Note
Use cookiecutter-pylibrary to avoid all the pain.
Just a short list of packaging blunders ...
Forgetting to clean the build dir *
why: | distutils and setuptools will skip things if you have stuff in the build dir, even if you have changed options in your setup.py. |
---|---|
fix: | Integrate a rm -rf build/ in your build pipeline. Better (clean everything): rm -rf dist build */*.egg-info *.egg-info |
Forgetting to specify package data *
why: | Distutils and Setuptools don't include your non-python files by default. |
---|---|
fix: | Create a MANIFEST.in and use include_package_data=True. Don't use package_data as it will override your manifest, and it's a less flexible approach anyway. [4] Make sure your data files are inside packages (they are called package data after all). An example of how to use data files. |
Fine grained MANIFEST.in *
Listing few file types in MANIFEST.in [4], then adding some webfonts or templates - only to find out the release you published on PyPI doesn't include them.
why: | You duplicated information you already have in the filesystem [1]. |
---|---|
fix: | Just recursive-include or graft the whole dir. Separate sources from build and temporary files (e.g.: use different directories). |
Using package_data, or worse: fine grained package_data *
Listing few file types in package_data [6], then adding some webfonts - only to find out the release you published on PyPI doesn't include them.
why: | You duplicated information you already have in the filesystem [1]. You have better options. |
---|---|
fix: | Use MANIFEST.in and include_package_data=True. See forgetting-package-data. |
Listing excludes/prunes before includes/grafts *
Your excludes/prunes would get overriden if there are includes/grafts that match the same files later.
why: | Last rule wins [4]. |
---|---|
fix: | Use correct rule ordering. Excludes have more weight, put them last in MANIFEST.in. |
Hardcoding packages list in setup.py *
why: | You duplicated information you already have in the filesystem [1]. |
---|---|
fix: | Use setuptools.find_packages. Or, if you want everything to be static, have good testing [3]. |
Hardcoding py_modules list in setup.py *
why: | You duplicated information you already have in the filesystem [1]. |
---|---|
fix: | Discover the modules, e.g.:
|