Created
May 31, 2018 19:57
-
-
Save shlevy/315d6b686065b31a0962d6e879cc0e32 to your computer and use it in GitHub Desktop.
This file contains 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 __future__ import print_function | |
import sys | |
import tokenize | |
_is_declarative = True | |
with (getattr(tokenize, 'open', open))('setup.py') as setup_py: | |
_lines = [] | |
for line in setup_py: | |
if _is_declarative and line.strip() not in ['import setuptools', 'from setuptools import setup', 'setup()', '']: | |
_is_declarative = False | |
_lines.append(line) | |
if _is_declarative: | |
sys.exit(0) | |
import setuptools | |
# Hacky! But we can't keep __name__ == '__main__' with distutils.core.run_setup :( | |
setuptools.distutils.core._setup_stop_after = 'config' | |
__file__='setup.py' | |
sys.argv = [ __file__ ] | |
# Taken from nixpkgs run_setup.py, in turn taken from pip | |
exec(compile(''.join(_lines), __file__, 'exec')) | |
cfg = setuptools.distutils.core._setup_distribution | |
print("[metadata]") | |
print("name = %(name)s" % { 'name': cfg.metadata.name }) | |
print("version = %(version)s\n" % { 'version': cfg.metadata.version }) | |
print("[options]") | |
def print_list(name, deps): | |
if deps: | |
print("%(name)s =" % { 'name': name }) | |
for dep in deps: | |
print(" %(dep)s" % { 'dep': dep }) | |
print_list("install_requires", cfg.install_requires) | |
print_list("setup_requires", cfg.setup_requires) | |
print_list("tests_require", cfg.tests_require) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment