Reputation: 5803
I have the following in setup.py:
from setuptools import setup
# ...
setup(
name='xml-boiler',
version='0.0.1',
url='https://github.com/vporton/xml-boiler',
license='AGPLv3',
author='Victor Porton',
author_email='[email protected]',
description='Automatically transform between XML namespaces',
packages=find_packages(),
package_data={'': ['*.ttl', '*.xml']},
scripts=['bin/boiler'],
data_files = [
('/etc/xmlboiler', ['etc/config-cli.ttl'])
],
test_suite="xmlboiler.tests",
cmdclass={'build_py': MyBuild},
)
But after I run python setup.py build
, the build directory does not contain any *.xml
or *.ttl
files.
What is my error?
I also want to distribute all files from xmlboiler/core/data/assets/
and
xmlboiler/core/data/assets/
.
I don't understand how it works:
package_data={'': ['*/.xml', '*/.ttl', '*/.net', 'data/assets/*', 'data/scripts/*.xslt', 'xmlboiler/doc/*.html', 'xmlboiler/doc/*.css']},
included xmlboiler/core/data/scripts/section.xslt
but not xmlboiler/tests/core/data/xml/simple.xml
. Why?!
Upvotes: 3
Views: 194
Reputation: 66201
package_data
is a mapping of package names to files or file globs. This means that
package_data = {'', ['*.xml', '*.ttl']}
will include every file ending with .xml
or .ttl
located in any package directory, for example xmlboiler/file.xml
, xmlboiler/core/file.ttl
etc. It will, however, not include file xmlboiler/core/data/interpreters.ttl
because it is located in data
which is not a package dir (not containing an __init__.py
file). To include that, you should use the correct file path:
package_data = {'xmlboiler.core', ['data/interpreters.ttl']}
To include every .ttl
file under xmlboiler/core/data
:
package_data = {'xmlboiler.core', ['data/*.ttl', 'data/**/*.ttl']}
This will include every .ttl
file in data
directory (glob data/*.ttl
) and every .ttl
file in every subdirectory of data
(glob data/**/*.ttl
).
To include every .ttl
and .xml
file in every package:
package_data = {'', ['*.xml', '**/*.xml', '*.ttl', '**/*.ttl']}
I also want to distribute all files from
xmlboiler/core/data/assets/
Same approach for data/assets
, but omit the file extension in globs:
package_data={
'xmlboiler.core': ['data/assets/*', 'data/assets/**/*'],
}
Upvotes: 1