最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - migrating from distutils to setup tools - Stack Overflow

programmeradmin2浏览0评论

I am migrating a large library of python cpp extensions form swig+distutils to swig+setuptols. I am using swig cpp example as the illustration. The original setup.py file:

from distutils.core import setup, Extension
from distutilsmand.build_ext import build_ext

example_module = Extension(
    name='_example',
    sources=['example.i', 'example.cpp'],
    swig_opts=['-python', '-py3', '-c++', '-cppext', 'cpp']
)

setup(
    name='example',
    version='1.0',
    ext_modules=[example_module],
)

And I building it as

   /usr/bin/python3 setup.py build_ext --swig=${SWIG}
   /usr/bin/python3 setup.py install --prefix ${PREFIX} --install-lib ${LIBDIR} --no-compile --skip-build

I replaced distutils.core -> setuptools and distutilsmand -> setuptoolsmand in my setup.py file. I added PYTHONPATH=${LIBDIR} to my install command.

I got everything built. And I can run my example. However, instead of .so file in the library _example.cpython-38-x86_64-linux-gnu.so, I got an 'egg' file, site.py and easy-install.pth:

easy-install.pth
example-1.0-py3.8-linux-x86_64.egg
site.py

What is next? Should I simply use .egg files instead of .so files? I tried to use .egg files for a more complicated example and it did not work.

I unzipped .egg file, it worked for both the simple example and for more a complicated one. But I feel that simply unzipping these files as a part of the build process is not the right thing to do.

Update: I added --old-and-unmanageable option and I got .so file installed instead of .egg one.

发布评论

评论列表(0)

  1. 暂无评论