Specific package from install environment in build environment. #4035
-
Hello, In the build process of my package (pip install), I link (CMake) against libraries by another package. Therefore, I either need to install the exact same package in the isolated build environment (1) or know the package path in the install environment and pass this information down to the isolated build environment (2). The package in question I need to link against is PyTorch. (1) Defining the same package version in build-system/requires and dependencies does not guarantee the same installed package. A GPU/Cuda version in the install environment will show as torch==2.0.0 but placing torch==2.0.0 in the build-system/requires will download and install torch CPU version in the build environment. Further, I do not want to restrict the user to either CPU or GPU version but rather want to use the same package in the build environment, which is already installed in the install environment. (2) Determining the path of the package from the install environment is trivial: I would appreciate any help. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Hi @Tim-Salzmann, I am afraid that the way the installation procedure is currently defined by PyPA decouples the building phase with the installation phase. There is no guarantee the "installation environment" is "ready" (or even available at all) when running the "build" phase. This means that The only alternative I can see if you want to go via the Regarding option
Version identifiers should unequivocally identify an specific implementation of a package, except for the system platform, ABIs etc... But then, the Having a look on the PyTorch private index we can see things like torch-2.0.1+cu118-cp38-cp38-win_amd64.whl and torch-2.0.0+cpu.cxx11.abi-cp38-cp38-linux_x86_64.whl. Note how they have a local version segment (e.g.
Please note that this is not possible. There might be no such a thing as a version "already installed in the install environment". For example, imagine that the user is installing your package in a brand new environment. There is no PyTorch already there... instead it will be installed as a consequence of being defined as a dependency of your package. In this case the build environment comes first. If you want the workflow to be exactly as you described, I am afraid you need to give specific instructions for your users to manually install your package. E.g.:
(which basically brings you back to the same comments for option If you want to avoid giving such detailed/manual install instructions to your users, I think that the best place to find advice is to ask to the PyTorch maintainers. They are the people that know about the intricacies of their workaround for wheel's lack of support for GPU tagging and how that interplays with 3rd-party packages/plugins. |
Beta Was this translation helpful? Give feedback.
-
Hi, Thanks for the detailed reply! This is much appreciated!
This crossed my mind too. However, I could not find a way to determine the name of the installed wheel in the install environment during the setup routine. Any ideas? In the meantime, I will opt for the easy solution.
Thank you for the help! |
Beta Was this translation helpful? Give feedback.
-
Quick follow up:
this works when run in a virtual environment. However when I try to install system-wide (happens in my github CI pipeline) I get the following output:
No dependencies are installed either and the package is not usable. I appreciate any help! |
Beta Was this translation helpful? Give feedback.
Hi @Tim-Salzmann, I am afraid that the way the installation procedure is currently defined by PyPA decouples the building phase with the installation phase.
There is no guarantee the "installation environment" is "ready" (or even available at all) when running the "build" phase. This means that
setuptools
itself has no access to the "installation environment", and therefore even if we wanted, we have no means of providing references to it insetup.py
.The only alternative I can see if you want to go via the
(2)
route is explicitly asking forpip
to disable build isolation (pip install --no-build-isolation ...
). This option askspip
to use the same environment for building and installing t…