【问题标题】:Setuptools setup.py installing when dependencies not satisfiedSetuptools setup.py 在不满足依赖项时安装
【发布时间】:2013-07-19 08:42:03
【问题描述】:

我有一个setup.py,看起来有点(好吧,完全一样):

#!/usr/bin/env python

from setuptools import setup
import subprocess
import distutils.command.build_py

class BuildWithMake(distutils.command.build_py.build_py):
    """
    Build using make.
    Then do the default build logic.

    """
    def run(self):
        # Call make.
        subprocess.check_call(["make"])

        # Keep installing the Python stuff
        distutils.command.build_py.build_py.run(self)


setup(name="jobTree",
    version="1.0",
    description="Pipeline management software for clusters.",
    author="Benedict Paten",
    author_email="benedict@soe.ucsc.edu",
    url="http://hgwdev.cse.ucsc.edu/~benedict/code/jobTree.html",
    packages=["jobTree", "jobTree.src", "jobTree.test", "jobTree.batchSystems",
    "jobTree.scriptTree"],
    package_dir= {"": ".."},
    install_requires=["sonLib"],
    # Hook the build command to also build with make
    cmdclass={"build_py": BuildWithMake},
    # Install all the executable scripts somewhere on the PATH
    scripts=["bin/jobTreeKill", "bin/jobTreeStatus", 
    "bin/scriptTreeTest_Sort.py", "bin/jobTreeRun", 
    "bin/jobTreeTest_Dependencies.py", "bin/scriptTreeTest_Wrapper.py", 
    "bin/jobTreeStats", "bin/multijob", "bin/scriptTreeTest_Wrapper2.py"])

当使用./setup.py install 运行时,它可以完美地安装包。但是,无论是否安装了“sonLib”包,它都会这样做,而忽略依赖关系。

这是预期的行为吗?如果没有安装依赖项,setup.py install 是否应该愉快地继续,让 pip 或其他任何东西预先安装它们?如果没有,并且 setup.py install 在不存在依赖项时应该会失败,我做错了什么?

编辑:一些版本信息:

Python 2.7.2 (default, Jan 19 2012, 21:40:50) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import setuptools
>>> setuptools.__version__
'0.6c12'
>>> 

【问题讨论】:

  • 我很确定setuptools 实际上并没有检查依赖关系。您可能想考虑改用distribute
  • @murgatroid99d - 分发和设置工具已重新合并在一起。并且 setuptools 通常确实安装依赖项。
  • 运行pip install setuptools -U 获取0.9 版本,我认为这个接受install_requires 选项,就像分发一样。

标签: python setuptools distutils


【解决方案1】:

default install command for Distutils setup 对依赖一无所知。如果您正在运行它,那么不会检查依赖项是对的。

不过,按照您在setup.py 中显示的内容,您正在使用Setuptools 来实现setup 功能。 Setuptools install command 被声明为运行 easy_install,而 easy_install 反过来会检查和下载依赖项。

您可能通过指定 install --single-version-externally-managed 显式调用 Distutils install

【讨论】:

    猜你喜欢
    • 2022-01-15
    • 1970-01-01
    • 2014-09-17
    • 2014-10-02
    • 2015-01-10
    • 1970-01-01
    • 2017-11-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多