I have such structure:
setup.py
package
__init__.py
sub_package
___init__.py
sub_package2
__init__.py
If I install package via setup.py install, then it works as appreciated (by copying whole package to site-packages dir):
site_packages
package
sub_package
sub_package2
But if I run pip install package, then pip installs each sub-package as independent package:
site-packages
package
sub_package
sub_package2
How can I avoid this? I use find_packages() from setuptools to specify packages.
Locally installed Python and all packages will be installed under a directory similar to ~/. local/bin/ for a Unix-based system, or \Users\Username\AppData\Local\Programs\ for Windows.
By default, packages are installed to the running Python installation's site-packages directory. site-packages is by default part of the python search path and is the target directory of manually built python packages.
The Pip, Pipenv, Anaconda Navigator, and Conda Package Managers can all be used to list installed Python packages. You can also use the ActiveState Platform's command line interface (CLI), the State Tool to list all installed packages using a simple “state packages” command.
NOTE: This answer is not valid anymore, it's only kept for historical reasons, the right answer right now is to use setuptools, more info https://mail.python.org/pipermail/distutils-sig/2013-March/020126.html
First of all i will recommend to drop setuptools :
And use either distutils (which is the standard mechanism to distribute Python packages) or distribute you have also distutils2 but i think is not ready yet, and for the new standard here is a guide line to how to write a setup.py.
For your problem the find_packages()
don't exist in the distutils and you will have to add your package like this:
setup(name='package',
version='0.0dev1',
description='blalal',
author='me',
packages=['package', 'package.sub_package', 'package.sub_package2'])
And if you have a lot of package and sub packages you will have to make some code that create the list of packages here is an example from Django source.
I think using distutils can help you with your problem,and i hope this can help :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With