Search code examples
pythonnumpypipsetuptoolssetup.py

Cryptic error in step 'build_py' of Python's 'setup.py install'


While trying to install my python project adla, I've been receiving an error that I cannot make sense of:

(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)> $

The error appears regardless of the machine that I'm using (tried on OS X 10.11, Ubuntu Server 14.04 and a virtual machine running Ubuntu Desktop 14.04). I also attempted to do fresh installs of Python 3.5, pip and setuptools, to no avail. As you see, I'm using Python 3.5 in a virtualenv, with pip (7.1.2) and setuptools (18.4).

The project uses versioneer for versioning and contains a numpy generalized ufunc in extension adla.ml.dtw, which builds fine when issuing $ python3 setup.py build_ext.

My setup.py file looks as follows

...
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")]
        )
    ]
)
...

EDIT For a little more information, here's the output of the build_py step run by itself.

(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'

Unfortunately, I don't understand why setuptools is trying to find the file build/[...]/None. I would greatly appreciate some insight into the error!


Solution

  • I just managed to solve the problem on my own. The versioneer variable versionfile_build in setup.cfg was set to None instead of the propper versioneer version file. Here's the correct set-up in setup.cfg for reference.

    [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