1

There is way in python, to install dependencies according the libs in the host machine? The "issue" is I have package that shall work in machine with and without a lib e.q: Hadoop.

But, the pydoop is falling when it is not installed in the host. It is possible make a wheel intelligent enough to not to installs pydoop in machines does not have Hadoop installed?

Agus
  • 1,604
  • 2
  • 23
  • 48

1 Answers1

1

It is possible, but I don't recommend you do that. Instead, make it an 'extra' option in the distribution using setuptools:

extras_require: A dictionary mapping names of “extras” (optional features of your project) to strings or lists of strings specifying what other distributions must be installed to support those features. See the section below on Declaring Dependencies for details and examples of the format of this argument.

So your setup.py will have something like this:

setup(
    name="PyAgus",
    ...
    extras_require={
        'hadoop':  ["pydoop"],
    }
)

Leave it up to the user to decide whether to install with the optional hadoop support or not. Note that the "user" in this case might be an orchestration repo, e.g. salt / ansible / puppet.

If you really want to dynamically decide whether to install an extra or not based upon inspecting the libs avail on the source machine, you can do it using a post-install script or just adding the logic for generating install_requires argument directly into the setup.py. Both methods are hacky and PyPA has an open ticket about that, if you want to follow the discussion.

wim
  • 338,267
  • 99
  • 616
  • 750