-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected --target behavior with/without --upgrade #8799
Comments
The wheel I got from PyPI contains three directories:
So it seems like neither of the commands is doing the right thing (the right result should be a combination of the two, IIUC), but they err differently and cuase the discrepency. |
Compare with sampleproject:
|
My guess is that the file-copying logic assumes |
That makes sense, and explains why it produces the following warning even on a fresh install:
So is this a bug in |
Probably in pip, since pip implements wheel installation internally. I think instead of letting the directories overwrite each other, pip should merge them and emit warnings when there are duplicate files. /cc @dholth |
…buildpack Some dependencies are incompatible with the --upgrade and --target flag combination, e.g. pypa/pip#8799. PiperOrigin-RevId: 328384678 Change-Id: Iea6962774a6bd82f02435ba785ba92445e762c8d
teradatasql/ is copied to purelib because Root-Is-Purelib: true:
teradatasql-17.0.0.1.data/data/teradatasql/ is copied to data per https://www.python.org/dev/peps/pep-0427/ It just so happens that purelb and data are the same directory in this case. |
Data files are a surprisingly confusing aspect of building wheels. Doubly so if you don't want them to be installed in the same directory as your python files. After way too much trial and error I have managed to produce source code that creates a wheel with a layout that triggers the issue:
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
[metadata]
name = mypackage
version = 0.0.1
[options]
packages = mypackage
[options.data_files]
mypackage = data-lives-here/example.txt
Proof
|
Is it intentional that purelib and data are the same directory when using |
I don't think it's so much "intentional" as that there's no obvious "better" option. Where would you expect data to go in an install where the only thing you've specified is (in effect) the location of the
|
The culprit: pip/src/pip/_internal/commands/install.py Lines 477 to 509 in c188d1f
|
btw:
This is wrong. It should be:
|
Possibly duplicate: #7548 |
Yup, that issue seems to be the same as this. Since this issue contains much more detailed information and discussion on how this should be fixed, I’ll close #7548 in favour of this one. |
Also adding awaiting PR since we’ve more or less concluded how this should be resolved, and “only” need someone to have the time to actually implement it. |
Environment
Description
In a fresh Docker container, I'm seeing a difference in the files installed between
pip install X --target /tmp
andpip install X --target /tmp --upgrade
. My understanding of--target
is that the--upgrade
flag will only produce different behavior if there's already an existing installation present.I can't determine if this due to a badly formed distribution of the project in question, a bug in
pip
,wheel
, or a combination of them all.(You can ignore
--no-deps
below, I just included it to keep the output smaller).Behavior without
--upgrade
Behavior with
--upgrade
Expected behavior
The same files are installed regardless of whether
--upgrade
is specified.The text was updated successfully, but these errors were encountered: