【发布时间】:2018-10-15 18:40:13
【问题描述】:
我从这个 git repo 创建了一个分支:https://github.com/QQuick/Opy
我在opy 目录/包中添加了一个__init__.py。当我运行setup.py install 时,opy 包没有安装到我的site-packages 目录中。为什么?
这里是 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
【问题讨论】:
-
是什么让你觉得包没有安装?它就在那里,只是不是你所期望的形式。在
site-packages目录中查找文件opy-1.1.28.1-py2.7.egg,这是已安装的包。另外,要检查是否安装了包,可以尝试导入模块:python -c "import opy; print('opy is installed')"等。 -
哦。真的吗?鸡蛋是包装本身吗?有没有办法让 setuptools 以明文形式安装它?
-
鸡蛋只是一个压缩包,所以你可以看看里面有什么。您可以通过发出
python setup.py install --old-and-unmanageable强制setuptools进入平面安装,这实际上(几乎)与使用distutils.core.setup相同,但它的命名是有原因的。 -
问题是,
distutils包不跟踪正在为一个包安装的文件,因此之后无法执行干净卸载 - 你根本不知道哪些文件应删除属于该包的。这是setuptools推出自己的包安装程序easy_install和egg格式(打包为单个文件)的主要原因之一,也是pip出现setuptools方法也失败的原因(但这是另一个故事)。 -
你必须使用
setup.py install吗?正确的替代方法是从setup.py所在的目录运行pip install .;pip从源代码构建一个轮子,包括其中的文件列表,然后安装该构建的轮子;之后,卸载软件包只是通过该列表并删除每个文件。像魅力一样工作。
标签: python setuptools