Package Organization with Cython

I have a package that requires Cython to create its extensions, and I'm trying to configure a file setup.pyto simplify the installation.

Plain

pip install git+git://<pkg-repo> 

gives an error message

$ pip install git+https://<pkg-repo>
Downloading/unpacking git+https://<pkg-repo>
  Cloning https://<pkg-repo> to /tmp/pip-nFKHOM-build
  Running setup.py (path:/tmp/pip-nFKHOM-build/setup.py) egg_info for package from git+https://<pkg-repo>
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/pip-nFKHOM-build/setup.py", line 2, in <module>
        from Cython.Build import cythonize
    ImportError: No module named Cython.Build
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/tmp/pip-nFKHOM-build/setup.py", line 2, in <module>

    from Cython.Build import cythonize

ImportError: No module named Cython.Build

due to import of Cython before installing Cython. This leads to a multi-step installation process:

pip install <deps> cython
pip install git+git://<pkg-repo>

which sucks. Relevant sections setup.py:

from setuptools import setup, find_packages
from Cython.Build import cythonize

setup(
    install_requires=[
        ...
        'cython>=0.19.1'
        ...
    ],
    ext_modules=cythonize([
        ...
        "pkg/io/const.pyx",
        ...
    ])
)

How can I change setup.pyto still cythonize ext_modules, relying on install_requiresto get Cython first?

+4
source share
1 answer

18.0, setuptools Cython: cython setup_requires Extension, setuptools Cython - cythonize() setup.py.

setup.py :

from setuptools import setup, Extension

setup(
    setup_requires=[
        ...
        'setuptools>=18.0',
        'cython>=0.19.1',
        ...
    ],
    ext_modules=Extension([
        ...
        "pkg/io/const.pyx",
        ...
    ])
)

, SO: fooobar.com/questions/386037/....

0

All Articles