Skip to content

Commit

Permalink
dont support sdist->wheel build
Browse files Browse the repository at this point in the history
  • Loading branch information
carderne committed Aug 31, 2024
1 parent 8e8ae44 commit 60dd6eb
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 27 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand All @@ -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
```

Expand Down
9 changes: 5 additions & 4 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand All @@ -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
```

Expand Down
9 changes: 1 addition & 8 deletions plugins/hatch/hatch_una/hatch_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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,
}


Expand Down
15 changes: 5 additions & 10 deletions plugins/hatch/hatch_una/hatch_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion plugins/hatch/hatch_una/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from typing import Any

PYPROJ = "pyproject.toml"
EXTRA_PYPROJ = Path("_extra_pyproj")


def load_conf(path: Path) -> dict[str, Any]:
Expand Down

0 comments on commit 60dd6eb

Please sign in to comment.