Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python is not installing dependencies listed in install_requires of setuptools

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?

like image 489
jmtoung Avatar asked Feb 19 '16 22:02

jmtoung


People also ask

What is install_requires in setup py?

install_requires is a section within the setup.py file in which you need to input a list of the minimum dependencies needed for a project to run correctly on the target operating system (such as ubuntu). When pip runs setup.py, it will install all of the dependencies listed in install_requires.

Does pip install Setuptools?

Type “ pip install setuptools ” (without quotes) in the command line and hit Enter again. This installs setuptools for your default Python installation.

How do you install dependencies in Python?

To install Python dependencies for a private IP environment inside a perimeter, you can: Use a private PyPI repository hosted in your VPC network. Use a proxy server VM in your VPC network to connect to a PyPI repository on the public internet. Specify the proxy address in the /config/pip/pip.

What is the use of install_requires in Python?

install_requires ¶ install_requires is a setuptools setup.py keyword that should be used to specify what a project minimally needs to run correctly. When the project is installed by pip, this is the specification that is used to install its dependencies. For example, if the project requires A and B, your install_requires would be like so:

What is install_requires in pip install?

When the project is installed by pip, this is the specification that is used to install its dependencies. For example, if the project requires A and B, your install_requires would be like so: install_requires=[ 'A', 'B' ] Additionally, it’s best practice to indicate any known lower or upper bounds.

How do I install Setuptools in Python?

Setuptools is typically installed with Python downloaded from python.org, so there’s no need to separately install setuptools. Instead, your first step should be to use pip to update your Python installation to the latest version of setuptools on popular operating systems like Windows, Linux or macOS:

What is setup Py in Python?

Simply put, setup.py is a build script template distributed with Python’s setuptools package. Setuptools is the Python Packaging Authority (PyPA) package development process library and utility for building Python projects based on packages and their dependencies listed in a setup.py script.


3 Answers

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

like image 181
tau Avatar answered Sep 27 '22 21:09

tau


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]
    )
like image 20
the pillow Avatar answered Sep 27 '22 21:09

the pillow


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

like image 20
user2161165 Avatar answered Sep 27 '22 22:09

user2161165