setuptools sdist ignore data_files

点点圈 提交于 2019-12-11 06:46:15

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/38117149/setuptools-sdist-ignore-data-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!