Python setuptools安装未安装程序包
我从这个git回购中创建了一个fork: 我在Python setuptools安装未安装程序包,python,setuptools,Python,Setuptools,我从这个git回购中创建了一个fork: 我在opy目录/包中添加了一个\uuu init.py\uuu。当我运行setup.py install时,opy软件包未安装到我的站点软件包目录中。为什么? 下面是setup.py脚本: import os import sys sys.path.append ('opy') import opy from setuptools import setup import codecs def read (*paths): with code
opy
目录/包中添加了一个\uuu init.py\uuu
。当我运行setup.py install
时,opy
软件包未安装到我的站点软件包
目录中。为什么?
下面是setup.py脚本:
import os
import sys
sys.path.append ('opy')
import opy
from setuptools import setup
import codecs
def read (*paths):
with codecs.open (os.path.join (*paths), 'r', encoding = 'utf-8') as aFile:
return aFile.read()
setup (
name = 'Opy',
version = opy.programVersion,
description = 'OPY - Obfuscator for Python, string obfuscation added, keyword added',
long_description = (
read ('README.rst') + '\n\n' +
read ('license_reference.txt')
),
keywords = ['opy', 'obfuscator', 'obfuscation', 'obfuscate', 'kivy', 'pyo', 'python'],
url = 'https://github.com/JdeH/Opy/',
license = 'Apache 2',
author = 'Jacques de Hooge',
author_email = 'jacques.de.hooge@qquick.org',
packages = ['opy'],
include_package_data = True,
install_requires = [],
classifiers = [
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Natural Language :: English',
'License :: Other/Proprietary License',
'Topic :: Software Development :: Libraries :: Python Modules',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
],
)
输出:
>python setup.py install
running install
running bdist_egg
running egg_info
creating Opy.egg-info
writing Opy.egg-info\PKG-INFO
writing top-level names to Opy.egg-info\top_level.txt
writing dependency_links to Opy.egg-info\dependency_links.txt
writing manifest file 'Opy.egg-info\SOURCES.txt'
reading manifest file 'Opy.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files matching '*.pyc' found anywhere in distribution
warning: no previously-included files matching '*.des' found anywhere in distribution
writing manifest file 'Opy.egg-info\SOURCES.txt'
installing library code to build\bdist.win32\egg
running install_lib
running build_py
creating build
creating build\lib
creating build\lib\opy
copying opy\opy.py -> build\lib\opy
copying opy\opymaster.py -> build\lib\opy
copying opy\__init__.py -> build\lib\opy
creating build\bdist.win32
creating build\bdist.win32\egg
creating build\bdist.win32\egg\opy
copying build\lib\opy\opy.py -> build\bdist.win32\egg\opy
copying build\lib\opy\opymaster.py -> build\bdist.win32\egg\opy
copying build\lib\opy\__init__.py -> build\bdist.win32\egg\opy
byte-compiling build\bdist.win32\egg\opy\opy.py to opy.pyc
byte-compiling build\bdist.win32\egg\opy\opymaster.py to opymaster.pyc
byte-compiling build\bdist.win32\egg\opy\__init__.py to __init__.pyc
creating build\bdist.win32\egg\EGG-INFO
copying Opy.egg-info\PKG-INFO -> build\bdist.win32\egg\EGG-INFO
copying Opy.egg-info\SOURCES.txt -> build\bdist.win32\egg\EGG-INFO
copying Opy.egg-info\dependency_links.txt -> build\bdist.win32\egg\EGG-INFO
copying Opy.egg-info\top_level.txt -> build\bdist.win32\egg\EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist\Opy-1.1.28.1-py2.7.egg' and adding 'build\bdist.win32\egg' to it
removing 'build\bdist.win32\egg' (and everything under it)
Processing Opy-1.1.28.1-py2.7.egg
Copying Opy-1.1.28.1-py2.7.egg to c:\python27\lib\site-packages
Adding Opy 1.1.28.1 to easy-install.pth file
Installed c:\python27\lib\site-packages\opy-1.1.28.1-py2.7.egg
Processing dependencies for Opy==1.1.28.1
Finished processing dependencies for Opy==1.1.28.1
我换了
从设置工具导入设置
与
从distutils.core导入设置
这起作用了。但是,该功能的setuptools
模块版本不应该安装到站点软件包目录中吗?文件表明确实如此。我不明白…总结一下评论中的陈述:
setuptools.setup
完成其工作;但是,python setup.py install
将生成一个egg文件,然后通过将其复制到站点软件包来安装,而不仅仅是将模块复制到站点软件包中(distutils
)。这样,只需删除一个egg文件,就可以轻松地在以后卸载包
如果您不喜欢将包安装在存档中,可以:
- 是否安装“旧的且不可管理的”软件:
但请注意,这样做时,您可能无法正确卸载软件包。尽管如此,该命令仍可以在虚拟环境中使用,您计划在以后删除该虚拟环境
- 使用
pip
,因为它可以从源目录安装软件包:
$ pip install dir/
其中dir
是包含setup.py
脚本的目录。这是首选方式pip
将首先构建一个控制盘文件,然后安装它。模块将以平面方式安装(作为文件写入磁盘),但pip
还将在其他元数据中存储已安装文件的列表,因此在卸载软件包时将正确删除所有文件
是什么让您认为软件包未安装?它就在那里,只是不是你所期望的那样。在site packages
dir中查找文件opy-1.1.28.1-py2.7.egg
,这是已安装的软件包。另外,要检查包是否已安装,可以尝试导入模块:python-c“import opy;print('opy is installed')”
等。真正地鸡蛋是包装本身吗?有一种方法可以让setuptools以明文形式安装它吗?一个egg只是一个zip归档文件,所以您可以查看其中的内容。您可以通过发布python setup.py install--old and unmanaged
强制setuptools
进行平面安装,这与使用distutils.core.setup
的效果(几乎)相同,但它的命名是有原因的。distutils
包不会跟踪为包安装的文件,因此,没有办法在以后执行干净的卸载-您根本不知道应该删除属于该包的哪些文件。这是setuptools
推出自己的软件包安装程序easy\u install
和egg
格式(作为单个文件包)的主要原因之一,也是pip
出现的原因之一,因为setuptools
方法也失败了(但这是另一回事)。你必须使用setup.py install
吗?正确的替代方法是从setup.py
所在的目录运行pip安装。
pip
从源代码构建控制盘,包括其中的文件列表,然后安装构建的控制盘;之后,卸载软件包只需遍历该列表并删除每个文件。工作起来很有魅力。
$ pip install dir/