Packaging Helper Functions (common)

Requirements / distutils “extras” helpers

Example usage for requirements/extras helpers

Examples:

>>> extensions = ['cache', 'crypto', 'django']
# Loads ``extras/{extension}.txt`` for each extension, then returns a dictionary mapping each extension
# to their requirements
>>> extras_require(extensions)
{'cache': ['redis'], 'crypto': ['cryptography>=2.8'], 'django': ['Django']}

# Load ``example.txt`` and merge sub-requirement lists.
>>> reqs('example.txt')
['privex-loghelper>=1.0', 'privex-jsonrpc', 'requests']

License note

The following functions were taken from Celery’s setup.py file. Since the time of writing this comment block, they may have been further modified from their originals.

  • strip_comments

  • pip_requirement

  • _reqs

  • reqs

  • extras

Celery is licensed under The BSD License (3 Clause, also known as the new BSD license). The license is an OSI approved Open Source license and is GPL-compatible(1).

The BSD license text can also be found here: http://www.opensource.org/licenses/BSD-3-Clause

Celery LICENSE file: https://github.com/celery/celery/blob/master/LICENSE

Functions

extras(*p)

Parse requirement in the extras/ directory.

extras_require(extra)

Get map of all extra requirements.

pip_requirement(req)

Check a requirement line for imports -r some/path/requirements.txt and import them if found.

reqs(*f)

Parse requirement file.

strip_comments(l)

Strip any # comments from a line.