[英]Python setuptools install is not installing a package
I created a fork from this git repo: https://github.com/QQuick/Opy 我从这个git repo创建了一个fork: https : //github.com/QQuick/Opy
I added an __init.py__
to the opy
directory / package. 我在opy
目录/包中添加了__init.py__
。 When I run setup.py install
, the opy
package is not installed into my site-packages
directory. 当我运行setup.py install
, opy
包没有安装到我的site-packages
目录中。 Why? 为什么?
Here's the setup.py script: 这是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',
],
)
Output: 输出:
>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
To sum up the statements from the comments: 总结评论中的陈述:
setuptools.setup
does its job; setuptools.setup
完成它的工作; however, instead of just copying modules to site-packages
(what distutils
does), python setup.py install
will build an egg file which is then installed by simply copying it to site-packages
. 然而, python setup.py install
不是仅仅将模块复制到site-packages
( distutils
做什么),而是构建一个egg文件,然后通过简单地将其复制到site-packages
来安装。 This way, it's easy to uninstall the package afterwards by just removing the one egg file. 这样,只需删除一个egg文件就可以轻松卸载软件包。
If you don't like the package being installed in an archive, you can: 如果您不喜欢存档中安装的软件包,您可以:
do the "old and unmanageable" install: 执行“旧的和无法管理的”安装:
$ python setup.py install --old-and-unmanageable
but beware that you may not be able to properly uninstall the package when doing that. 但要注意,这样做时可能无法正确卸载软件包。 Still, this command may be used eg in a virtual environment that you plan to remove afterwards anyway; 尽管如此,此命令仍可用于您计划在之后删除的虚拟环境中;
use pip
as it's able to install packages from source directories: 使用pip
因为它能够从源目录安装包:
$ pip install dir/
where dir
is the directory containing the setup.py
script. 其中dir
是包含setup.py
脚本的目录。 This is the preferred way; 这是首选方式; pip
will build a wheel file first, then install it. pip
将首先构建一个wheel文件,然后安装它。 The modules will be installed flat (written to disk as files), but pip
will also store the list of installed files among other metadata, so all files will be removed properly on package uninstall. 这些模块将平面安装(写入磁盘作为文件),但是pip
还会将已安装文件的列表存储在其他元数据中,因此在卸载软件包时将正确删除所有文件。
I replaced 我换了
from setuptools import setup
with 同
from distutils.core import setup
and that worked. 那很有效。 But, isn't the setuptools
module version of that function supposed to install into the site-packages directory? 但是,该函数的setuptools
模块版本不应该安装到site-packages目录中吗? The documentation indicates it does. 文档表明它确实如此。 I don't get it... 我不明白......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.