24

I have written a python module that depends on openpyxl. I want openpxyl to be installed as a dependency automatically using setuptools. I read that the proper way to do this is to include the following in the setup.py script:

setup(name='methpipe',
    version=find_version("lala", "__init__.py"),
    description='Utilities',
    author='Jonathan T',
    author_email='[email protected]',
    url='https://git.com...',
    packages=find_packages(),
    install_requires=[
        'openpxyl = 2.3.3',
    ],
    scripts=["bin/submit_run_full.py"],
    cmdclass=dict(install=my_install)
)

So I packaged up my module with python setup.py sdist, took the *.tar.gz file, unzipped it, and then ran python setup.py install, and openpyxl is NOT installing!!!

What am I doing wrong here?

2
  • Isn't there any error in the install log ? Commented Feb 19, 2016 at 23:17
  • 8
    I think you want to do openpyxl==2.3.3 Commented Mar 29, 2016 at 23:38

3 Answers 3

8

Try providing your dependency both in install_requires and setup_requires.

Following is from setuptool's documentation at https://pythonhosted.org/setuptools/setuptools.html

setup_requires

A string or list of strings specifying what other distributions need to be present in order for the setup script to run. setuptools will attempt to obtain these (even going so far as to download them using EasyInstall) before processing the rest of the setup script or commands. This argument is needed if you are using distutils extensions as part of your build process; for example, extensions that process setup() arguments and turn them into EGG-INFO metadata files.

(Note: projects listed in setup_requires will NOT be automatically installed on the system where the setup script is being run. They are simply downloaded to the ./.eggs directory if they’re not locally available already. If you want them to be installed, as well as being available when the setup script is run, you should add them to install_requires and setup_requires.)

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

1 Comment

setup_requires is "I need this at build time", whereas install_requires is "I need this dependency at runtime". Duplicating them in both places is not usually the right thing to do
1

I notice when you use override 'install' with a 'cmdclass' key. The pattern below also left me with uninstalled dependencies.

Custom_Install(install):
    def run(self):
        # some custom commands
        install.run(self) 

Adding the dependencies into setup_requires didn't work for me so in the end I just did my own pip install in the custom install command..

def pip_install(package_name):
    subprocess.call(
        [sys.executable, '-m', 'pip', 'install', package_name]
    )

Comments

1

Building with sdist create a source distribution, so I think it's normal taht dependencies are not packaged with your sources.

1 Comment

They are packaged with sdist :)

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.