diff options
author | Hugo van Kemenade <hugovk@users.noreply.github.com> | 2022-04-29 13:47:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-29 13:47:26 (GMT) |
commit | 89c6b2b8f615a1c1827a92c4582c213b1a5027fb (patch) | |
tree | f4e4996942f7d0e314d0a2e4c732d74b098aef36 /Tools | |
parent | 64113a4ba801126028505c50a7383f3e9df29573 (diff) | |
download | cpython-89c6b2b8f615a1c1827a92c4582c213b1a5027fb.zip cpython-89c6b2b8f615a1c1827a92c4582c213b1a5027fb.tar.gz cpython-89c6b2b8f615a1c1827a92c4582c213b1a5027fb.tar.bz2 |
bpo-36329: Remove 'make -C Doc serve' in favour of 'make -C Doc htmlview' (GH-32354)
Also updated `make -C htmlview` so it used a full path with `file://`, because the original didn't open the page (macOS).
For example:
```sh
cd Doc
# Doesn't open anything:
python3 -c "import webbrowser; webbrowser.open('build/html/index.html')"
# Opens the docs page e.g. file:///Users/hugo/github/cpython/Doc/build/html/index.html :
python3 -c "import os, webbrowser; webbrowser.open('file://' + os.path.realpath('build/html/index.html'))"
```
https://bugs.python.org/issue36329
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/scripts/README | 1 | ||||
-rwxr-xr-x | Tools/scripts/serve.py | 36 |
2 files changed, 0 insertions, 37 deletions
diff --git a/Tools/scripts/README b/Tools/scripts/README index ba0f662..c1d6673 100644 --- a/Tools/scripts/README +++ b/Tools/scripts/README @@ -57,7 +57,6 @@ reindent.py Change .py files to use 4-space indents reindent-rst.py Fix-up reStructuredText file whitespace rgrep.py Reverse grep through a file (useful for big logfiles) run_tests.py Run the test suite with more sensible default options -serve.py Small wsgiref-based web server, used in make serve in Doc stable_abi.py Stable ABI checks and file generators. suff.py Sort a list of files by suffix texi2html.py Convert GNU texinfo files into HTML diff --git a/Tools/scripts/serve.py b/Tools/scripts/serve.py deleted file mode 100755 index 7ac9c10..0000000 --- a/Tools/scripts/serve.py +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env python3 -''' -Small wsgiref based web server. Takes a path to serve from and an -optional port number (defaults to 8000), then tries to serve files. -Mime types are guessed from the file names, 404 errors are raised -if the file is not found. Used for the make serve target in Doc. -''' -import sys -import os -import mimetypes -from wsgiref import simple_server, util - -def app(environ, respond): - - fn = os.path.join(path, environ['PATH_INFO'][1:]) - if '.' not in fn.split(os.path.sep)[-1]: - fn = os.path.join(fn, 'index.html') - type = mimetypes.guess_type(fn)[0] - - if os.path.exists(fn): - respond('200 OK', [('Content-Type', type)]) - return util.FileWrapper(open(fn, "rb")) - else: - respond('404 Not Found', [('Content-Type', 'text/plain')]) - return [b'not found'] - -if __name__ == '__main__': - path = sys.argv[1] if len(sys.argv) > 1 else os.getcwd() - port = int(sys.argv[2]) if len(sys.argv) > 2 else 8000 - httpd = simple_server.make_server('', port, app) - print("Serving {} on port {}, control-C to stop".format(path, port)) - try: - httpd.serve_forever() - except KeyboardInterrupt: - print("Shutting down.") - httpd.server_close() |