From d67b3e906eb50bba36de8a9d38d384f6e82dc8fc Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sun, 1 Mar 2026 12:04:48 -0800 Subject: [PATCH] release: copy all Python sources and deps to shim branch (#34) The shim branch was only copying __init__.py from each package, which dropped Python source files needed for CFFI builds (build.py, colors.py, defines.py, enums.py, version.py) and extra packages like pyray. It also dropped project dependencies like cffi. - Copy all .py files from the main module, not just __init__.py - Copy extra packages listed in packages.find.include - Preserve project dependencies in generated pyproject.toml --- release.sh | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/release.sh b/release.sh index 1efb19c..67aacfb 100755 --- a/release.sh +++ b/release.sh @@ -58,9 +58,28 @@ for toml in sorted(pathlib.Path(".").glob("*/pyproject.toml")): pkg_dir = tmp_dir / pkg mod_dir = pkg_dir / module mod_dir.mkdir(parents=True, exist_ok=True) - shutil.copy2(pathlib.Path(pkg) / module / "__init__.py", mod_dir / "__init__.py") + + # copy all .py files from the main module + src_mod = pathlib.Path(pkg) / module + for py_file in src_mod.glob("*.py"): + shutil.copy2(py_file, mod_dir / py_file.name) + + # copy extra packages (e.g. pyray for raylib) + include_patterns = data.get("tool", {}).get("setuptools", {}).get("packages", {}).get("find", {}).get("include", []) + extra_packages = [] + for pattern in include_patterns: + p = pattern.rstrip("*") + if p and p != module and p != f"{module}/": + src_extra = pathlib.Path(pkg) / p + if src_extra.is_dir(): + dst_extra = pkg_dir / p + shutil.copytree(src_extra, dst_extra, dirs_exist_ok=True) + extra_packages.append(pattern) + shutil.copy2(shim_setup, pkg_dir / "setup.py") + deps = data.get("project", {}).get("dependencies", []) + lines = [ "[build-system]", 'requires = ["setuptools>=64", "wheel", \'tomli; python_version < \"3.11\"\']', @@ -73,15 +92,19 @@ for toml in sorted(pathlib.Path(".").glob("*/pyproject.toml")): 'requires-python = ">=3.8"', ] + if deps: + lines.append(f"dependencies = {json.dumps(deps)}") + if scripts: lines += ["", "[project.scripts]"] for name, target in scripts.items(): lines.append(f'"{name}" = {json.dumps(target)}') + find_include = [f"{module}*"] + extra_packages lines += [ "", "[tool.setuptools.packages.find]", - f'include = ["{module}*"]', + f"include = {json.dumps(find_include)}", "", "[tool.setuptools.package-data]", f'{module} = ["{datadir}/**/*"]',