Packagebuilder_ is a library designed for building packages. It takes InstallRequirement objects as inputs and first attempts to build a wheel, but falls back to producing a source distribution if necessary. Invocation is straightforward:
>>> import packagebuilder >>> import pip_shims >>> ireq = pip_shims.shims.InstallRequirement.from_line('vistir') >>> builder = packagebuilder.BuiltDist(ireq, sources=packagebuilder.get_sources()) >>> dist = builder.build() >>> dist.metadata.run_requires ['requests', 'six', 'backports.weakref; python_version < "3.3"', 'backports.shutil-get-terminal-size; python_version < "3.3"', 'pathlib2; python_version < "3.5"', "yaspin; extra == 'spinner'", "pytest; extra == 'tests'", "pytest-xdist; extra == 'tests'", "pytest-cov; extra == 'tests'", "pytest-timeout; extra == 'tests'", "hypothesis-fspaths; extra == 'tests'", "hypothesis; extra == 'tests'"]