ExtrasCommand

class privex.helpers.setuppy.commands.ExtrasCommand(dist)[source]

Distutils/setup.py command for managing package extras, including displaying/saving requirements, installing them, and more.

Usage in setup.py:

from setuptools import setup, find_packages
from privex.helpers import ExtrasCommand


setup(
    cmdclass={
        'extras': ExtrasCommand
    },
);

Command usage examples

Print all requirements listed for each extra in extras_require

./setup.py extras
#### Example output: ####
# # Extra [cache] - file: extras/cache.txt
# redis>=3.3
# # Extra [crypto] - file: extras/crypto.txt
# cryptography>=2.8
# Extra [django] - file: extras/django.txt
# Django
...

Print only the requirements for a specific extra:

./setup.py extras --extra=cache
#### Example output: ####
# # Extra [cache] - file: extras/cache.txt
# redis>=3.3

Install requirements for a specific extra using pip

./setup.py extras --install --extra=cache
# running extras
# Installing the following requirements: redis>=3.3
# Requirement already up-to-date: redis>=3.3 in ./venv/lib/python3.7/site-packages (3.3.11)
# Done.

Install ALL extras requirements using pip

./setup.py extras --install

List extras entered in extras_require

./setup.py extras --list
# # Extras available:
# full
# cache
# crypto
...
__init__(dist)

Create and initialize a new Command object. Most importantly, invokes the ‘initialize_options()’ method, which is the real initializer and depends on the actual command being instantiated.

Methods

Methods

finalize_options()

Set final values for all the options that this command supports.

initialize_options()

Set default values for all the options that this command supports.

install_extras()

Installs extras requirements using python -m pip install -U -r requirements.txt

run()

A command’s raison d’etre: carry out the action it exists to perform, controlled by the options initialized in ‘initialize_options()’, customized by other commands, the setup script, the command-line, and config files, and finalized in ‘finalize_options()’.

save_list(extra_list[, out_file])

Attributes

Attributes

description

user_options