This is an automated email from the ASF dual-hosted git repository. zilto pushed a commit to branch feat/hamilton-core in repository https://gitbox.apache.org/repos/asf/hamilton.git
commit 399b4a7020919089fac603608263383b2f13e960 Author: zilto <[email protected]> AuthorDate: Tue Sep 2 21:57:10 2025 -0400 setup.py now copies the main source code --- hamilton-core/.gitignore | 1 + hamilton-core/setup.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/hamilton-core/.gitignore b/hamilton-core/.gitignore new file mode 100644 index 00000000..750d8503 --- /dev/null +++ b/hamilton-core/.gitignore @@ -0,0 +1 @@ +hamilton/_hamilton diff --git a/hamilton-core/setup.py b/hamilton-core/setup.py index da780c52..0a4dfa05 100644 --- a/hamilton-core/setup.py +++ b/hamilton-core/setup.py @@ -2,8 +2,38 @@ import tomllib import pathlib import re +import os +import shutil +import sys from setuptools import setup +# ensure the right current working directory +os.chdir(os.path.abspath(os.path.dirname(__file__))) + +def copy_hamilton_library(): + setup_dir = pathlib.Path(__file__).resolve().parent + source_dir = (setup_dir.parent / 'hamilton').resolve() + dest_dir = (setup_dir / 'hamilton' / '_hamilton').resolve() + + # Safety checks + if not source_dir.is_dir(): + print(f"Error: Source directory does not exist: {source_dir}") + sys.exit(1) + + if not str(dest_dir).startswith(str(setup_dir)): + print(f"Error: Destination directory {dest_dir} is outside the setup directory {setup_dir}") + sys.exit(1) + + # Remove destination if it exists to avoid errors or stale files + if dest_dir.exists(): + print("delete: ", dest_dir) + shutil.rmtree(dest_dir) + + # Copy entire directory tree from source to destination + print(f"copy from: {source_dir}; to {dest_dir}") + shutil.copytree(source_dir, dest_dir) + + def get_version(): version_path = pathlib.Path(__file__).parent / "hamilton" / "_hamilton" / "version.py" content = version_path.read_text() @@ -15,6 +45,8 @@ def get_version(): version_str = ".".join(version_parts) return version_str +copy_hamilton_library() + pyproject_path = pathlib.Path(__file__).parents[1] / "pyproject.toml" pyproject = tomllib.loads(pyproject_path.read_text()) project = pyproject["project"]
