I just made a Python package with setuptool, but I face a problem, If I preinstall everything from the Ubuntu repository the its working, but when I’m using PyPi the installation fails because on the PyPi contains only the source and it has to be compiled, so there are a lot of error source during installation. How can I install Ubuntu package during my package installation? My idea is the subprocess, is there a better way?
EDITED
The error message
Reading http://pypi.python.org/simple/enable/
Reading http://code.enthought.com/projects/enable
Best match: enable 4.2.0
Downloading http://www.enthought.com/repo/ets/enable-4.2.0.tar.gz
Processing enable-4.2.0.tar.gz
Writing /tmp/easy_install-wuMg8s/enable-4.2.0/setup.cfg
Running enable-4.2.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-wuMg8s/enable-4.2.0/egg-dist-tmp-LbjqHY
/usr/lib/python2.7/dist-packages/numpy/distutils/system_info.py:548: UserWarning: Specified path /usr/local/include/python2.7 is invalid.
warnings.warn('Specified path %s is invalid.' % d)
/usr/lib/python2.7/dist-packages/numpy/distutils/system_info.py:548: UserWarning: Specified path is invalid.
warnings.warn('Specified path %s is invalid.' % d)
Warning: distutils distribution has been initialized, it may be too late to add a library freetype2_srcWarning: distutils distribution has been initialized, it may be too late to add a library agg24_srcWarning: distutils distribution has been initialized, it may be too late to add a library kiva_srcWarning: distutils distribution has been initialized, it may be too late to add an extension _agg/usr/lib/python2.7/dist-packages/numpy/distutils/system_info.py:548: UserWarning: Specified path /usr/X11R6/lib is invalid.
warnings.warn('Specified path %s is invalid.' % d)
/usr/lib/python2.7/dist-packages/numpy/distutils/system_info.py:548: UserWarning: Specified path /usr/X11/lib is invalid.
warnings.warn('Specified path %s is invalid.' % d)
/usr/lib/python2.7/dist-packages/numpy/distutils/system_info.py:548: UserWarning: Specified path /usr/X11R6/include is invalid.
warnings.warn('Specified path %s is invalid.' % d)
/usr/lib/python2.7/dist-packages/numpy/distutils/system_info.py:548: UserWarning: Specified path /usr/X11/include is invalid.
warnings.warn('Specified path %s is invalid.' % d)
error: X11 libraries not found.
Setup script:
from setuptools import setup
setup(
name = 'SomeName',
version = '0.1',
packages = ['src'],
author = 'Some Author',
maintainer = 'Some',
maintainer_email = 'some@email.com',
description = '',
url = 'www.some.com',
install_requires = ['envisage >= 4.0',
'pyface >= 4.0',
'apptools >= 4.0',
'chaco >= 4.0',
'traits >= 4.0',
'traitsui >= 4.0',
'mysql-connector-python >= 1.0',
'pysnmp >= 4.2',
'pyasn1 >= 0.1.4',
'M2Crypto >= 0.21.1',
'netifaces >= 0.7'
],
)
Installing from apt repositories the binaries downloaded are already built with the required system libraries. If not, the apt manager ensures that any system libraries are also installed. Installing using setuptools (pip or easy_install) only fetch the python requirements; and not the build/system requirements.
In your case, the error is
error: X11 libraries not found.This means that the build headers for X11 are not available in your system. An easy way to get around this is to tell apt to only download and install the dependencies for your package (and not the package itself). This will ensure that when you use pip or easy_install, Python will find everything it needs.For example,
psycopg2is the Python library for Postgresql. To build it, you need postgresql support libraries (headers and files). These are not available from PyPi. The debian packagepython-psycopg2will properly install all the external requirements. Now if I want to install psycopg2 in a virtual environment, I first need to make sure my system has all the external requirements to build the package, so I run this command:sudo apt-get build-dep python-pyscopg2This will only install the dependencies (all supporting headers) so that I can manually install it later.
In your case, you should run
apt-get build-dep python-enable, and it will fetch everything required:Once all those libraries are installed, your pypi package will install correctly.
PyPi is only for Python packages (and Python-specific dependencies for those packages). For any external requirements; you need to specify those in your install documentation or have them available on the system so that the install process can succeed.