Skip to content

Instantly share code, notes, and snippets.

@duckinator
Last active January 21, 2020 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save duckinator/94205a8465403b2354d4469a437bad9f to your computer and use it in GitHub Desktop.
Save duckinator/94205a8465403b2354d4469a437bad9f to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
from pathlib import Path
import pep517.build
import sys
import textwrap
# quick-and-dirty pep517 wrapper that handles projects without a pyproject.toml.
# Released under public domain, CC0, or MIT license, whichever you prefer.
# This means you can re-license it to whatever you want and don't need to give me credit.
# - @duckinator
def _ensure_pyproject_exists():
pyproject_file = Path(Path.cwd(), 'pyproject.toml')
print(pyproject_file)
if not pyproject_file.exists():
pyproject_file.write_text(textwrap.dedent("""\
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
"""))
def build(args):
_ensure_pyproject_exists()
if not args:
args = ['--binary', '--source', '.']
pep517.build.main(pep517.build.parser.parse_args(args))
if __name__ == '__main__':
build(sys.argv[1:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment