0

I am trying to use setup.py to install a Python package that is kept in a git repository, which we'll call my_dependency. In my_package, I have a setup.py file with:

setup(
    ...
    install_requires=[
        ...
        'my_dependency=VERSION'
    ],
    dependency_links=['git+https://...my_dependency.git#egg=my_dependency-VERSION',]
)

When I run my setup file (python setup.py develop), the dependency appears to install; it shows up as my_dependency==VERSION when I run pip freeze. However, when I start a python session and call import my_dependency, I get ImportError: No module named my_dependency.

I don't know if this is possibly the source of the problem, but when running setup.py, I get a warning:

Processing dependencies for my_package==0.1
Searching for my_dependency==VERSION
Doing git clone from https://.../my_dependency.git to /var/folders/.../.../T/easy_install-_rWjyp/my_dependency.git
Best match: my_dependency VERSION
Processing my_dependency.git
Writing /var/folders/.../my_dependency.git/setup.cfg
Running setup.py -q bdist_egg --dist-dir /var/folders/.../my_dependency.git/egg-dist-tmp-UMiNdL
warning: install_lib: 'build/lib' does not exist -- no Python modules to install

Copying my_dependency-VERSION-py2.7.egg to /.../my_package/venv/lib/python2.7/site-packages
Adding my_dependency VERSION to easy-install.pth file

However, I am able to use the package if I install it through pip, like this: pip install -e git+https://.../my_dependency.git#egg=my_dependency-VERSION

For reference, the dependency package structure looks like this:

my_dependency/
    my_dependency/
        __init__.py
    setup.py

And its setup.py contains this:

from setuptools import setup

setup(
    name='my_dependency',
    version='VERSION',
    description='...',
    author='...',
    url='https://...',
    license='MIT',
    install_requires=[
        'numpy',
    ],

    zip_safe=False,
)

1 Answer 1

1

The solution was (in retrospect) pretty silly. My dependency package was missing this line in its setup.py:

packages=['my_dependency'],

That meant the package was correctly building and installing, but it wasn't actually including the code in the package. This became apparent when I looked at the SOURCES.txt in the egg-info: it didn't include any of the Python source files in the package.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.