9

I have a package with extras that I can typically install with the following command.

pip install package[extras]

However, I can also install the same package via wheels, specifying some wheel URL like the following.

pip install package_url.whl

Is it possible to also specify the extras when installing via wheel url, something in spirit?

pip install package_url.whl[extras]
richliaw
  • 1,925
  • 16
  • 14

2 Answers2

20
pip install 'package_url.whl[extras]'

works. I added apostrophes to screen (escape) [] as they are shell metacharacters and I prefer to be on the safe side.

phd
  • 82,685
  • 13
  • 120
  • 165
  • This did not work for me because though `http://package_url.whl` is a valid resource on the server where the wheel resides, `http://package_url.whl[extras]` is not and thus returns a 404 – ThisGuyCantEven Dec 18 '19 at 20:34
  • From such a server you can only install the wheel but not wheel+extras. Separate downloading of `http://package_url.whl` into a local file and running `pip install package.whl[extras]`. – phd Dec 18 '19 at 20:40
  • Thought I might have to download the wheel and do this, just not super happy about it – ThisGuyCantEven Dec 18 '19 at 20:44
  • `pip` is intended for a completely different kind of usage. It's for PyPI (or a similar local server) with so called "simple" API. – phd Dec 18 '19 at 20:45
  • 7
    @ThisGuyCantEven For URLs, use this @ syntax: `pip install 'faust[rocksdb] @ https://files.pythonhosted.org/packages/79/f8/3fec4f5c3e5bf1ce8bb557ae507525253fa30a5cfc5984f342b931143f75/faust-1.10.4-py2.py3-none-any.whl'` – Kevin Tindall Mar 15 '21 at 13:17
  • 1
    @phd No, pip supports installing from VCS and any URL that points to a egg or wheel file. PyPI is not the only source. – Keto Jan 04 '22 at 21:03
0

I am working with a conda environment (ironically to test my wheel build) and wanted a way to quickly test the different extras of my local wheel. The only option that worked for me in the environment.yaml file was from @ThisGuyCantEven in the comment above

name: wheel_test

dependencies:
  - python ~=3.7
  - pip
  - pip:
    - 'my_package[extra_uno] @ file:///absolute/path/to/my_package.whl'

This would translate to

pip install 'my_package[extra_uno] @ file:///absolute/path/to/my_package.whl'

Thanks @ThisGuyCantEven! Hopefully this answer is easier to spot now... or can at least be found by ChatGPT

roomrys
  • 81
  • 1
  • 6