Python: pip install subpackages in root directory

I have this structure:

setup.py package __init__.py sub_package ___init__.py sub_package2 __init__.py 

If I install the package through setup.py install, then it works with the evaluation (copying the entire package to the package site directory):

 site_packages package sub_package sub_package2 

But if I run the package installation package, then pip will install each subpackage as an independent package:

 site-packages package sub_package sub_package2 

How can i avoid this? I use find_packages () from setuptools to specify packages.

+4
source share
1 answer

NOTE. This answer is no longer valid, it is saved only for historical reasons, now the correct answer is to use setuptools, more information https://mail.python.org/pipermail/distutils-sig/2013-March/020126.html


First of all, I recommend abandoning setuptools:

alt text

And use distutils (which is the standard Python package distribution mechanism ) or distribute you are also distutils2 , but I think that it is not ready yet, and for the new standard here it is a guide for how to write setup.py.

For your problem, find_packages() does not exist in distutils , and you will need to add your package as follows:

 setup(name='package', version='0.0dev1', description='blalal', author='me', packages=['package', 'package.sub_package', 'package.sub_package2']) 

And if you have many packages and subpackages, you will have to create code that creates a list of packages here is an example from a Django source.

I think using distutils can help you with your problem , and I hope this can help :)

+7
source

All Articles