Opened 12 months ago
Closed 12 months ago
#16220 closed enhancement (fixed)
Pip install dependency from a specified repository
Reported by: | Owned by: | Zach Pearson | |
---|---|---|---|
Priority: | moderate | Milestone: | |
Component: | Tool Shed | Version: | |
Keywords: | Cc: | chimerax-programmers | |
Blocked By: | Blocking: | ||
Notify when closed: | Platform: | all | |
Project: | ChimeraX |
Description
Can ChimeraX pyproject.toml or bundle_info.xml install a dependency from a repository other than PyPi? Specifically Roden wants to install a CUDA-enabled version of Torch from the torch repository.
pip install torch==2.2.1 --index-url https://download.pytorch.org/whl/cu121
when installing his DiffFit Toolshed bundle. Details are in the Github ticket
https://github.com/nanovis/DiffFit/issues/40
Another aspect is that he may only want to install using this repository on Windows. Is it possible in pyproject.toml or bundle_info.xml to specify the operating system when listing a dependency?
Change History (5)
comment:1 by , 12 months ago
comment:2 by , 12 months ago
I commented on GitHub:
I don't believe that pyproject.toml
files allow a package maintainer to give a URL for a dependency. See [this comment on discuss.python.org](https://discuss.python.org/t/how-to-specify-extra-index-in-a-pyproject-toml-for-pip-and-pip-tools/23592/4).
If torch is something that's going to stay static over the life of your package, you could:
- vendor it - copy torch into your project and import it locally in your code
- when your package starts up, import
run_logged_pip
fromchimerax.core.python_utils
and pass itinstall --user -qq --upgrade-strategy only-if-needed --no-warn-script-location --index-url https://download.pytorch.org/whl/cu12 torch==2.2.1
See the kvfinder bundle for how Eric has done it before.
comment:3 by , 12 months ago
The torch 2.2.1 Windows wheel from https://download.pytorch.org/whl/cu12 is over 2 Gbytes in size so probably not a good idea to try to include it in the DiffFit Toolshed wheel.
-rw-r--r--@ 1 goddard staff 2473941180 Oct 30 13:11 torch-2.1.1+cu121-cp311-cp311-win_amd64.whl
But maybe Zach's second suggestion is the way to go. Here is the ChimeraX code uses to pip install kvfinder from PyPi when the tool is first used.
https://github.com/RBVI/ChimeraX/blob/develop/src/bundles/kvfinder/src/__init__.py
comment:4 by , 12 months ago
Thanks very much, Tom, Zach, and Eric! Taking all of the abovementioned factors, I have settled on using a Dependencies tab. See the details at https://github.com/nanovis/DiffFit/issues/40#issuecomment-2453347706. Best, Roden On Wed, Oct 30, 2024 at 11:45\u202fPM ChimeraX <ChimeraX-bugs-admin@cgl.ucsf.edu> wrote: > > > > >
comment:5 by , 12 months ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Equivalent ticket closed on GitHub
I'm only knowledgable about bundle_info.xml-style content, so my answers here are limited to that. As per https://www.cgl.ucsf.edu/chimerax/docs/devel/tutorials/bundle_info.html, any tag can be limited to a specific platform with the "platform" tag attribute.
Assuming the underlying code can support it, perhaps the Dependency tag could have a "repository" attribute added to it to allow fetching from an alternative repository.
--Eric