richliaw
richliaw

Reputation: 2045

How to pip install with wheel specifying extras?

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]

Upvotes: 11

Views: 7575

Answers (2)

roomrys
roomrys

Reputation: 194

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 👀

Upvotes: 1

phd
phd

Reputation: 94397

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.

Upvotes: 25

Related Questions