I have a setup.py:
from setuptools import setup setup( ... packages=['mypackage'], test_suite='mypackage.tests', ... )
python setup.py sdist
creates a file that includes only the source modules from top-level mypackage and not mypackage.tests nor any other submodules.
What am I doing wrong?
Using python 2.7
the "sdist" command is for creating a "source" distribution of a package. Usually, one would combine this command with the "upload" command to distribute the package through Pypi (for example).
The setup.py file may be the most significant file that should be placed at the root of the Python project directory. It primarily serves two purposes: It includes choices and metadata about the program, such as the package name, version, author, license, minimal dependencies, entry points, data files, and so on.
Use the find_packages()
function:
from setuptools import setup, find_packages setup( # ... packages=find_packages(), )
The function will search for python packages (directories with a __init__.py
file) and return these as a properly formatted list. It'll start in the same dir as the setup.py script but can be given an explicit starting directory instead, as well as exclusion patterns if you need it to skip some things.
For people using pure distutils instead of setuptools: you have to pass the list of all packages and subpackages (but not all submodules, they are detected) in the packages parameter.
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