setuptools麻烦 - 不包括包,包括数据文件 [英] setuptools troubles -- excluding packages, including data files
问题描述
我对setuptools很新。我看到了一些类似的问题,它驱动有点疯狂,我似乎遵循建议我看到,但setuptools仍然有不同于我想要的东西。
这里是我的项目的结构:
。
..
package1 /
__init__.py
abc.py
...
tests /
__init__.py
test_package1.py
LICENSE
README.md
RELEASE
setup.py
这里是我的setup.py的内容:
#!/ usr / bin / env python
import os
#from distutils.core import setup
从setuptools导入安装程序,find_packages
setup(
name ='package1',
version ='1.1',
test_suite =tests,
package = find_packages(exclude = ['tests']),
include_package_data = True,
package_data = {
'':['LICENSE','README.md5','RELEASE']
},
)
此外,在我的清单文件中我有:
包括LICENSE
include RELEASE
include README.md
我用tar建立:
python setup.py sdist
我想要:
- 从源发布中排除
tests
目录; - 在site-packages目录中,在顶层或package1目录中有LICENSE,README.md,RELEASE文件(此时我同意)。
相反,会发生以下情况:
- 文件被复制到存档,但不会安装到该软件包的网站打包目录。
<
tests 目录仍在创建的tar存档中,并安装到site-packages;
我有点想法,有人可以向我解释什么
您应该创建一个名为 MANIFEST的新文件。
最终在您的tar文件中,在包的根级别创建一个名为
MANIFEST.in
的新文件。例如,您可以使用 MANIFEST.in
文件中的 recursive-exclude
,从发布中排除整个目录。在您的情况下,您需要 MANIFEST.in
文件包含: 递归排除测试*
在网站中包含README和其他文件并不常见-packages目录,但如果你真的想要,然后进入 package1
并创建您要包括的文件的符号链接:
cd package1
ln -s ../LICENSE
ln -s ../README.md
ln -s ../ RELEASE
然后在setup.py中更改以下行:
$ $ b
package_data = {
>
到:
package_data = {
'package1':['LICENSE','README.md','RELEASE']
I'm fairly new to setuptools. I've seen a few similar questions and it drives a little bit insane that I've seemed to follow advice I saw but setuptools still does something different than what I want.
Here is the structure of my project:
.
..
package1/
__init__.py
abc.py
...
tests/
__init__.py
test_package1.py
LICENSE
README.md
RELEASE
setup.py
And here is the contents of my setup.py:
#!/usr/bin/env python
import os
#from distutils.core import setup
from setuptools import setup, find_packages
setup(
name='package1',
version='1.1',
test_suite="tests",
packages=find_packages(exclude=['tests']),
include_package_data=True,
package_data = {
'': ['LICENSE', 'README.md5', 'RELEASE']
},
)
Also, in my manifest file I have:
include LICENSE
include RELEASE
include README.md
I build the tar with:
python setup.py sdist
I want to:
- Exclude
tests
directory from the source distribution; - Have LICENSE, README.md, RELEASE files in the site-packages directory, either at the top level, or inside the package1 directory (at this point I will agree to either).
Instead, here's what happens:
tests
directory remains to be in the created tar archive and gets installed to the site-packages;- Files are copied to the archive, but do not get installed to the site-packaged directory of the package.
I am out of ideas, can someone explain to me what I am doing wrong and how to fix it?
You should create a new file called MANIFEST.in
in the root level of your package, then follow these instructions:
To control which files end up in your tar file, create a new file called
MANIFEST.in
in the root level of your package. For example, you can exclude whole directories from your distribution, usingrecursive-exclude
in theMANIFEST.in
file. In your case, you need yourMANIFEST.in
file to contain:recursive-exclude tests *
It's not common to include README and other files in the site-packages directory, but if you really want to, then go inside
package1
and create symbolic links to the files you want to include:cd package1 ln -s ../LICENSE ln -s ../README.md ln -s ../RELEASE
Then change the following line in your setup.py:
package_data = { '': ['LICENSE', 'README.md', 'RELEASE']
to:
package_data = { 'package1': ['LICENSE', 'README.md', 'RELEASE']
这篇关于setuptools麻烦 - 不包括包,包括数据文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!