Installing data files into site-packages with setup.py

喜你入骨 提交于 2019-12-21 03:39:05

问题


I have a Python package with a standard setup.py installer but I cannot for the life of me get it to install some pre-defined configuration files into site-packages somewhere... my setup() function is called like this:

setup(
  name='Hydrant',
  version=version,
  description=long_description,
  author='Scott Frazer',
  author_email='scott.d.frazer@gmail.com',
  packages=['hydrant'],
  package_data={'hydrant': ['sql/*.sql', 'hydrant.conf', 'hydrant.deploy']},
  data_files=[('config', ['hydrant/hydrant.conf'])],
  install_requires=[
    "xtermcolor>=1.0.3",
    "pyyaml",
    "pymysql",
    "jprops"
  ],
  entry_points={
    'console_scripts': [
      'hydrant = hydrant.Main:Cli'
    ]
  },
  test_suite='hydrant.test',
  license = "MIT",
)

I was experimenting around with package_data and data_files but they simply don't seem to DO anything. I'm installing into a virtual environment with the command line:

$ python setup.py install

Any insight would be greatly appreciated!


回答1:


Try adding a MANIFEST.in file to your module. Althought AFAIK it's only used to add data to generated packages (eggs or tar.gz distribution files)
Look at this StackOverflow related question/answer.

Others programmers made it work switching to distutils, but i wouldn't recommend it since it's deprecated by distribute.
Look at this other StackOverflow related question/answer



来源:https://stackoverflow.com/questions/9689816/installing-data-files-into-site-packages-with-setup-py

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