【问题标题】:Install static nested directories to prefix (or at least include in setuptools package)将静态嵌套目录安装到前缀(或至少包含在 setuptools 包中)
【发布时间】:2015-03-20 17:37:39
【问题描述】:

我正在尝试让我的setup.py 将目录安装到/usr/share(或使用不同的前缀,或者至少让我的脚本从 EGG 文件中复制它)。

我的项目的目录结构是这样的:

- setup.py
- MANIFEST.in
- myproj
  - __init__.py
  - sompekg
     - __init__.py
- data
  - dirA
     - dirB
       - somefile
  - somefile

我尝试将“数据”添加到 MANIFEST.in:

recursive-include data *
recursive-include themer *

setup.py:

include_package_data=True,

但是因为它是一个嵌套的目录结构并且那里没有 python 文件,所以它不会包含它们。目前“数据”目录已包含在 EGG 中,但没有任何子目录。

【问题讨论】:

    标签: installation setuptools distutils


    【解决方案1】:

    好的,我最终编写了自己的 install 替换,它调用常规的 setuptools.commands.install,然后我的文件复制。以下是我setup.py的相关部分:

    from setuptools.command.install import install
    class new_install(install):
      def run(self):
         install.run(self) # invoke original install
         self.mkpath('/usr/share/themer')
         self.copy_tree('data/default', '/usr/share/themer/default')
         self.mkpath('/usr/share/fish/completions')
         self.copy_file('data/fish/themer.fish', '/usr/share/fish/completions/')
    
    setup(
     #... whatever else you got here
     cmdclass=dict(install=new_install)
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-08-04
      • 2014-04-28
      • 2012-12-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多