I've created package with distutils including package data.
When i look in tar.gz of my package I see expected files, BUT after package installation (by pip or by 'python setup.py install') there is no any package data. Only python scripts included. My setup.py
is:
# py3.3
#from packaging.core import setup
# py3.2
from distutils.core import setup
setup(
name = 'mypkg',
version = '0.7dev',
author = 'Projekt Alef',
author_email = '[email protected]',
packages = [
'my_pkg',
'my_pkg/tests',
'my_pkg/plugins',
],
#scritps=['bin/setup.sh',],
)
Files which are to be used by your installed library (e.g. data files to support a particular computation method) should usually be placed inside of the Python module directory itself. E.g. in our case, a data file might be at funniest/funniest/data. json .
What is "package data"? Broadly, package data is any files that you want to include with your Python package that aren't Python source files. An example is a TOML default configuration file that you want to be able to produce for users.
package_data. By default, include_package_data considers all non .py files found inside the package directory ( src/mypkg in this case) as data files, and includes those that satisfy (at least) one of the above two conditions into the source distribution, and consequently in the installation of your package.
Place the files that you want to include in the package directory (in our case, the data has to reside in the roman/ directory). Add the field include_package_data=True in setup.py. Add the field package_data={'': [... patterns for files you want to include, relative to package dir...]} in setup.py .
Package data to be installed should be included as a package_data={}
dictionary passed to the setup()
function. Each dictionary gives the module (package) to be installed and a list of patterns to find data files to be installed from/with it, such as:
package_data = {
'exceptional_middleware': [ 'templates/http_responses/*.html' ],
}
Additionally, you may prefer not to install your tests (just drop pkg/tests
from the packages
list).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With