问题
I have a python package implemented in C++ that I am distributing using setuptools. My C++ code depends on some shared objects, specifically the boost.python library. How should I distribute these shared objects? At the moment I ask the package user to install the boost C++ libraries separately but I would rather bundle everything in one setuptools distribution to make it easier for him/her. At the moment they must set up the boost libraries and their LD_LIBRARY_PATH
environment variable in addition to installing my package.
回答1:
Declaring dependencies
There is an option in setup.py
called install_requires = [""]
:
Ex :
setup(
name='django-cherrypy',
version='0.1',
packages=packages,
license='LICENSE',
description='cherrypy, running under django',
long_description=open('README.md').read(),
author='Calvin Cheng',
author_email='calvin@calvinx.com',
install_requires=['cherrypy-wsgiserver'],
extra_requires=['newrelic'],
url='https://github.com/od-eon/django-cherrypy',
)
This setup ask for chrerryPy WSGI server library.
Bundle Everything
Everything is explained here : http://pythonhosted.org/distribute/setuptools.html#declaring-dependencies
Depedencies in PiPy :
- When your project is installed, either by using EasyInstall, setup.py install, or setup.py develop, all of the dependencies not already installed will be located (via PyPI), downloaded, built (if necessary), and installed.
- Any scripts in your project will be installed with wrappers that verify the availability of the specified dependencies at runtime, and ensure that the correct versions are added to sys.path (e.g. if multiple versions have been installed).
- Python Egg distributions will include a metadata file listing the dependencies
Dependencies that aren’t in PyPI
If your project depends on packages that aren’t registered in PyPI, you may still be able to depend on them, as long as they are available for download as:
- an egg, in the standard distutils sdist format,
- a single .py file,
- or a VCS repository (Subversion, Mercurial, or Git). You just need to add some URLs to the dependency_links argument to setup().
来源:https://stackoverflow.com/questions/17484752/how-to-package-shared-objects-that-python-modules-depend-on