3

I am working on a python project.

I have already created my setup.py file.

Is there a way to make use of setup.py file install_requires section so as to create my virtualenv, or do I have to explicitly create a requirements.txt file and proceed with

  • virtualenv -p python3 venv
  • pip install -r requirements.txt

1 Answer 1

3

setup.py installs the package in whichever environment is active. If you want to install it in a virtualenv, then you need to activate it first. Otherwise it will install globally.

You can continue using requirements.txt but let setup.py handle the installation. You can then read the file and set the list of dependencies for install_requires section.

from setuptools import setup, find_packages

with open('requirements.txt') as f:
    requirements = f.readlines()

setup(
    name='myawesomepackage',
    version='0.1',
    packages=find_packages(),
    url='https://example.com',
    author='abdusco',
    description='',
    install_requires=requirements,
    entry_points=dict(console_scripts=[
        'myawesomeapp=app:main'
    ])
)

Here's requirements.txt

certifi==2019.3.9
chardet==3.0.4
Click==7.0
idna==2.8
requests==2.22.0
urllib3==1.25.3
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.