Setup.py settings (aka setup.py --enable-feature)

I am looking for a way to include some function in a python module (extension) during the installation phase.

In practice:

I have a python library that has 2 implementations of the same function, one internal (slow) and one that depends on the external library (fast, in C).

I want this library to be optional and can be activated during compilation / installation using a flag like:

python setup.py install # (it doesn't include the fast library)
python setup.py --enable-fast install

I need to use Distutils, but all the decisions are well made!

+3
source share
2 answers

, , sqlalchemy cextensions, - C. , SA , 2 :

1) setup.py. , setuptools distutils:

try:
    from setuptools import setup, Extension, Feature
except ImportError:
    from distutils.core import setup, Extension
    Feature = None

if Feature:, extra, setup().

2) base.py: , BaseRowProxy:

try:
    from sqlalchemy.cresultproxy import BaseRowProxy
except ImportError:
    class BaseRowProxy(object):
        #....

, C- ( --with-cextensions ) C. / Python.

+2

distutils . , , distutils.command.* (, build_py install) setup ( cmdclass, , ). . (, ), , , .

+4

Source: https://habr.com/ru/post/1742692/


All Articles