pypa / installer

A low-level library for installing from a Python wheel distribution.
https://installer.readthedocs.io/
MIT License
126 stars 51 forks source link

`data_dir` lacks optional build tag #193

Open tibdex opened 1 year ago

tibdex commented 1 year ago

This is related to #171 but this issue impacts all wheels with a build tag and data files.

For example, using the following command to create a wheel for a package named foo with version 0.4.2:

python setup.py bdist_wheel --build-number 1337

will create a wheel named foo-0.4.2-1337-py3-none-any.whl. The build_tag in:

https://github.com/pypa/installer/blob/444e5295f2403ab303dcf14160591074396f1d21/src/installer/utils.py#L66-L68

will be 1337.

Data files in the wheel will have paths such as foo-0.4.2-1337.data/some_folder/some_file.txt. Due to the implementation of data_dir:

https://github.com/pypa/installer/blob/444e5295f2403ab303dcf14160591074396f1d21/src/installer/sources.py#L49-L52

we'll thus have the following variable values here:

https://github.com/pypa/installer/blob/444e5295f2403ab303dcf14160591074396f1d21/src/installer/_core.py#L43

assert data_dir == "foo-0.4.2.data"
assert path == "foo-0.4.2-1337.data/some_folder/some_file.txt"
assert posixpath.commonprefix([data_dir, path]) == "foo-0.4.2"
assert posixpath.commonprefix([data_dir, path]) != data_dir
# -> the scheme is incorrectly determined as root_scheme.

Can the implementation of data_dir be changed to take into account the wheel's build tag?


Environment:

eli-schwartz commented 1 year ago

This sounds like exactly the opposite of https://github.com/pypa/setuptools/issues/3997 and is probably a setuptools/wheel bug for generating a non spec-compliant artifact.

but this issue impacts all wheels with a build tag

Presumably it doesn't include any wheels that possess only modules/packages and don't have data files / headers / scripts. So it would impact the minority of wheels, really.

tibdex commented 1 year ago

Presumably it doesn't include any wheels that possess only modules/packages and don't have data files / headers / scripts. So it would impact the minority of wheels, really.

Yes you're right, I'll edit the issue description for future readers.