简体   繁体   English

Python setuptools安装不是安装包

[英]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 installopy包没有安装到我的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-packagesdistutils做什么),而是构建一个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.

相关问题 “ easy_install setuptools”是否将setuptools安装到其他站点包中? - “easy_install setuptools” is installing setuptools into different site-package? 哪个是最pythonic:通过包管理器(macports,apt)或通过pip / easy_install / setuptools安装python模块 - Which is the most pythonic: installing python modules via a package manager ( macports, apt) or via pip/easy_install/setuptools python没有安装setuptools的install_requires中列出的依赖项 - python is not installing dependencies listed in install_requires of setuptools 使用setuptools创建软件包无法正确安装 - creating package with setuptools not installing properly python setuptools:如何用cython子模块安装包? - python setuptools: how can I install package with cython submodules? 我可以为所有用户安装python软件包(在开发模式下使用setuptools) - Can I install a python package for all users (with setuptools in develop mode) 如何配置 python setuptools 将模块作为单个包安装在根目录中? - How to configure python setuptools to install modules in the root directory as a single package? Python setuptools安装为可编辑 - Python setuptools install as editable Python setuptools将脚本安装到路径 - Python setuptools installing script to path 在私有版本的python中安装setuptools - Installing setuptools in a private version of python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM