1

I am trying to create a conda package to distribute a python tool. Part of the tool is cythonized, and it works perfectly using python setup.py install. I create the tar properly but when I try to install it, the package does not contain the .py files that links the python imports and the .so files. So when I try to import that packages I get a module not found.

The only think I have found around cython and conda is to introduce cython requirement in the build/run section in the meta.yaml, but I don't know why those .py files are not included.

This is my meta.yaml

package:
  name: project
  version: 1.0.0
source:
  path: /home/user/project
requirements:
  build:
    - python >=2.7
    - jinja2
    - numpy
    - scipy
    - matplotlib
    - pysam
    - setuptools
    - h5py
    - cython
  run:
    - python >=2.7
    - jinja2
    - numpy
    - scipy
    - matplotlib
    - pysam >=0.8 
    - setuptools
    - h5py
    - cython
build:
  preserve_egg_dir: True
  entry_points:
    - exec_file = project.run_exec:main
about:
  license: GPL3
  summary: "PROJECT"

my setup.py file looks like

from setuptools import setup, find_packages
from distutils.core import Extension
from Cython.Build import cythonize


extensions = [Extension('project.src.norm', ['project/src/norm.pyx'])]

setup(
    name="PROJECT",
    packages=find_packages(),
    version="1.0.0",
    description="PROJECT",
    author='Lab',
    author_email='email',
    url='http://',
    license='LICENSE.txt',
    include_package_data=True,
    entry_points={'console_scripts': ['exec_file = project.run_exec:main']},
    zip_safe=False,
    ext_modules=cythonize(extensions),
    classifiers=[
        'Development Status :: 4 - Beta',
        'Environment :: Console',
        'Intended Audience :: Bioinformaticians',
        'License :: OSI Approved :: BSD License',
        'Operating System :: MacOS',
        'Operating System :: Microsoft :: Windows',
        'Operating System :: POSIX',
        'Programming Language :: Python :: 2.7',
    ]
)

The directory structures is

project/
    setup.py
    __init__.py
    MANIFEST.in
    requirements.txt
    README.md
    info/
        meta.yaml
        build.sh
        bld.bat
    project/
        src/
           norm.pyx
        run_exec.py
    subproject/
        <etc...>

EDITED: Today I tried using python setup.py bdist_conda but the behavior is the same, or it is a conda issue or it is an specific problem on my configuration.
if that is the case I guess is is setup.py....

merv
  • 67,214
  • 13
  • 180
  • 245
jvaquero
  • 75
  • 8
  • 1
    I think the missing important information is your directory structure and your setup.py file. – DavidW May 01 '17 at 17:43
  • I edited the post adding the info you said. Thanks for the help – jvaquero May 03 '17 at 21:06
  • `- setuptools - h5py - cython` are probably not required to _run_ the package – ivan_pozdeev May 04 '17 at 16:09
  • h5py is required, is imported in the code. I am not sure If I need setuptools or cython in the run part or only in the build, but I don't think that is what makes conda fail – jvaquero May 04 '17 at 16:33
  • What specifically is not being included? I assumed it's `run_exec.py`, the only .py file that you specifically mentioned, but based on your feedback, this doesn't seem so. – ivan_pozdeev May 04 '17 at 17:38
  • If you have a `setup.py`, you should probably be able to [generate `meta.yaml` from it](http://conda-test.pydata.org/docs/build_tutorials/pkgs.html). – ivan_pozdeev May 04 '17 at 18:30
  • When you cythonize and compile, cython creates a wrapper py file, in this ase norm.py. That file is just an __bootstrap__ method that connects the import to the binary object file (.so). This wrapper file is the one is missing, I think that file is created at install not in build, so conda don't include it in the tgz file. – jvaquero May 04 '17 at 22:41

1 Answers1

1

I did find the problem was in my environment. I had defined a PYTHONPATH variable that was making conda generate incorrectly the package. Instead of going to the build package, it was importing my source code directly. Removing the PYTHONPATH the problem is solved.

jvaquero
  • 75
  • 8