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.
I've looked at many questions: Q1 Q2 Q3 Q4
but adding a MANIFEST.in or adding the following lines to my setup.py
didn't change anything. And what about my manage.py? Shouldn't python files be included by default with sdist?
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).
No, all python files won't be included by default. The other important part of your
setup.pyis thepackagesandpy_moduleskeywords. 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 thatmanage.pyis alongsidesetup.py).To get your built distributions to contain data files, like your templates and static files, your
MANIFEST.inneeds to include them. You should add entries like these:The
data_fileskeyword is not needed. Simply useinclude_package_data=Trueand it will respect yourMANIFEST.in.sdist(source distribution) andbdist_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_wheeldoesn't modify how the source distribution is built.