Skip to content

Commit c7089cb

Browse files
authored
Merge pull request #36 from Holzhaus/python-flags-passthrough
Python flags passthrough
2 parents 7109646 + a36ce1c commit c7089cb

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,6 @@ before_script:
9191
script:
9292
- mkdir html
9393
- git fetch --all
94-
- sphinx-multiversion -W docs html
94+
- python -I -m sphinx_multiversion -W docs html
9595
- python setup.py build sdist bdist_wheel
9696

docs/changelog.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Version 0.2.4 (unreleased)
1515
* Fix bug in the sphinx extension which tried to load the `conf.py` from the source directory instead of the conf directory. This could lead to problems when the two directories differ. (`#11 <issue11_>`_, `#13 <issue13_>`_)
1616
* Fix wrong import in :file:`__main__.py` that prevented invocation using ``python -m sphinx_multiversion``. (`#23 <issue23_>`_)
1717
* Fix failure to find refs if ``sphinx-multiversion`` was not invoked from the root of the git repository. (`#24 <issue24_>`_, `#25 <issue25_>`_, `#26 <issue26_>`_)
18-
* Resolve issues with Sphinx extensions and Python modules not being reloaded when parsing the different :file:`conf.py` files. Now, each config file is parsed in it's own process, and the build is performed using the ``subprocess`` module instead of doing it all from the context of the main module. (`#22 <issue22_>`_, `#28 <issue28_>`_, `#30 <issue30_>`_)
18+
* Resolve issues with Sphinx extensions and Python modules not being reloaded when parsing the different :file:`conf.py` files. Now, each config file is parsed in it's own process, and the build is performed using the ``subprocess`` module instead of doing it all from the context of the main module. Python's `interpreter flags <pythonflags_>`_ (e.g. isolated mode) are passed through to the subprocesses. (`#22 <issue22_>`_, `#28 <issue28_>`_, `#30 <issue30_>`_, `#36 <issue36_>`_)
1919
* Rewrite the path handling of the Sphinx extension to handle branch names containing a forward slash properly on Windows and add unittests and Windows CI builds to make sure it doesn't break on future updates. (`#31 <issue31_>`_, `#35 <issue35_>`_)
2020

2121

@@ -77,3 +77,5 @@ Version 0.1.0
7777
.. _issue30: https://github.com/Holzhaus/sphinx-multiversion/issues/30
7878
.. _issue31: https://github.com/Holzhaus/sphinx-multiversion/issues/31
7979
.. _issue35: https://github.com/Holzhaus/sphinx-multiversion/issues/35
80+
.. _issue36: https://github.com/Holzhaus/sphinx-multiversion/issues/36
81+
.. _pythonflags: https://docs.python.org/3/using/cmdline.html#miscellaneous-options

sphinx_multiversion/main.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,36 @@ def load_sphinx_config(confpath, confoverrides, add_defaults=False):
8989
return result
9090

9191

92+
def get_python_flags():
93+
if sys.flags.bytes_warning:
94+
yield "-b"
95+
if sys.flags.debug:
96+
yield "-d"
97+
if sys.flags.hash_randomization:
98+
yield "-R"
99+
if sys.flags.ignore_environment:
100+
yield "-E"
101+
if sys.flags.inspect:
102+
yield "-i"
103+
if sys.flags.isolated:
104+
yield "-I"
105+
if sys.flags.no_site:
106+
yield "-S"
107+
if sys.flags.no_user_site:
108+
yield "-s"
109+
if sys.flags.optimize:
110+
yield "-O"
111+
if sys.flags.quiet:
112+
yield "-q"
113+
if sys.flags.verbose:
114+
yield "-v"
115+
for option, value in sys._xoptions.items():
116+
if value is True:
117+
yield from ("-X", option)
118+
else:
119+
yield from ("-X", "{}={}".format(option, value))
120+
121+
92122
def main(argv=None):
93123
if not argv:
94124
argv = sys.argv[1:]
@@ -297,7 +327,13 @@ def main(argv=None):
297327
]
298328
)
299329
logger.debug("Running sphinx-build with args: %r", current_argv)
300-
cmd = (sys.executable, "-m", "sphinx", *current_argv)
330+
cmd = (
331+
sys.executable,
332+
*get_python_flags(),
333+
"-m",
334+
"sphinx",
335+
*current_argv,
336+
)
301337
current_cwd = os.path.join(data["basedir"], cwd_relative)
302338
subprocess.check_call(cmd, cwd=current_cwd)
303339

0 commit comments

Comments
 (0)