2

According to docs https://packaging.python.org/en/latest/distributing/#data-files

setuptools will honor data_files configed in setup.py. But i can't make it work. This is my setup.py:

setup(
    name='booking_order',
    version=version,
    packages=find_packages(),
    package_data={
        'booking_order': ['fake_backends/static/*',
                          'scripts/*',
                          '*.sample'],
    },
    data_files=[
        ('/etc/booking', ['etc/booking.conf'])
    ],

This is the project's file tree:

.
├── booking_order
│   ├── __init__.py
│   ├── tests
│   │   ├── __init__.py
├── etc
│   ├── booking.conf
├── README.md
├── setup.py

The behavior is, if i run python setup.py install, file etc/booking.conf will got installed to /etc/booking. But if i first python setup.py sdist upload, then pip install booking_order, there will be an error "error: can't copy 'etc/booking.conf': doesn't exist or not a regular file". I checked python setup.py sdist doesn't include files in etc at all.

EDIT:

it seems this is the answer: https://github.com/pypa/setuptools/issues/521

apporc
  • 870
  • 3
  • 11
  • 23

1 Answers1

0

Answer it myself.

According to pypa, and non-package-data-files。"Setuptools doesn't support installing data files to some arbitrary location on a user’s machine; this is a feature, not a bug."

If one need to install files to locations like /etc, /usr/share, eg, then he/she may use data_files flag from distutils, which feature is not totally cleaned up from setuptools. "Not totally cleaned up" means you need to add those files to MANIFEST.in manually, which is different as in distutils.

Of course, it will be better if one can manage these configuration files with rpm or deb package system. For me it's just a temporary solution to use pip here.

apporc
  • 870
  • 3
  • 11
  • 23