You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue here is that optional dependencies aren't being written properly to PKG-INFO, therefore making it impossible to pip install the package with options. This was originally identified in biopragmatics/curies#147. Here's a minimal reproduction:
$ uv --preview init xyz --build-backend uvInitialized project `xyz` at `/Users/cthoyt/xyz`
$ cd xyz
$ uv --preview add defusedxml --optional xmlUsing CPython 3.11.10Creating virtual environment at: .venvResolved 2 packages in 59ms Built xyz @ file:///Users/cthoyt/xyzPrepared 1 package in 5msInstalled 2 packages in 3ms + defusedxml==0.7.1 + xyz==0.1.0 (from file:///Users/cthoyt/xyz)
$ echo"import defusedxml"> src/xyz/__init__.py
$ echo"def main(): print('hello from modified xyz')">> src/xyz/__init__.py
$ uv run xyzhello from modified xyz
If you start from scratch, you need to do uv run --extra xml xyz, since the option isn't installed yet.
Now comes the problematic part, after building:
$ uv --preview buildBuilding source distribution (uv build backend)...Building wheel from source distribution (uv build backend)...Successfully built dist/xyz-0.1.0.tar.gzSuccessfully built dist/xyz-0.1.0-py3-none-any.whl
$ tar -xOzf dist/xyz-0.1.0.tar.gz xyz-0.1.0/PKG-INFO Metadata-Version: 2.3Name: xyzVersion: 0.1.0Summary: Add your description hereAuthor: Charles Tapley HoytAuthor-email: Charles Tapley Hoyt <[email protected]>Requires-Python: >=3.11Provides-Extra: xmlDescription-Content-Type: text/markdown
Here's the bug: This PKG-INFO file should also include the line Requires-Dist: defusedxml>=0.7.1; extra == 'xml'.
I believe this also implies that the test scenario at
is incomplete, since it's also missing the appropriate Requires-Dist: lines for mysql and postgres
What this means for pip users
This affects users by the following scenario using pip to install the package. The minimal reproduction below should follow the code before, in which it creates a virtual environment, activates it (I'm using fish, but so activation will vary based on your console), installing pip in the virtual environment, then using pip to install the package locally
This can be reproduced with a pip installation scenario by creating a new virtual environment, installing pip in it, then using pip to install. Note that the same thing happens whether you're using -e for an editable installation or not.
$ uv venvCreating virtual environment at: .venvActivate with: source .venv/bin/activate.fish
$ source .venv/bin/activate.fish
$ uv pip install pipResolved 1 package in 196msPrepared 1 package in 182msInstalled 1 package in 6ms + pip==24.3.1
$ UV_PREVIEW=1 python -m pip install .[xml]Processing /Users/cthoyt/Desktop/xyz Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... doneBuilding wheels for collected packages: xyz Building wheel for xyz (pyproject.toml) ... done Created wheel for xyz: filename=xyz-0.1.0-py3-none-any.whl size=1503 sha256=23ddd26cc3e4c20321aec8053bf8ce5e80d9340977d96555e34ce06b7450c6f5 Stored in directory: /private/var/folders/6k/r2gmmc213vl6h7bv20x624xw0000gn/T/pip-ephem-wheel-cache-hcnf61u2/wheels/92/98/ae/8e6e182b3e32485aed6bab20d53b27efc72ed7f772a8da227bSuccessfully built xyzInstalling collected packages: xyzSuccessfully installed xyz-0.1.0
$ pip listPackage Version Editable project location------- ------- -------------------------pip 24.3.1xyz 0.1.0 /Users/cthoyt/Desktop/xyz
This listing should include defusedxml, but doesn't
How it should look, using hatch backend
Here's an alternate reproduction that gets the right thing, using hatchling as the backend:
$ uv init xyz --build-backend hatchInitialized project `xyz` at `/Users/cthoyt/Desktop/xyz`
$ cd xyz
$ uv add defusedxml --optional xmlUsing CPython 3.11.10Creating virtual environment at: .venvResolved 2 packages in 1ms Built xyz @ file:///Users/cthoyt/Desktop/xyzPrepared 1 package in 218msInstalled 2 packages in 1ms + defusedxml==0.7.1 + xyz==0.1.0 (from file:///Users/cthoyt/Desktop/xyz)
$ uv buildBuilding source distribution...Building wheel from source distribution...Successfully built dist/xyz-0.1.0.tar.gzSuccessfully built dist/xyz-0.1.0-py3-none-any.whl
$ tar -xOzf dist/xyz-0.1.0.tar.gz xyz-0.1.0/PKG-INFO Metadata-Version: 2.4Name: xyzVersion: 0.1.0Summary: Add your description hereAuthor-email: Charles Tapley Hoyt <[email protected]>Requires-Python: >=3.11Provides-Extra: xmlRequires-Dist: defusedxml>=0.7.1; extra == 'xml'
The text was updated successfully, but these errors were encountered:
Closes#147
Temporarily switches to hatch as a backend until
astral-sh/uv#10091 is addressed. setuptools
still has a major bug with metadata upload to PyPI related to licenses
between metadata version 2.3 and 2.4, so it doesn't make sense to go
back to that at all.
The following should now work:
```console
$ git clone https://github.com/biopragmatics/curies
$ cd curies
$ git checkout -b hatch-backend
$ python -m pip install -e .[flask,rdflib]
$ python -m curies mapper --host 0.0.0.0 --port 8764 bioregistry
# then, navigate to http://0.0.0.0:8764/sparql
```
I'm on uv 0.5.11 (c4d0caa 2024-12-19).
The issue here is that optional dependencies aren't being written properly to PKG-INFO, therefore making it impossible to pip install the package with options. This was originally identified in biopragmatics/curies#147. Here's a minimal reproduction:
If you start from scratch, you need to do
uv run --extra xml xyz
, since the option isn't installed yet.Now comes the problematic part, after building:
Here's the bug: This PKG-INFO file should also include the line
Requires-Dist: defusedxml>=0.7.1; extra == 'xml'
.I believe this also implies that the test scenario at
uv/crates/uv-build-backend/src/metadata.rs
Lines 1029 to 1036 in ad92aaf
Requires-Dist:
lines for mysql and postgresWhat this means for
pip
usersThis affects users by the following scenario using pip to install the package. The minimal reproduction below should follow the code before, in which it creates a virtual environment, activates it (I'm using fish, but so activation will vary based on your console), installing pip in the virtual environment, then using pip to install the package locally
This can be reproduced with a pip installation scenario by creating a new virtual environment, installing pip in it, then using pip to install. Note that the same thing happens whether you're using
-e
for an editable installation or not.This listing should include
defusedxml
, but doesn'tHow it should look, using
hatch
backendHere's an alternate reproduction that gets the right thing, using hatchling as the backend:
The text was updated successfully, but these errors were encountered: