步骤' build_py'中的隐秘错误Python的安装'

时间:2015-10-19 16:53:46

标签: python numpy pip setuptools setup.py

在尝试安装我的python项目adla时,我一直收到一个我无法理解的错误:

(devel)> $ cd $PROJECT_DIR
(devel)> $ pip3 -v install .
Processing [PROJECT_DIR]
  Running setup.py [...] egg_info for package from file://[PROJECT_DIR]
    Running command python setup.py egg_info
    running egg_info
    creating pip-egg-info/adla.egg-info
    writing requirements to pip-egg-info/adla.egg-info/requires.txt
    writing dependency_links to pip-egg-info/adla.egg-info/dependency_links.txt
    writing entry points to pip-egg-info/adla.egg-info/entry_points.txt
    writing pip-egg-info/adla.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/adla.egg-info/top_level.txt
    writing manifest file 'pip-egg-info/adla.egg-info/SOURCES.txt'
    warning: manifest_maker: standard file '-c' not found

    reading manifest file 'pip-egg-info/adla.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'pip-egg-info/adla.egg-info/SOURCES.txt'
  Source in [...] has version 0.8.4, which satisfies requirement adla==0.8.4 from file://[PROJECT_DIR]
Requirement already satisfied [...]
Could not parse version from link: file://[PROJECT_DIR]
Installing collected packages: adla
  Running setup.py install for adla
    Running command [...]/Environments/devel/bin/python3.5 -c [...]
    running install
    running build
    running build_py
    error: [Errno 2] No such file or directory: 'build/lib.macosx-10.11-x86_64-3.5/None'
    UPDATING build/lib.macosx-10.11-x86_64-3.5/None
    Complete output from command [...]Environments/devel/bin/python3.5 -c "import setuptools, tokenize;__file__='/var/folders/t2/kg3yygn93nd2s175mkdcx0sc0000gn/T/pip-cbqf77qe-build/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/t2/kg3yygn93nd2s175mkdcx0sc0000gn/T/pip-rtbxcavl-record/install-record.txt --single-version-externally-managed --compile --install-headers [...]/Environments/devel/bin/../include/site/python3.5/adla:
    running install
    running build
    running build_py
    error: [Errno 2] No such file or directory: 'build/lib.macosx-10.11-x86_64-3.5/None'
    UPDATING build/lib.macosx-10.11-x86_64-3.5/None
    ----------------------------------------
[...]
(devel)> $

无论我使用的是什么机器(在OS X 10.11,Ubuntu Server 14.04和运行Ubuntu Desktop 14.04的虚拟机上试过),都会出现错误。我还尝试重新安装Python 3.5,pipsetuptools,但无济于事。如您所见,我在virtualenv中使用Python 3.5,pip (7.1.2)setuptools (18.4)

该项目使用versioneer进行版本控制,并在扩展程序numpy中包含adla.ml.dtw广义ufunc,在发布$ python3 setup.py build_ext时可以正常构建。

我的setup.py文件如下所示

...
build_requires = []
try:
    import numpy
except ImportError:
    build_requires = ["numpy >= 1.7.0"]

requirements = [
    "bokeh",
    "pymongo",
    "characteristic",
    "click",
    "pandas",
    "theano",
    "scipy",
    "scikit-learn"
]

setup(
    name=DISTNAME,
    author=AUTHOR,
    author_email=EMAIL,
    description=DESCRIPTION,
    license=LICENSE,
    url=URL,
    download_url=DOWNLOAD_URL,
    classifiers=CLASSIFIERS,
    keywords=KEYWORDS,
    long_description=LONG_DESCRIPTION,
    version=versioneer.get_version(),
    cmdclass=versioneer.get_cmdclass(),
    platforms="any",
    setup_requires=build_requires,
    install_requires=build_requires + requirements,
    entry_points={
        "console_scripts": [
            "adla = adla.loader:main",
            "adlaml = adla.ml.loader:main"
        ]
    },
    packages=find_packages(where="src", exclude=("historical", "test", "specs")),
    package_dir={"": "src"},
    package_data={
        "adla": ["src/adla/config.ini", "src/adla/specs/*.json"]
    },
    ext_modules=[
        Extension(
            "adla.ml.dtw",
            ["src/adla/ml/dtw.cpp"],
            include_dirs=[resource_filename("numpy", "core/include")]
        )
    ]
)
...

编辑有关更多信息,请参阅build_py步骤的输出。

(devel)> $ python3 setup.py --verbose build_py
running build_py
creating build
creating build/lib.macosx-10.11-x86_64-3.5
creating build/lib.macosx-10.11-x86_64-3.5/adla
copying src/adla/__init__.py -> build/lib.macosx-10.11-x86_64-3.5/adla
copying src/adla/_version.py -> build/lib.macosx-10.11-x86_64-3.5/adla
copying src/adla/analysis.py -> build/lib.macosx-10.11-x86_64-3.5/adla
copying src/adla/commands.py -> build/lib.macosx-10.11-x86_64-3.5/adla
copying src/adla/inspection.py -> build/lib.macosx-10.11-x86_64-3.5/adla
copying src/adla/loader.py -> build/lib.macosx-10.11-x86_64-3.5/adla
copying src/adla/modification.py -> build/lib.macosx-10.11-x86_64-3.5/adla
copying src/adla/rbi.py -> build/lib.macosx-10.11-x86_64-3.5/adla
copying src/adla/util.py -> build/lib.macosx-10.11-x86_64-3.5/adla
creating build/lib.macosx-10.11-x86_64-3.5/adla/ml
copying src/adla/ml/__init__.py -> build/lib.macosx-10.11-x86_64-3.5/adla/ml
copying src/adla/ml/loader.py -> build/lib.macosx-10.11-x86_64-3.5/adla/ml
copying src/adla/ml/meta_model.py -> build/lib.macosx-10.11-x86_64-3.5/adla/ml
copying src/adla/ml/models.py -> build/lib.macosx-10.11-x86_64-3.5/adla/ml
copying src/adla/ml/util.py -> build/lib.macosx-10.11-x86_64-3.5/adla/ml
UPDATING build/lib.macosx-10.11-x86_64-3.5/None
error: [Errno 2] No such file or directory: 'build/lib.macosx-10.11-x86_64-3.5/None'

很遗憾,我不明白为什么setuptools正在尝试查找文件build/[...]/None。我非常感谢对错误的一些见解!

1 个答案:

答案 0 :(得分:2)

我只是设法自己解决问题。 versionfile_build中的版本变量setup.cfg设置为None,而不是propper versioneer版本文件。这是setup.cfg中的正确设置以供参考。

[versioneer]
VCS = git
style = pep440
versionfile_source = src/adla/_version.py
versionfile_build = adla/_version.py
tag_prefix =
parentdir_prefix = adla-

[pytest]
norecursedirs = .git .vagrant .eggs contrib puppet