annotate roundup/dist/command/build_doc.py @ 6739:00fe67eb8a91

Update locations templates and locale files are stored Installing on a new ubuntu 22.04 venv at /tmp/roundup, I found the locale and template files installed under /tmp/roundup2/lib/python3.10/site-packages/usr/local/share which was unexpected. /tmp/roundup2/lib/python3.10/site-packages/tmp/roundup2/share would be expected. Why sys.prefix (/tmp/roundup2) was not being used but sys.base_prefix (/usr) and 'local' were added in I have no idea. In any case, updated admin and i18n code to find the files in this location. Suggested building a venv for installation with commands in installation.txt. Removed search for templates top level directory. Was used for the old location of the tracker templates pre-2009 when they were moved under share/roundup/templates. left print statemts for debugging directory search in admin templates. They are disabled by a variable set to False. At some point will add pragma's to admin to set debugging and other options see issue 2551103.
author John Rouillard <rouilj@ieee.org>
date Tue, 28 Jun 2022 23:16:47 -0400
parents 42bf0a707763
children 4ff18b1cd9bf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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)

Roundup Issue Tracker: http://roundup-tracker.org/