添加对单个python文件的编译支持
This commit is contained in:
+21
-6
@@ -24,16 +24,26 @@ def build_extensions(target_dirs):
|
||||
for target_dir in target_dirs:
|
||||
# Ensure target directory exists
|
||||
if not os.path.exists(target_dir):
|
||||
print(f"Warning: Directory '{target_dir}' not found. Skipping.")
|
||||
print(f"Warning: Path '{target_dir}' not found. Skipping.")
|
||||
continue
|
||||
|
||||
# Get the absolute path of the target directory
|
||||
abs_target_dir = os.path.abspath(target_dir)
|
||||
# Get the absolute path of the target
|
||||
abs_target_path = os.path.abspath(target_dir)
|
||||
|
||||
print(f"Scanning {abs_target_dir} for Python files...")
|
||||
# Check if the target is a file or directory
|
||||
if os.path.isfile(abs_target_path):
|
||||
if abs_target_path.endswith(".py"):
|
||||
file_path = abs_target_path
|
||||
rel_path = os.path.relpath(file_path, project_root)
|
||||
module_name = os.path.splitext(rel_path)[0].replace(os.sep, ".")
|
||||
print(f"Found file: {rel_path} -> {module_name}")
|
||||
extensions.append(Extension(module_name, [file_path]))
|
||||
continue
|
||||
|
||||
print(f"Scanning {abs_target_path} for Python files...")
|
||||
|
||||
# Walk through the directory
|
||||
for root, dirs, files in os.walk(abs_target_dir):
|
||||
for root, dirs, files in os.walk(abs_target_path):
|
||||
for file in files:
|
||||
if file.endswith(".py"):
|
||||
file_path = os.path.join(root, file)
|
||||
@@ -100,7 +110,12 @@ def build_extensions(target_dirs):
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Default directories to compile if none provided
|
||||
DEFAULT_TARGETS = ["app/services", "app/native/wndb", "app/algorithms"]
|
||||
DEFAULT_TARGETS = [
|
||||
"app/services",
|
||||
"app/native/wndb",
|
||||
"app/algorithms",
|
||||
"app/infra/epanet/epanet.py",
|
||||
]
|
||||
|
||||
# Check for help flag
|
||||
if len(sys.argv) > 1 and sys.argv[1] in ["--help", "-h"]:
|
||||
|
||||
Reference in New Issue
Block a user