Niourf
Niourf

Reputation: 460

Build conda package upon installation

So I have published a conda package (link).

This package contains .c extensions (coming from cython code), which need to be compiled when the package is installed. My problem is that none of the extensions are compiled when running the install command

conda install -c nicolashug scikit-surprise 

Compiling the extensions can be done by simply running

python setup.py install

which is exactly what pip does. The package is on PyPI and works fine.

As far as I understand, this setup.py command is only called when I build the conda package using conda build: the meta.yaml file (created with conda skeleton) contains

build:
    script: python setup.py install  --single-version-externally-managed--record=record.txt

But I need this to be done when the package is installed, not built.

Reading the conda docs, it looks like the install process is merely a matter of copying files:

Installing the files of a conda package into an environment can be thought of as changing the directory to an environment, and then downloading and extracting the .zip file and its dependencies

That would mean I would have to build the package for all platforms and architectures, and then upload them to conda... Which is impossible to me.

So, is there a way to build the package when it is installed, just like pip does?

Upvotes: 1

Views: 517

Answers (1)

darthbith
darthbith

Reputation: 19675

As far as I know, there is no way to have the compilation happen on the user's machine when installing a conda package. Indeed, the whole idea of a conda package is that you do the compiling so that I don't have to on my machine, and all that's distributed is the compiled library. On Windows in particular, setting up compilers so they work properly (with Python) is a big big PITA, which is one of the biggest reasons for conda (and also wheels installed by pip).

If you don't have access to a particular OS directly, you can use Continuous Integration (CI) services, such as Appveyor (Windows), Travis CI (Linux/macOS), or CircleCI (Linux/macOS) to build packages and upload them to Anaconda cloud (or to PyPI for that matter). These services integrate directly with GitHub and other code-sharing services, and are generally free for FOSS projects. That way, you can build packages on each commit, on each tag, or some other variation that you desire.

In the end, you may save more time by setting up these services, because you won't have to provide compiler support for users who can't install a source package from PyPI.

Upvotes: 3

Related Questions