How to reference a variable defined in setup.py?

I've got the following setup.py:

import itertools


dependencies = {
  'minimal': ['numpy', 'requests'],
  'option-a': ['scipy'],
  'option-b': ['matplotlib']
}

setup(
  install_requires=dependencies['minimal'],                           # minimal dependencies
  extras_require={
      'all': list(itertools.chain(*dependencies.values())),           # all dependencies included
      **{k: v for k, v in dependencies.items() if k != 'minimal'},    # each extra dependency group
  },
  # other setup parameters omitted
)

I used a variable dependencies to avoid duplicating lists of dependencies and to make it easy to maintain. It seems like a good approach.

I'd like to write a function verify_optional_extras('option-a') which will check if the packages for the option-a extras were installed.

If I could access the dependencies variable defined in setup.py I could easily write a verification function for those packages.

Possible answers to this question:

  1. Show me how to access dependencies in setup.py.
  2. Tell me a better way to organize optional dependencies.


Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation