4

我有一个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'
>>> 
4

1 回答 1

0

Distutils默认installsetup命令对依赖项一无所知。如果您正在运行它,那么您是对的,不会检查依赖项。

不过,按照您在 中显示的内容setup.py,您正在使用 Setuptools 来执行该setup功能。Setuptools命令被声明为 run installeasy_install它反过来会检查和下载依赖项。

您可以install通过指定明确调用 Distutils install --single-version-externally-managed

于 2015-01-13T22:31:49.907 回答