1

How to add dependencies inside setup.py file ? Like, I am writing this script on VM and want to check whether certain dependencies like, jdk or docker is there or not, and if there is no dependencies installed, then need to install automatically on VM using this script.

Please do tell me as soon as possible, as it is required for my project.

3 Answers 3

3

In simplest form, you can add (python) dependencies which can be install via pip as follow:

from setuptools import setup
setup(
    ...
    install_requires=["install-jdk", "docker>=4.3"],
    ...
)

Alternatively, write down a requirement.txt file and then use it:

with open("requirements.txt") as requirements_file:
    requirements = requirements_file.readlines()
    requirements = [x[:-1] for x in requirements]

setup(
    ...
    install_requires=requirements,
    ...
)

Whenever you'll execute python setup.py install then these dependencies will be checked against the available libraries in your VM and if they are not available (or version mismatch) then it will be installed (or replaced). More information can be found here.

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

Comments

0

Refer the https://github.com/boto/s3transfer/blob/develop/setup.py and check the requires variables.

You can refer many other open source projects

Comments

0

You can add dependencies using setuptools, however it can only check dependencies on python packages.

Because of that, you could check jdk and docker installation before setup(), manually. You could call system like the code below and check the reponse.

import os
os.system("java -version")
os.system("docker version --format \'{{.Server.Version}}\'")

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.