0

Related to this question: What do square brackets mean in pip install?

I have a setup.py file that needs to install azure[common] package. However, if I try:

setup(
    ...
    install_requires=['azure[common]'],
    ...
)

This results in an error:

pkg_resources.UnknownExtra: azure 4.0.0 has no such extra feature 'common'

But, if I do:

pip install 'azure[common]', then it works.

There were a lot of bugs and unexpected behavior involved in the experiment above, so the question doens't really make sense anymore.

  1. There's a bug in pip which causes random stuff to be installed if "extra" package isn't found. So, pip install 'azure[common]' shouldn't have worked at all. It's an error that led me to believe there was such a package.
  2. There's an inconsistency between how setuptools and pip install packages from wheels. setuptools installs (or seems to) only install one package from a wheel, while pip will install everything, and if there are more than one package, then it will install more. So, pip was installing azure.common by mistake, but there is no way to intentionally install just that package. At the minimum, you will also get azure.profiles plus a fake package azure_common, which doesn't really contain anything.

Given all this new info, I reformulated the question here: How to make setuptools install a wheel containing multiple packages?

wvxvw
  • 8,089
  • 10
  • 32
  • 61
  • According to https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies your entry is correct. The error-message also indicates that the problem is not the format as such, but the package does not have an extra named common. – deets Dec 02 '18 at 16:28
  • The github suggests azure-common.https://github.com/Azure/azure-sdk-for-python/blob/master/azure-common/setup.py – deets Dec 02 '18 at 16:30
  • @deets that's the wrong package, it doesn't contain the code installed by this dependency. The dependency I need installs code under `site-packages/azure/common`, but the one you pointed at installs code under `site-packages/azure-common`. – wvxvw Dec 02 '18 at 19:43
  • @deets PS. The error message might be boolshit. `pip` and `setuptools` don't really coordinate their formatting conventions, so the notation may mean one thing to `pip` and a completely different thing to `setuptools`. It's just tons of atrocious code you need to read through before you can figure that out, and I hoped someone would have already done the dumpster-diving for me... – wvxvw Dec 02 '18 at 19:52
  • @wvxvw `azure-common` installs code under `site-packages/azure/common` – Artemij Rodionov Dec 03 '18 at 00:34
  • @Artemiy if you simply put it in `install_requires` it doesn't. – wvxvw Dec 03 '18 at 09:25
  • I have the same issue with `ray[rllib]`! Installing it with `pip install ray[rllib]` works fine, but listing it inside a `setup.py` leads to this error. Any ideas why? See [related GitHub issue](https://github.com/ray-project/ray/issues/11274). – stefanbschneider Feb 09 '21 at 18:28

1 Answers1

3

Azure does not provide the common extra dependency. pip install azure[common] shows the warning about it.

Artemij Rodionov
  • 1,721
  • 1
  • 17
  • 22
  • @wvxvw , it seems, you should try this: `pip install azure.common` – Artemij Rodionov Dec 02 '18 at 16:33
  • That's simply not true, but the command you provided is impossible, so I doubt you even tested it. You need quotes around `"azure[common]"` otherwise it will be interpreted by shell (or at least some shells) as test statement. But then again, maybe in some Windows shell it will not do that, and it did work for you like that, but maybe for Windows there is not such package, idk, I didn't try. Wrt `pip install azure.common` - `pip` automatically corrects that to be `azure-common` and installs a wrong package. – wvxvw Dec 02 '18 at 19:42
  • I created a [gist](https://gist.github.com/artemiy312/0c5f0e6acfeb84e96a82b77eff97b784) for you. You should pay attention to line 4. The command I provided is correct for bash 4.4.23(1)-release version, which i use. Quotes around `"azure[common]"` don't change anything. I don't know what exactly you want to install, so it was just an assumption. Sorry for it. – Artemij Rodionov Dec 02 '18 at 23:55
  • well, try `pip install azure[common]` and then try `pip install 'azure[common]'` and observe the difference. – wvxvw Dec 03 '18 at 09:27
  • Your ultimate test should be: after installing this package, `python -c 'import azure.common'` should work. Also, where's the warning you were talking about? I don't see it. – wvxvw Dec 03 '18 at 09:32
  • OK, but I'll have to take back the interpretation of square brackets: it only works like that in `zsh`, `dash` and `bash` don't treat them specially in this place, however my reading of Shell grammar suggests that `zsh` is actually correct here. – wvxvw Dec 03 '18 at 09:46
  • Ah, and I do see the warning now. So... if there is no extra... what the hell is it installing? – wvxvw Dec 03 '18 at 12:16