I am trying to deliver a Django app via pip (stored on Pypi). The problem is that when I install the app with pip, it does not contain the static folder inside of the main specified package.
Here is what I have:
├── LICENSE.txt
├── MANIFEST.in
├── README.rst
├── setup.cfg
├── setup.py
└── zxcvbn_password
├── fields.py
├── __init__.py
├── static
│ └── zxcvbn_password
│ └── js
│ ├── password_strength.js
│ ├── zxcvbn-async.js
│ └── zxcvbn.js
├── validators.py
└── widgets.py
What I do is the following:
python setup.py register -r pypi
python setup.py sdist upload -r pypi
The tar archive is correctly created (it contains the static folder), and when I download this same archive from PyPi, it also contains the static folder. But installing it with pip just gives me the following in zxcvbn_password
inside my site-packages:
└── zxcvbn_password
├── fields.py
├── __init__.py
├── validators.py
└── widgets.py
This is how I write my setup.py:
from distutils.core import setup
setup(
name='django-zxcvbn-password',
packages=['zxcvbn_password'],
include_package_data=True,
url='https://github.com/Pawamoy/django-zxcvbn-password',
# and other data ...
)
And my MANIFEST.in:
include LICENSE.txt
include README.rst
recursive-include zxcvbn_password/static *
Am I doing something wrong?
Why the static folder is not installed when pip uses setup.py install
?
I added the line of setup.py importing the setup function from distutils.
I get this warning when running python setup.py sdist upload -r pypitest
:
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'include_package_data'
# MANIFEST.in
include LICENSE.txt
include README.rst
# recursive-include zxcvbn_password/static *
and
# setup.py
from distutils.core import setup
setup(
name='django-zxcvbn-password',
packages=['zxcvbn_password'],
package_data={'': ['static/zxcvbn_password/js/*.js']},
# include_package_data=True,
url='https://github.com/Pawamoy/django-zxcvbn-password',
# and other data ...
)
I commented out the recursive-include line from MANIFEST.in and the include_package_data=True from setup.py: apparently they are not needed if you specify the package_data={...} line in setup.py.
# MANIFEST.in
include LICENSE.txt
include README.rst
recursive-include zxcvbn_password/static *
and
# setup.py
from setuptools import setup
setup(
name='django-zxcvbn-password',
packages=['zxcvbn_password'],
include_package_data=True,
url='https://github.com/Pawamoy/django-zxcvbn-password',
# and other data ...
)
The only line that has changed is from setuptools import setup
.
My problem was trully coming from the way I was importing the setup function. Reading this: Differences between distribute, distutils, setuptools and distutils2?, I understood that Setuptools has more functionality than Distutils.