2
votes

I am trying to build a package using the "conda build fibtestpackage" command.

The "fibtestpackage" is built using Cython, hence in the .sh file I have the command:

python setup.py build_ext --inplace

Even though the Build ends successfully, and the output is as expected:


Fetching packages ... fibtestpackage-1.0.0 100% |################################| Time: 0:00:00 3.03 MB/s

Extracting packages ... [ COMPLETE ] |##################################################| 100%

Linking packages ... [ COMPLETE ] |##################################################| 100%


the one test I have in the YAML file fails. The only test I have looks like this:


test:
  # Python imports
  imports:
      - fibtestpackage
      #- numpy
      #- samplers

Hence, its an import error,

ImportError: No module named fibtestpackage

My first guess for why there is an importerror is because the .SO, .C, and .PYX files generated by the build (and the other files of the library) are NOT being place into the anaconda/lib/python2.7/site-packages/ folder where the other modules are located. Do I need to specify this in the shell file or should this be covered by the "python setup.py build_ext --inplace" command?

My second guess is that there are two different versions of conda (after updating) in the distribution,

1) Python 2.7.8 |Anaconda 2.1.0 (64-bit)| (default, Aug 21 2014, 18:22:21)

2) Python 2.7.8 |Continuum Analytics, Inc.| (default, Aug 21 2014, 18:22:21)

Could this be causing the issue? Perhaps the build environment is installing libraries in the wrong one?

Thank you in advance for your help!

1
After some research, I found out in the .sh file if I move (using cp command) the fibstestpackage.so file generated by the build to the ~/anaconda/lib/python2.7/site-packages/ folder, it seems to work. Is this the best solution??? - G01

1 Answers

2
votes

Conda build creates a build conda environment, called _build (generally in ~/anaconda/envs/_build), which is where you should install everything in. For Python, generally doing python setup.py install is good enough if you include Python as a build dependency in the meta.yaml because the python will be the one installed in the _build environment and it will install there.

At the end of the build, conda build wraps up all the new files in the build environment and creates a conda package out of them. If there is a test phase, it deletes the _build environment and creates a test environment, called _test, and installs and runs the package there.

To debug this problem, try running the Python in ~/anaconda/envs/_test.

In your case, the issue is likely that python setup.py build_ext --inplace does not actually install the files, it just builds them. Check at the end of the build to see how many files it says there are. If there are 0, then this is the issue.