0

当我做

python setup.py bdist

对于我的 python 项目文件夹。我发现它创建了 dist, build 文件夹,但是在创建了 egg/tar 之后它会删除二进制文件。我如何保存二进制文件?我可以看到它在最后删除了 build 文件夹。

running bdist
running bdist_dumb
running build
running build_py
creating build
creating build/lib
creating build/lib/my_project_folder
copying my_project_folder/__init__.py -> build/lib/my_project_folder
copying my_project_folder/my_script.py -> build/lib/my_project_folder
installing to build/bdist.linux-x86_64/dumb
running install
running install_lib
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/dumb
creating build/bdist.linux-x86_64/dumb/usr
creating build/bdist.linux-x86_64/dumb/usr/lib
creating build/bdist.linux-x86_64/dumb/usr/lib/python2.6
creating build/bdist.linux-x86_64/dumb/usr/lib/python2.6/site-packages
creating build/bdist.linux-x86_64/dumb/usr/lib/python2.6/site-packages/my_project_folder
copying build/lib/my_project_folder/__init__.py -> build/bdist.linux-x86_64/dumb/usr/lib/python2.6/site-packages/my_project_folder
copying build/lib/my_project_folder/my_script.py -> build/bdist.linux-
byte-compiling build/bdist.linux-x86_64/dumb/usr/lib/python2.6/site-packages/my_project_folder/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/dumb/usr/lib/python2.6/site-packages/my_project_folder/my_script.py to my_script.pyc
running install_egg_info
running egg_info
creating my_project_folder.egg-info
writing requirements to my_project_folder.egg-info/requires.txt
writing my_project_folder.egg-info/PKG-INFO
writing top-level names to my_project_folder.egg-info/top_level.txt
writing dependency_links to my_project_folder.egg-info/dependency_links.txt
writing requirements to my_project_folder.egg-info/requires.txt
writing my_project_folder.egg-info/PKG-INFO
writing top-level names to my_project_folder.egg-info/top_level.txt
writing dependency_links to my_project_folder.egg-info/dependency_links.txt
writing manifest file 'my_project_folder.egg-info/SOURCES.txt'
reading manifest file 'my_project_folder.egg-info/SOURCES.txt'
writing manifest file 'my_project_folder.egg-info/SOURCES.txt'
Copying my_project_folder.egg-info to build/bdist.linux-x86_64/dumb/usr/lib/python2.6/site-packages/my_project_folder-1.0.0_SNAPSHOT-py2.6.egg-info
running install_scripts
creating /root/workspace/my_project-rpm/my_project-v1/target/my_project-v1-1.0.0-SNAPSHOT/dist
tar -cf /root/workspace/my_project-rpm/my_project-v1/target/my_project-v1-1.0.0-SNAPSHOT/dist/my_project-v1-1.0.0-SNAPSHOT.linux-x86_64.tar .
gzip -f9 /root/workspace/my_project-rpm/my_project-v1/target/my_project-v1-1.0.0-SNAPSHOT/dist/my_project-v1-1.0.0-SNAPSHOT.linux-x86_64.tar
tar -cf /root/workspace/my_project-rpm/my_project-v1/target/my_project-v1-1.0.0-SNAPSHOT/dist/my_project-v1-1.0.0-SNAPSHOT.linux-x86_64.tar .
gzip -f9 /root/workspace/my_project-rpm/my_project-v1/target/my_project-v1-1.0.0-SNAPSHOT/dist/my_project-v1-1.0.0-SNAPSHOT.linux-x86_64.tar
removing 'build/bdist.linux-x86_64/dumb' (and everything under it)

我要解决的问题是创建一个仅包含二进制文件的 tar 文件。到目前为止,我能够创建包含 *.py 和 *.pyc 文件的 tar 文件(默认情况下使用 bdist 命令)我知道这是 bdist 命令的功能。但我不希望 .py 文件在最后 tar 中。

只要我可以访问 *.pyc 文件,我就可以自己创建 tar,但 setuptools 不允许我保留它。

4

1 回答 1

0

两者都做。

python setup.py bdist build

或者

python setup.py bdist
python setup.py build
于 2013-04-17T08:11:59.560 回答