Created
August 22, 2017 19:52
-
-
Save wcooley/2d0136418a6d302cc754df002eb93480 to your computer and use it in GitHub Desktop.
Inline setuptools command to list requirements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from setuptools import setup, Command | |
class ListRequirements(Command): | |
"""In-line command to display declared requirements.""" | |
# TODO: | |
# * Add option to write out in a format | |
# comaptible with requirements.txt. | |
# * Add options to restrict to particular | |
# kinds & extras. | |
user_options = [] | |
def initialize_options(self): | |
pass | |
def finalize_options(self): | |
pass | |
def run(self): | |
d = self.distribution | |
print('Requirements:\n ', end='') | |
print(*d.install_requires, sep='\n ', end='\n\n') | |
print('Extra requirements:') | |
for k, v in sorted(d.extras_require.items()): | |
print(k+':\n ', end='') | |
print(*v, sep='\n ') | |
print() | |
print('Test requirements:\n ', end='') | |
print(*d.tests_require, sep='\n ', end='\n\n') | |
print('Setup requirements:\n ', end='') | |
print(*d.setup_requires, sep='\n ', end='\n\n') | |
setup( | |
... | |
cmdclass={'reqs': ListRequirements}, | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment