When I run
python setup.py sdist
in my project directory and check the contents with
tar --list -f .\dist\my_project_name-1.0.tar.gz I expected to see one important python file (
manage.py) and a couple of directories such as
templates which contains .html files, and
static containing .css files. However, these files are all missing from the tar archive.
but adding a
MANIFEST.in or adding the following lines to my
didn’t change anything. And what about my
manage.py? Shouldn’t python files be included by default with
include_package_data=True, data_files=[('templates','my_app/templates/my_app/*.html']), ('static', ['my_app/static/my_app/static/css/*.css'])]
Also, I get the same exact result with
python setup.py sdist bdist_wheel (although I’m not sure what’s the difference with the two commands).
what about my manage.py? Shouldn’t python files be included by default with sdist?
No, all python files won’t be included by default. The other important part of your
setup.py is the
py_modules keywords. You must specify all packages and subpackages and modules you want to include.
In general, Django apps aren’t distributed with the manage.py file, but if you want to include it, you can add
py_modules=['manage'] to the setup keywords (assuming that
manage.py is alongside
To get your built distributions to contain data files, like your templates and static files, your
MANIFEST.in needs to include them. You should add entries like these:
recursive-include my_app/templates * recursive-include my_app/static *
data_files keyword is not needed. Simply use
include_package_data=True and it will respect your
Also, I get the same exact result with python setup.py sdist bdist_wheel
sdist (source distribution) and
bdist_wheel (wheel binary distribution) are just separate distribution formats.
So, compared to the first command, you’re just telling it to build the source distribution AND a wheel. Adding
bdist_wheel doesn’t modify how the source distribution is built.
Answered By – sytech