clean up source folder
This commit is contained in:
+67
-25
@@ -5,6 +5,28 @@ import subprocess
|
||||
from pathlib import Path
|
||||
from importlib.machinery import EXTENSION_SUFFIXES
|
||||
|
||||
INCLUDE_LAYOUT = {
|
||||
"configs": {
|
||||
"source_dir": Path("src/orisys/configs"),
|
||||
"target_subdir": Path("configs"),
|
||||
"patterns": ["ddjx01.json"],
|
||||
},
|
||||
"examples": {
|
||||
"source_dir": Path("."),
|
||||
"target_subdir": Path("examples"),
|
||||
"files": [
|
||||
Path("example1_basic_pipeline.py"),
|
||||
Path("example2_two_sensor_pipeline.py"),
|
||||
Path("example3_plot_data.py"),
|
||||
],
|
||||
},
|
||||
"docs": {
|
||||
"source_dir": Path("docs"),
|
||||
"target_subdir": Path("docs"),
|
||||
"patterns": ["*.md", "*.pdf"],
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def install_nuitka():
|
||||
print("Checking Nuitka installation...")
|
||||
@@ -49,11 +71,49 @@ def move_wheel_to_sdk(wheel_path: Path, version: str) -> Path:
|
||||
return dest_wheel
|
||||
|
||||
|
||||
def copy_included_files(pkg_dir: Path) -> dict[str, int]:
|
||||
copied_counts = {}
|
||||
for group_name, group_cfg in INCLUDE_LAYOUT.items():
|
||||
src_dir = group_cfg["source_dir"]
|
||||
dst_dir = pkg_dir / group_cfg["target_subdir"]
|
||||
dst_dir.mkdir(exist_ok=True)
|
||||
|
||||
copied = 0
|
||||
if "files" in group_cfg:
|
||||
for file_path in group_cfg["files"]:
|
||||
if file_path.exists():
|
||||
shutil.copy(file_path, dst_dir)
|
||||
copied += 1
|
||||
print(f"Copied {group_name}: {file_path.name}")
|
||||
else:
|
||||
for pattern in group_cfg.get("patterns", []):
|
||||
for src_file in src_dir.glob(pattern):
|
||||
shutil.copy(src_file, dst_dir)
|
||||
copied += 1
|
||||
print(f"Copied {group_name}: {src_file.name}")
|
||||
|
||||
if group_name == "examples":
|
||||
(dst_dir / "__init__.py").write_text("# Examples for orisys package\n", encoding="utf-8")
|
||||
|
||||
copied_counts[group_name] = copied
|
||||
return copied_counts
|
||||
|
||||
|
||||
def get_package_data_entries(ext_suffix: str) -> dict[str, list[str]]:
|
||||
package_data = {"orisys": [f"*{ext_suffix}"], "orisys.examples": ["*.py"]}
|
||||
for group_name, group_cfg in INCLUDE_LAYOUT.items():
|
||||
if group_name == "examples":
|
||||
continue
|
||||
target_subdir = str(group_cfg["target_subdir"]).replace("\\", "/")
|
||||
for pattern in group_cfg.get("patterns", []):
|
||||
package_data["orisys"].append(f"{target_subdir}/{pattern}")
|
||||
return package_data
|
||||
|
||||
|
||||
def build():
|
||||
install_nuitka()
|
||||
|
||||
version = get_version()
|
||||
src_dir = Path("src/orisys")
|
||||
output_dir = Path("build_nuitka")
|
||||
dist_dir = Path("dist_nuitka")
|
||||
|
||||
@@ -93,26 +153,11 @@ def build():
|
||||
shutil.copy(ext_file, dest_ext)
|
||||
print(f"Copied compiled package to {dest_ext}")
|
||||
|
||||
configs_src = src_dir / "configs"
|
||||
configs_dst = pkg_dir / "configs"
|
||||
configs_dst.mkdir()
|
||||
json_count = 0
|
||||
for json_file in configs_src.glob("*.json"):
|
||||
shutil.copy(json_file, configs_dst)
|
||||
json_count += 1
|
||||
print(f"Copied {json_count} JSON config files")
|
||||
|
||||
examples_dst = pkg_dir / "examples"
|
||||
examples_dst.mkdir(exist_ok=True)
|
||||
(examples_dst / "__init__.py").write_text("# Examples for orisys package\n", encoding="utf-8")
|
||||
example_files = [Path("example1_basic_pipeline.py"), Path("example2_two_sensor_pipeline.py")]
|
||||
example_count = 0
|
||||
for example_file in example_files:
|
||||
if example_file.exists():
|
||||
shutil.copy(example_file, examples_dst)
|
||||
example_count += 1
|
||||
print(f"Copied example: {example_file.name}")
|
||||
print(f"Copied {example_count} example files to orisys/examples/")
|
||||
copied_counts = copy_included_files(pkg_dir)
|
||||
print(f"Copied {copied_counts['configs']} JSON config files")
|
||||
print(f"Copied {copied_counts['examples']} example files to orisys/examples/")
|
||||
print(f"Copied {copied_counts['docs']} doc files to orisys/docs/")
|
||||
package_data = get_package_data_entries(ext_suffix)
|
||||
|
||||
setup_py_path = dist_dir / "setup.py"
|
||||
setup_content = f"""
|
||||
@@ -129,10 +174,7 @@ setup(
|
||||
author="Orisys",
|
||||
packages=['orisys', 'orisys.examples'],
|
||||
package_dir={{'': 'wheel_root'}},
|
||||
package_data={{
|
||||
'orisys': ['*{ext_suffix}', 'configs/*.json'],
|
||||
'orisys.examples': ['*.py'],
|
||||
}},
|
||||
package_data={package_data},
|
||||
include_package_data=True,
|
||||
install_requires=[
|
||||
"numpy>=1.24.4",
|
||||
|
||||
Reference in New Issue
Block a user