From 60dd6ebbd5927e70ca97bf3037ecd0a75c04c3a7 Mon Sep 17 00:00:00 2001 From: Chris Arderne Date: Sat, 31 Aug 2024 21:07:48 +0100 Subject: [PATCH] dont support sdist->wheel build --- README.md | 9 +++++---- docs/quickstart.md | 9 +++++---- plugins/hatch/hatch_una/hatch_build.py | 9 +-------- plugins/hatch/hatch_una/hatch_meta.py | 15 +++++---------- plugins/hatch/hatch_una/util.py | 1 - 5 files changed, 16 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 27125ab..bc512b0 100644 --- a/README.md +++ b/README.md @@ -65,14 +65,14 @@ uv add --dev una ``` Then setup the Una workspace. This will generate a structure and an example lib and app. -``` +```bash uv run una create workspace rm -rf src uv sync ``` Have a look at what's been generated: -``` +```bash tree ``` @@ -99,9 +99,10 @@ tail apps/printer/pyproject.toml It added `greeter` as an internal dependency to `printer`. It didn't add `cowsay-python`, as transitive external dependencies are only resolved at build-time. -Now you can build your app: +Now you can build your app. Note that you **must** specify the `--wheel` parameter. Una doesn't currently work for builds that do source -> sdist -> wheel, as these break some things with uv virtual envs. ```bash -uvx --from build pyproject-build --installer=uv --outdir=dist apps/printer +uvx --from build pyproject-build --installer=uv \ + --outdir=dist --wheel apps/printer # this will inject the cowsay-python external dependency ``` diff --git a/docs/quickstart.md b/docs/quickstart.md index 99e3f0f..c91f373 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -15,14 +15,14 @@ uv add --dev una ``` Then setup the Una workspace. This will generate a structure and an example lib and app. -``` +```bash uv run una create workspace rm -rf src uv sync ``` Have a look at what's been generated: -``` +```bash tree ``` @@ -49,9 +49,10 @@ tail apps/printer/pyproject.toml It added `greeter` as an internal dependency to `printer`. It didn't add `cowsay-python`, as transitive external dependencies are only resolved at build-time. -Now you can build your app: +Now you can build your app. Note that you **must** specify the `--wheel` parameter. Una doesn't currently work for builds that do source -> sdist -> wheel, as these break some things with uv virtual envs. ```bash -uvx --from build pyproject-build --installer=uv --outdir=dist apps/printer +uvx --from build pyproject-build --installer=uv \ + --outdir=dist --wheel apps/printer # this will inject the cowsay-python external dependency ``` diff --git a/plugins/hatch/hatch_una/hatch_build.py b/plugins/hatch/hatch_una/hatch_build.py index 24ac52f..c76348f 100644 --- a/plugins/hatch/hatch_una/hatch_build.py +++ b/plugins/hatch/hatch_una/hatch_build.py @@ -19,8 +19,7 @@ class UnaBuildHook(BuildHookInterface[BuilderConfig]): def initialize(self, version: str, build_data: dict[str, Any]) -> None: via_sdist = Path("PKG-INFO").exists() if via_sdist: - print("una-build: In sdist, do nothing") - return + raise ValueError("Una doesn't work for wheels built from sdist") print("una-build: Injecting internal dependencies") @@ -45,15 +44,9 @@ def initialize(self, version: str, build_data: dict[str, Any]) -> None: for f in files: add_dep_files[str(f)] = str(f.relative_to(package_dir)) - add_packages_pyproj = { - str(p / util.PYPROJ): str(util.EXTRA_PYPROJ / p.name / util.PYPROJ) - for p in package_dirs - } - build_data["force_include"] = { **build_data["force_include"], **add_dep_files, - **add_packages_pyproj, } diff --git a/plugins/hatch/hatch_una/hatch_meta.py b/plugins/hatch/hatch_una/hatch_meta.py index 9e9228f..884104c 100644 --- a/plugins/hatch/hatch_una/hatch_meta.py +++ b/plugins/hatch/hatch_una/hatch_meta.py @@ -21,19 +21,14 @@ def update(self, metadata: dict[str, Any]) -> None: ext_deps, int_deps = util.get_dependencies(path) via_sdist = Path("PKG-INFO").exists() - members: list[str] = [] if via_sdist else util.get_members() + if via_sdist: + raise ValueError("Una doesn't work for wheels built from sdist") + + members: list[str] = util.get_members() add_deps: list[str] = [] for dep_name in int_deps: - # In builds that do src -> sdist -> wheel, the needed pyproject.toml files - # will have been copied into the sdist so they're available for the wheel build. - # Here we check for both in order. - - dep_path = ( - util.EXTRA_PYPROJ / Path(dep_name).name - if via_sdist - else util.find_package_dir(dep_name, members) - ) + dep_path = util.find_package_dir(dep_name, members) # load all third-party dependencies from this internal dependency into the # project.dependencies table diff --git a/plugins/hatch/hatch_una/util.py b/plugins/hatch/hatch_una/util.py index 5fefedc..5843d8c 100644 --- a/plugins/hatch/hatch_una/util.py +++ b/plugins/hatch/hatch_una/util.py @@ -3,7 +3,6 @@ from typing import Any PYPROJ = "pyproject.toml" -EXTRA_PYPROJ = Path("_extra_pyproj") def load_conf(path: Path) -> dict[str, Any]: