【问题标题】:python setup.py build ignoring some filespython setup.py build忽略一些文件
【发布时间】:2016-07-14 21:37:59
【问题描述】:

我的 Python 包具有以下结构:

$ tree -d | grep -v "__pycache__"
.
├── src
│   ├── poliastro
│   │   ├── iod
│   │   ├── tests
│   │   └── twobody
│   │       └── tests
├── setup.py
└── MANIFEST.in

47 directories

执行python setup.py build后的Buf,最里面的test目录没有被复制:

$ tree -d | grep -v "__pycache__"
.
├── build
│   ├── lib
│   │   └── poliastro
│   │       ├── iod
│   │       ├── tests
│   │       └── twobody

相反,python setup.py sdist 工作正常。

到目前为止,我已经使用MANIFEST.in 规则在 sdist 中包含或排除某些文件、模式和目录。有没有办法控制build 目录的内容?为什么有些测试可以到达而有些则没有?

参考原始问题和源代码:https://github.com/poliastro/poliastro/issues/129

【问题讨论】:

  • 可以分享MANIFEST.in的内容吗?

标签: python setuptools packaging


【解决方案1】:

您的setup() 丢失了include_package_data=True。看看我做的这个公关https://github.com/poliastro/poliastro/pull/139

讨论:没有这个,非python包文件(例如你列出的不在“包中”的测试py文件)默认不包括在内,即使它们在技术上是其他包含的Python包目录的一部分树。
/HTH

【讨论】:

  • 哇,包括拉取请求 :) 非常感谢!
【解决方案2】:

尝试将__init__.py 文件放在MANIFEST.in 中指定的包含文件夹中。

【讨论】:

  • 问题是它们是测试文件夹,所以不打算导入。
  • 好的。过去我发现安装后pip工具删除了所有未指定为模块的文件夹(里面有一个__init__.py)。
猜你喜欢
  • 1970-01-01
  • 2018-11-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-14
  • 1970-01-01
  • 2021-12-31
相关资源
最近更新 更多