When I run
当我跑
python setup.py sdist
it creates an sdist in my ./dist directory. This includes a "PROJECT-egg.info" file in the zip inside my "dist" folder, which I don't use, but it doesn't hurt me, so I just ignore it.
它在我的./dist目录中创建了一个sdist。这包括我的“dist”文件夹中的zip中的“PROJECT-egg.info”文件,我没有使用它,但它不会伤害我,所以我只是忽略它。
My question is why does it also create a "PROJECT-egg.info" folder in my project root directory? Can I make it stop creating this? If not, can I just delete it immediately after creating the sdist?
我的问题是为什么它还在我的项目根目录中创建了一个“PROJECT-egg.info”文件夹?我可以让它停止创建吗?如果没有,我可以在创建sdist后立即删除它吗?
I'm using the 'setup' function imported from setuptools. WindowsXP, Python2.7, Setuptools 0.6c11, Distribute 0.6.14.
我正在使用从setuptools导入的'setup'功能。 WindowsXP,Python2.7,Setuptools 0.6c11,分发0.6.14。
My setup config looks like:
我的设置配置如下:
{'author': 'Jonathan Hartley',
'author_email': 'tartley@tartley.com',
'classifiers': ['Development Status :: 1 - Planning',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: Microsoft :: Windows',
'Programming Language :: Python :: 2.7'],
'console': [{'script': 'demo.py'}],
'data_files': [('Microsoft.VC90.CRT',
['..\\lib\\Microsoft.VC90.CRT\\Microsoft.VC90.CRT.manifest',
'..\\lib\\Microsoft.VC90.CRT\\msvcr90.dll'])],
'description': 'Utilities for games and OpenGL graphics, built around Pyglet.\n',
'keywords': '',
'license': 'BSD',
'long_description': "blah blah blah",
'name': 'pygpen',
'options': {'py2exe': {'ascii': True,
'bundle_files': 1,
'dist_dir': 'dist/pygpen-0.1-windows',
'dll_excludes': [],
'excludes': ['_imaging_gif',
'_scproxy',
'clr',
'dummy.Process',
'email',
'email.base64mime',
'email.utils',
'email.Utils',
'ICCProfile',
'Image',
'IronPythonConsole',
'modes.editingmodes',
'startup',
'System',
'System.Windows.Forms.Clipboard',
'_hashlib',
'_imaging',
'_multiprocessing',
'_ssl',
'_socket',
'bz2',
'pyexpat',
'pyreadline',
'select',
'win32api',
'win32pipe',
'calendar',
'cookielib',
'difflib',
'doctest',
'locale',
'optparse',
'pdb',
'pickle',
'pyglet.window.xlib',
'pyglet.window.carbon',
'pyglet.window.carbon.constants',
'pyglet.window.carbon.types',
'subprocess',
'tarfile',
'threading',
'unittest',
'urllib',
'urllib2',
'win32con',
'zipfile'],
'optimize': 2}},
'packages': ['pygpen'],
'scripts': ['demo.py'],
'url': 'http://code.google.com/p/edpath/',
'version': '0.1',
'zipfile': None}
3 个解决方案
#1
48
This directory is created intentionally as part of the build process for a source distribution. A little gander at the developer guide for setuptools gives you a hint as to why:
此目录是作为源分发的构建过程的一部分有意创建的。在setuptools的开发人员指南中,您可以看到为什么:
But, be sure to ignore any part of the distutils documentation that deals with MANIFEST or how it's generated from MANIFEST.in; setuptools shields you from these issues and doesn't work the same way in any case. Unlike the distutils, setuptools regenerates the source distribution manifest file every time you build a source distribution, and it builds it inside the project's .egg-info directory, out of the way of your main project directory. You therefore need not worry about whether it is up-to-date or not.
但是,请务必忽略处理MANIFEST的distutils文档的任何部分或者如何从MANIFEST.in生成它; setuptools保护您免受这些问题的影响,并且在任何情况下都不会以相同的方式工作。与distutils不同,setuptools每次构建源代码分发时都会重新生成源代码分发清单文件,并在项目的.egg-info目录中构建它,不受主项目目录的影响。因此,您无需担心它是否是最新的。
You may safely delete the directory after your build has completed.
构建完成后,您可以安全地删除该目录。
Bonus edit:
奖金编辑:
I customize the clean
command within my setup.py
on many of my Python projects to delete *.egg-info
, dist
, build
, and *.pyc
and other files. Here's an example of how it's done in setup.py
:
我在我的许多Python项目中的setup.py中自定义了clean命令,以删除* .egg-info,dist,build和* .pyc以及其他文件。这是一个如何在setup.py中完成的示例:
import os
from setuptools import setup, Command
class CleanCommand(Command):
"""Custom clean command to tidy up the project root."""
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
os.system('rm -vrf ./build ./dist ./*.pyc ./*.tgz ./*.egg-info')
# Further down when you call setup()
setup(
# ... Other setup options
cmdclass={
'clean': CleanCommand,
}
)
To illustrate, after running python setup.py build
on a dummy project called "poop" (Yes, I'm very mature), this happens:
为了说明,在一个名为“poop”的虚拟项目上运行python setup.py构建之后(是的,我很成熟),会发生这种情况:
$ python setup.py build
running build
running build_py
creating build
creating build/lib
creating build/lib/poop
copying poop/__init__.py -> build/lib/poop
And now if we run python setup.py clean
:
现在如果我们运行python setup.py clean:
$ python setup.py clean
running clean
removed `./build/lib/poop/__init__.py'
removed directory: `./build/lib/poop'
removed directory: `./build/lib'
removed directory: `./build'
Tada!
田田!
#2
11
The -egg.info
folder isn't always a temporary artifact you can delete.
-egg.info文件夹并不总是您可以删除的临时工件。
For example, if you use pip install -e YOURPACKAGE
for an "editable" install (works via symlink like python setup.py develop
so you don't have to re-install a package every time you edit it locally), the -egg.info
folder is required at runtime when your package is imported in another source. If it doesn't exist, you will get a DistributionNotFound
error.
例如,如果您使用pip install -e YOURPACKAGE进行“可编辑”安装(通过symlink工作,如python setup.py develop,这样您每次在本地编辑时都不必重新安装包),-egg在另一个源中导入包时,运行时需要.info文件夹。如果它不存在,您将收到DistributionNotFound错误。
#3
8
Note that you can have the PROJECT.egg-info
artifacts disappear completely from your sdist.
请注意,您可以让PROJECT.egg-info工件完全从您的sdist中消失。
The command setup.py egg_info
will use the source root as the egg base by default, resulting in the PROJECT.egg-info
directory being packaged into the sdist.
setup.py egg_info命令默认使用源根作为egg base,导致PROJECT.egg-info目录被打包到sdist中。
You can configure the egg base by passing the option --egg-base
. This will create the PROJECT.egg-info
directory somewhere else, leaving it out of your source distribution completely. You might also use a setup.cfg
to set that property.
您可以通过传递选项--egg-base来配置egg base。这将在其他地方创建PROJECT.egg-info目录,使其完全脱离源代码分发。您也可以使用setup.cfg来设置该属性。
The following command to create a sdist without a PROJECT.egg-info
works for me:
以下命令创建没有PROJECT.egg-info的sdist对我有用:
python setup.py egg_info --egg-base /tmp sdist
Or in a setup.cfg
:
或者在setup.cfg中:
[egg_info]
egg_base = /tmp
#1
48
This directory is created intentionally as part of the build process for a source distribution. A little gander at the developer guide for setuptools gives you a hint as to why:
此目录是作为源分发的构建过程的一部分有意创建的。在setuptools的开发人员指南中,您可以看到为什么:
But, be sure to ignore any part of the distutils documentation that deals with MANIFEST or how it's generated from MANIFEST.in; setuptools shields you from these issues and doesn't work the same way in any case. Unlike the distutils, setuptools regenerates the source distribution manifest file every time you build a source distribution, and it builds it inside the project's .egg-info directory, out of the way of your main project directory. You therefore need not worry about whether it is up-to-date or not.
但是,请务必忽略处理MANIFEST的distutils文档的任何部分或者如何从MANIFEST.in生成它; setuptools保护您免受这些问题的影响,并且在任何情况下都不会以相同的方式工作。与distutils不同,setuptools每次构建源代码分发时都会重新生成源代码分发清单文件,并在项目的.egg-info目录中构建它,不受主项目目录的影响。因此,您无需担心它是否是最新的。
You may safely delete the directory after your build has completed.
构建完成后,您可以安全地删除该目录。
Bonus edit:
奖金编辑:
I customize the clean
command within my setup.py
on many of my Python projects to delete *.egg-info
, dist
, build
, and *.pyc
and other files. Here's an example of how it's done in setup.py
:
我在我的许多Python项目中的setup.py中自定义了clean命令,以删除* .egg-info,dist,build和* .pyc以及其他文件。这是一个如何在setup.py中完成的示例:
import os
from setuptools import setup, Command
class CleanCommand(Command):
"""Custom clean command to tidy up the project root."""
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
os.system('rm -vrf ./build ./dist ./*.pyc ./*.tgz ./*.egg-info')
# Further down when you call setup()
setup(
# ... Other setup options
cmdclass={
'clean': CleanCommand,
}
)
To illustrate, after running python setup.py build
on a dummy project called "poop" (Yes, I'm very mature), this happens:
为了说明,在一个名为“poop”的虚拟项目上运行python setup.py构建之后(是的,我很成熟),会发生这种情况:
$ python setup.py build
running build
running build_py
creating build
creating build/lib
creating build/lib/poop
copying poop/__init__.py -> build/lib/poop
And now if we run python setup.py clean
:
现在如果我们运行python setup.py clean:
$ python setup.py clean
running clean
removed `./build/lib/poop/__init__.py'
removed directory: `./build/lib/poop'
removed directory: `./build/lib'
removed directory: `./build'
Tada!
田田!
#2
11
The -egg.info
folder isn't always a temporary artifact you can delete.
-egg.info文件夹并不总是您可以删除的临时工件。
For example, if you use pip install -e YOURPACKAGE
for an "editable" install (works via symlink like python setup.py develop
so you don't have to re-install a package every time you edit it locally), the -egg.info
folder is required at runtime when your package is imported in another source. If it doesn't exist, you will get a DistributionNotFound
error.
例如,如果您使用pip install -e YOURPACKAGE进行“可编辑”安装(通过symlink工作,如python setup.py develop,这样您每次在本地编辑时都不必重新安装包),-egg在另一个源中导入包时,运行时需要.info文件夹。如果它不存在,您将收到DistributionNotFound错误。
#3
8
Note that you can have the PROJECT.egg-info
artifacts disappear completely from your sdist.
请注意,您可以让PROJECT.egg-info工件完全从您的sdist中消失。
The command setup.py egg_info
will use the source root as the egg base by default, resulting in the PROJECT.egg-info
directory being packaged into the sdist.
setup.py egg_info命令默认使用源根作为egg base,导致PROJECT.egg-info目录被打包到sdist中。
You can configure the egg base by passing the option --egg-base
. This will create the PROJECT.egg-info
directory somewhere else, leaving it out of your source distribution completely. You might also use a setup.cfg
to set that property.
您可以通过传递选项--egg-base来配置egg base。这将在其他地方创建PROJECT.egg-info目录,使其完全脱离源代码分发。您也可以使用setup.cfg来设置该属性。
The following command to create a sdist without a PROJECT.egg-info
works for me:
以下命令创建没有PROJECT.egg-info的sdist对我有用:
python setup.py egg_info --egg-base /tmp sdist
Or in a setup.cfg
:
或者在setup.cfg中:
[egg_info]
egg_base = /tmp