Skip to content

Commit

Permalink
chore: include more files in sdist (to make it self-sufficient) (fa…
Browse files Browse the repository at this point in the history
…lconry#2139)

* chore: include more files in `sdist` (to make it self-sufficient)

* chore: change the mintest workflow to use sdist instead

* docs: add a newsfragment

* chore: revert `mintest.yaml` to only run on `master` merges
(now that it has passed for demonstration purposes).

* chore: remove temp dir when done
  • Loading branch information
vytas7 authored Jan 17, 2023
1 parent 0d808d9 commit 16d4710
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 5 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/mintest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ jobs:
run: |
tools/sed_coverage_rc.py
- name: Run tox
run: tox
- name: Run tox inside sdist
run: |
tools/tox_sdist.py
9 changes: 7 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
recursive-include docs *.rst *.html *.ico *.png *.py *.svg
recursive-include examples *.py
recursive-include falcon *.pyx
recursive-include tests *.py
recursive-include docs *.rst
recursive-include tests *.py *.pyx
include .coveragerc
include tox.ini
include CONTRIBUTING.md
include README.rst
include AUTHORS
include LICENSE
include docs/conf.py docs/Makefile
graft docs/_static
graft docs/_templates
graft requirements
graft tools
prune docs/_build
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ See also: `CONTRIBUTING.md <https://github.com/falconry/falcon/blob/master/CONTR
Legal
-----

Copyright 2013-2022 by Individual and corporate contributors as
Copyright 2013-2023 by Individual and corporate contributors as
noted in the individual source files.

Licensed under the Apache License, Version 2.0 (the "License"); you may
Expand Down
4 changes: 4 additions & 0 deletions docs/_newsfragments/2051.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Some essential files were unintentionally omitted from the source distribution
archive, rendering it unsuitable to run the test suite off.
This has been fixed, and the ``sdist`` tarball should now be usable as a base
for packaging Falcon in OS distributions.
Binary file removed docs/_static/img/my-web-app.gif
Binary file not shown.
Binary file removed docs/_static/img/my-web-app.png
Binary file not shown.
72 changes: 72 additions & 0 deletions tools/tox_sdist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env python

import argparse
import atexit
import logging
import pathlib
import shutil
import subprocess
import sys
import tarfile
import tempfile

logging.basicConfig(
format='[tox_sdist.py] %(asctime)s [%(levelname)s] %(message)s', level=logging.INFO
)
HERE = pathlib.Path(__file__).resolve().parent
DIST = HERE.parent / 'dist'


def build_sdist():
subprocess.check_call((sys.executable, 'setup.py', 'sdist'))
archives = sorted(DIST.glob('*.tar.gz'), key=lambda p: p.stat().st_mtime)
assert archives, 'no sdist archives found, something is wrong!'
archive = archives[-1]
logging.info(f'Built sdist: {archive}.')
return archive


def extract_sdist(archive, target):
with tarfile.open(archive) as targz:
targz.extractall(target)

content = target / archive.with_suffix('').stem
assert content.is_dir, 'no extracted directory found, something is wrong!'
logging.info(f'Extracted {archive} to {content}.')
return content


def exec_tox(tox_ini_dir):
logging.info(f'Running tox in {tox_ini_dir}...')
subprocess.check_call(('tox', '--version'))
subprocess.check_call(('tox',), cwd=tox_ini_dir)


def _cleanup(target):
shutil.rmtree(target)
logging.info(f'Removed temporary directory {target}.')


def main():
description = 'Build, extract sdist to a temp path, and run tox within.'

parser = argparse.ArgumentParser(description=description)
parser.add_argument(
'-p', '--path', help='path to extract sdist to (default: create temp)'
)
args = parser.parse_args()

target = args.path
if not target:
target = tempfile.mkdtemp(prefix='falcon-')
atexit.register(_cleanup, target)
target = pathlib.Path(target)
logging.info(f'Using target path: {target}.')

archive = build_sdist()
extracted = extract_sdist(archive, target)
exec_tox(extracted)


if __name__ == '__main__':
main()

0 comments on commit 16d4710

Please sign in to comment.