forked from openTdataCH/netexRealisationGuideSwitzerland
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
41 lines (30 loc) · 1.15 KB
/
setup.py
File metadata and controls
41 lines (30 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# setup.py - tiny hook to build docs into ./site)
import os
import subprocess
import sys
from setuptools import setup, Command
from setuptools.command.sdist import sdist as _sdist
class build_docs(Command):
description = "Build project documentation."
user_options = [
("clean", None, "clean the output directory before building"),
]
def initialize_options(self):
self.clean = False
def finalize_options(self):
self.clean = bool(self.clean)
def run(self):
cmd = [sys.executable, "-m", "tools.toolchain", "--target", "docs"]
self.announce(f"Running: {' '.join(cmd)}", level=2)
# Build environment variables to pass context
env = dict(os.environ)
env.setdefault("PYTHONHASHSEED", "0")
subprocess.check_call(cmd, env=env) # fails the build on nonzero exit
self.announce(f"Docs generated.", level=2)
class sdist(_sdist):
def run(self):
# Build docs before sdist (writes to ./site but we will exclude it from sdist)
self.run_command("build_docs")
super().run()
cmdclass = {"build_docs": build_docs, "sdist": sdist}
setup(cmdclass=cmdclass)