Mercurial > p > roundup > code
annotate roundup/dist/command/build_doc.py @ 6747:d32d43e4a5ba
wsgi can cache tracker instance enabled by feature flag.
Patch by Marcus Priesch caches a loaded tracker instance and reuse it
for future client sessions.
It is enabled by a feature flag in wsgi.py since it arrived during the
2.2.0 beta period.
The provided wsgi.py is modified to enable it. Testing is run with
flag enabled and disabled.
Ralf Schlatterbeck and Marcus tested it on one of their larger more
complex trackers and it sped up the response time to a client request
by a factor of 3 (270ms down to about 80-85ms).
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sat, 02 Jul 2022 14:04:00 -0400 |
| parents | 42bf0a707763 |
| children | 4ff18b1cd9bf |
| rev | line source |
|---|---|
|
4033
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
1 # |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
2 # Copyright (C) 2009 Stefan Seefeld |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
3 # All rights reserved. |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
4 # For license terms see the file COPYING.txt. |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
5 # |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
6 |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
7 import os, sys |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
8 import os.path |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
9 import glob |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
10 |
|
6647
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
11 try: |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
12 from setuptools.command.install import install as _build_py |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
13 raise ImportError |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
14 except ImportError: |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
15 from distutils.command.build import build as _build_py # try/except clause |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
16 orig_build = _build_py |
|
4033
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
17 |
|
6647
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
18 try: |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
19 # would be nice to use setuptools.Command.spawn() as it |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
20 # obeys the dry-run flag. |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
21 from subprocess import run as spawn |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
22 except ImportError: |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
23 from distutils.spawn import spawn # try/except: in except for subprocess |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
24 |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
25 try: |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
26 from distutils.spawn import find_executable # try/except: in try local find |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
27 except ImportError: |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
28 from roundup.dist.command import find_executable |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
29 |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
30 class build_doc(_build_py): |
|
4033
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
31 """Defines the specific procedure to build roundup's documentation.""" |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
32 |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
33 description = "build documentation" |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
34 |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
35 def run(self): |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
36 """Run this command, i.e. do the actual document generation.""" |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
37 |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
38 sphinx = find_executable('sphinx-build') |
|
4810
7b575e1f7368
setup.py build_doc: try Python-installed Sphinx if command
anatoly techtonik <techtonik@gmail.com>
parents:
4033
diff
changeset
|
39 if sphinx: |
|
7b575e1f7368
setup.py build_doc: try Python-installed Sphinx if command
anatoly techtonik <techtonik@gmail.com>
parents:
4033
diff
changeset
|
40 sphinx = [sphinx] |
|
7b575e1f7368
setup.py build_doc: try Python-installed Sphinx if command
anatoly techtonik <techtonik@gmail.com>
parents:
4033
diff
changeset
|
41 else: |
|
7b575e1f7368
setup.py build_doc: try Python-installed Sphinx if command
anatoly techtonik <techtonik@gmail.com>
parents:
4033
diff
changeset
|
42 try: # try to find version installed with Python tools |
|
7b575e1f7368
setup.py build_doc: try Python-installed Sphinx if command
anatoly techtonik <techtonik@gmail.com>
parents:
4033
diff
changeset
|
43 # tested with Sphinx 1.1.3 |
|
7b575e1f7368
setup.py build_doc: try Python-installed Sphinx if command
anatoly techtonik <techtonik@gmail.com>
parents:
4033
diff
changeset
|
44 import sphinx as sp |
|
7b575e1f7368
setup.py build_doc: try Python-installed Sphinx if command
anatoly techtonik <techtonik@gmail.com>
parents:
4033
diff
changeset
|
45 except ImportError: |
|
7b575e1f7368
setup.py build_doc: try Python-installed Sphinx if command
anatoly techtonik <techtonik@gmail.com>
parents:
4033
diff
changeset
|
46 pass |
|
7b575e1f7368
setup.py build_doc: try Python-installed Sphinx if command
anatoly techtonik <techtonik@gmail.com>
parents:
4033
diff
changeset
|
47 else: |
|
7b575e1f7368
setup.py build_doc: try Python-installed Sphinx if command
anatoly techtonik <techtonik@gmail.com>
parents:
4033
diff
changeset
|
48 sphinx = [sys.executable, sp.__file__] |
|
7b575e1f7368
setup.py build_doc: try Python-installed Sphinx if command
anatoly techtonik <techtonik@gmail.com>
parents:
4033
diff
changeset
|
49 |
|
4033
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
50 if not sphinx: |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
51 self.warn("could not find sphinx-build in PATH") |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
52 self.warn("cannot build documentation") |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
53 return |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
54 |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
55 doc_dir = os.path.join('share', 'doc', 'roundup', 'html') |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
56 temp_dir = os.path.join(self.build_temp, 'doc') |
|
4810
7b575e1f7368
setup.py build_doc: try Python-installed Sphinx if command
anatoly techtonik <techtonik@gmail.com>
parents:
4033
diff
changeset
|
57 cmd = sphinx + ['-d', temp_dir, 'doc', doc_dir] |
|
4033
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
58 spawn(cmd) |
