4

I would like to build a Conda package for my project. However, there is one package that is on pip-only (not uploaded to Conda channel). How to include pip only package when using conda-build command?

I tried using Conda skeleton to build a package from PyPI URL but it doesn't work because the file on PyPI site is a .whl file instead of a tar.gz file like in the conda skeleton tutorial. How should I solve this problem?

This is the error I got for when running the conda build.

conda_build.exceptions.DependencyNeedsBuildingError: Unsatisfiable dependencies for platform osx-64: {'plaidml'}

and for skeleton build for plaidml package by using conda skeleton pypi plaidml-keras

Error: No source urls found for plaidml-keras

Is there a good practice of how to include the pip only package when building conda package?

merv
  • 67,214
  • 13
  • 180
  • 245
asiandudeCom
  • 441
  • 1
  • 5
  • 26
  • 2
    AFAIK, you have the right idea: try to convert the dependency to a Conda package. Unfortunately, that package looks like a rather involved build - unlikely `skeleton` will do the job. Not sure any generic advice here is going to help; instead, I'd get in touch with the developers and see if they'd support you developing a Conda version. – merv Sep 09 '20 at 19:16
  • @merv Thank you for the comment. I will try to get in touch with the developer. – asiandudeCom Sep 10 '20 at 00:21
  • This procedure could work: https://stackoverflow.com/a/29304731/8288189 – Hebo Oct 19 '21 at 13:55

1 Answers1

2

I looks around in the conda-build docs, and it looks like you can build a conda package using a wheel as a dependency. From the conda-build user guide docs:

To build a conda package from a wheel file, install the .whl file in the conda recipe's bld.bat or build.sh file.

You may download the .whl file in the source section of the conda recipe's meta.yaml file.

You may instead put the URL directly in the pip install command.

EXAMPLE: The conda recipe for TensorFlow has a pip install command in build.sh with the URL of a .whl file. The meta.yaml file does not download or list the .whl file.

Note

It is important to pip install only the one desired package. Whenever possible, install dependencies with conda and not pip.

We strongly recommend using the --no-deps option in the pip install command.

If you run pip install without the --no-deps option, pip will often install dependencies in your conda recipe and those dependencies will become part of your package. This wastes space in the package and increases the risk of file overlap, file clobbering, and broken packages.

  • Maybe worth mentioning from the docs also: "The best way is to obtain the source code for the software and build a conda package from the source and not from a wheel. This helps ensure that the new package uses other conda packages to satisfy its dependencies. The second best way is to build a conda package from the wheel file. This tells conda more about the files present than a pip install. It is also less likely than a pip install to cause errors by overwriting (or "clobbering") files. Building a conda package from the wheel file also has the advantage that any clobbering is more ..." – Sterling Oct 21 '21 at 20:26