Newbie - django-polls tutorial packaging not picking up templates & static files

Hi, I am trying to follow the tutorial for packaging the sample polls app but the static files & templates are not being included in the tarball.

My MANIFEST.in includes the lines “recursive-include polls/static *” and “recursive-include polls/templates *”, and the setup.cfg includes the parameter “include_package_date = true”. But when I run “python setup.py sdist” it does not include the static files or templates in the tarball. What am I missing?

Thanks for any help!!

MANIFEST.in:

include LICENSE
include README.rst
recursive-include polls/static *
recursive-include polls/templates *

setup.cfg

[metadata]
name = django-polls
version = 0.1
description = A Django app to conduct web-based polls.
long_description = file: README.rst
url = https://www.example.com/
author = Harley Davis
author_email = harley@alum.mit.edu
license = BSD-3-Clause  # Example license
classifiers =
    Environment :: Web Environment
    Framework :: Django
    Framework :: Django :: 4.2  
    Intended Audience :: Developers
    License :: OSI Approved :: BSD License
    Operating System :: OS Independent
    Programming Language :: Python
    Programming Language :: Python :: 3
    Programming Language :: Python :: 3 :: Only
    Programming Language :: Python :: 3.8
    Programming Language :: Python :: 3.9
    Topic :: Internet :: WWW/HTTP
    Topic :: Internet :: WWW/HTTP :: Dynamic Content

[options]
include_package_data = true
packages = find:
python_requires = >=3.8
install_requires =
    Django >= 4.2  # Replace "X.Y" as appropriate

The tree structure of the source directory

django-polls
├── LICENSE
├── MANIFTEST.in
├── README.rst
├── dist
│   └── django-polls-0.1.tar.gz
├── django_polls.egg-info
│   ├── PKG-INFO
│   ├── SOURCES.txt
│   ├── dependency_links.txt
│   ├── requires.txt
│   └── top_level.txt
├── polls
│   ├── __init__.py
│   ├── __pycache__
│   │   ├── __init__.cpython-311.pyc
│   │   ├── __init__.cpython-39.pyc
│   │   ├── admin.cpython-311.pyc
│   │   ├── admin.cpython-39.pyc
│   │   ├── apps.cpython-311.pyc
│   │   ├── apps.cpython-39.pyc
│   │   ├── models.cpython-311.pyc
│   │   ├── models.cpython-39.pyc
│   │   ├── tests.cpython-39.pyc
│   │   ├── urls.cpython-311.pyc
│   │   ├── urls.cpython-39.pyc
│   │   ├── views.cpython-311.pyc
│   │   └── views.cpython-39.pyc
│   ├── admin.py
│   ├── apps.py
│   ├── django_polls.egg-info
│   │   ├── PKG-INFO
│   │   ├── SOURCES.txt
│   │   ├── dependency_links.txt
│   │   ├── requires.txt
│   │   └── top_level.txt
│   ├── migrations
│   │   ├── 0001_initial.py
│   │   ├── __init__.py
│   │   └── __pycache__
│   │       ├── 0001_initial.cpython-311.pyc
│   │       ├── 0001_initial.cpython-39.pyc
│   │       ├── __init__.cpython-311.pyc
│   │       └── __init__.cpython-39.pyc
│   ├── models.py
│   ├── static
│   │   └── polls
│   │       ├── images
│   │       │   └── background.png
│   │       └── style.css
│   ├── templates
│   │   └── polls
│   │       ├── detail.html
│   │       ├── index.html
│   │       └── results.html
│   ├── tests.py
│   ├── urls.py
│   └── views.py
├── pyproject.toml
├── setup.cfg
└── setup.py

13 directories, 48 files

The output of running the setup command:

(conda_django) harley@harleys-macbook-pro django-polls % python setup.py sdist           
running sdist
running egg_info
writing django_polls.egg-info/PKG-INFO
writing dependency_links to django_polls.egg-info/dependency_links.txt
writing requirements to django_polls.egg-info/requires.txt
writing top-level names to django_polls.egg-info/top_level.txt
reading manifest file 'django_polls.egg-info/SOURCES.txt'
adding license file 'LICENSE'
writing manifest file 'django_polls.egg-info/SOURCES.txt'
running check
creating django-polls-0.1
creating django-polls-0.1/django_polls.egg-info
creating django-polls-0.1/polls
creating django-polls-0.1/polls/migrations
copying files to django-polls-0.1...
copying LICENSE -> django-polls-0.1
copying README.rst -> django-polls-0.1
copying pyproject.toml -> django-polls-0.1
copying setup.cfg -> django-polls-0.1
copying setup.py -> django-polls-0.1
copying django_polls.egg-info/PKG-INFO -> django-polls-0.1/django_polls.egg-info
copying django_polls.egg-info/SOURCES.txt -> django-polls-0.1/django_polls.egg-info
copying django_polls.egg-info/dependency_links.txt -> django-polls-0.1/django_polls.egg-info
copying django_polls.egg-info/requires.txt -> django-polls-0.1/django_polls.egg-info
copying django_polls.egg-info/top_level.txt -> django-polls-0.1/django_polls.egg-info
copying polls/__init__.py -> django-polls-0.1/polls
copying polls/admin.py -> django-polls-0.1/polls
copying polls/apps.py -> django-polls-0.1/polls
copying polls/models.py -> django-polls-0.1/polls
copying polls/tests.py -> django-polls-0.1/polls
copying polls/urls.py -> django-polls-0.1/polls
copying polls/views.py -> django-polls-0.1/polls
copying polls/migrations/0001_initial.py -> django-polls-0.1/polls/migrations
copying polls/migrations/__init__.py -> django-polls-0.1/polls/migrations
Writing django-polls-0.1/setup.cfg
Creating tar archive
removing 'django-polls-0.1' (and everything under it)

Please post your complete MANAFEST.in and setup.cfg files here.

When posting code, config files, etc, surround each file with lines of three backtick - ` characters. This means you’ll have a line of ```, then the file contents, then another line of ```.

Also, copy/paste the contents of the file, please don’t retype it. (That tends to introduce errors.)

Thanks, just edited my initial post with your suggestion.

Did you also create the LICENSE and README.rst files as described?

Please post the complete output from this command.

Hi, I edited the initial post to include the tree structure of the directory and the output of the setup command. Thanks!

I’m currently unable to recreate the behavior you’re identifying here. When I recreate these steps in my test environment, they work as expected.

What version of Python are you using? What versions of pip and setuptools are installed?

I just noticed - this is what you show in your directory structure:

That’s not the right name for this file.

1 Like

Thanks, I feel properly ashamed and abashed!