Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python setup.py sdist only including .py source from top level module

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

like image 300
user1561108 Avatar asked Jan 28 '13 00:01

user1561108


People also ask

What does python setup py Sdist do?

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).

What should setup py contain?

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.


2 Answers

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.

like image 110
Martijn Pieters Avatar answered Sep 22 '22 00:09

Martijn Pieters


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.

like image 31
merwok Avatar answered Sep 24 '22 00:09

merwok