Hendrik Wiese
Hendrik Wiese

Reputation: 2219

`setup.py` `install_requirements` in Conda environment: force use of `pip`

I have a conda environment for one of my projects. It contains a setup.py that defines an install_requirements option. Conda seems to insist on using its own channels on all of the requirements. Some do not exist in the Conda catalogue though, but can definitely be installed through pip.

Is there a way to tell python setup.py install to use pip on these particular requirements? Preferably inside the setup.py?

Upvotes: 2

Views: 1018

Answers (1)

darthbith
darthbith

Reputation: 19597

No, there is no way to use pip to install packages during the conda build process. Conda insists on using conda packages as dependencies for all conda packages. In my opinion, this is a good restriction because it ensures you'll have a self-consistent environment and until very recently, conda and pip did not play very nicely together. In addition, pip has its own dependency solver that may give different/incompatible versions of dependent packages to the ones that conda would solve for.

For pure Python packages, its not very hard to generate a conda package, and you can upload it to conda forge so that it is generally available. See the conda-forge website, which states

  • Fork conda-forge/staged-recipes
  • Create a new branch from the staged-recipes master branch.
  • Add a new conda recipe in the "recipes" directory. There is an example of a well written recipe there. Further guidance on writing good recipes.
  • Propose the change as a pull request. Your recipe will automatically be built on Windows, Linux and OSX to test that it works, but the distribution will not yet be available on the conda-forge channel.
  • Once the recipe is ready it will be merged and new "feedstock" repository will automatically be created for the recipe. The build and upload processes take place in the feedstock, and once complete the package will be available on the conda-forge channel

Upvotes: 3

Related Questions