[Git][ghc/ghc][wip/backports-9.8] users_guide: Restore compatibility with pre-packaging Python

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Wed Aug 9 06:43:32 UTC 2023



Ben Gamari pushed to branch wip/backports-9.8 at Glasgow Haskell Compiler / GHC


Commits:
25d9baea by Ben Gamari at 2023-08-09T02:43:23-04:00
users_guide: Restore compatibility with pre-packaging Python

The `packaging` package is not available in Ubuntu 18.04 or Debian 9.
Fall back to distutils in this case to avoid incurring an extra
dependency.

- - - - -


1 changed file:

- docs/users_guide/flags.py


Changes:

=====================================
docs/users_guide/flags.py
=====================================
@@ -50,7 +50,12 @@ import sphinx
 from sphinx import addnodes
 from sphinx.domains.std import GenericObject
 from sphinx.errors import SphinxError
-from packaging.version import parse
+try:
+    from packaging.version import parse as parse_version
+except ImportError as e:
+    # N.B. `packaging` is not available in Ubuntu 18.04 or Debian 9
+    from distutils import LooseVersion as parse_version
+
 from utils import build_table_from_list
 
 import os.path
@@ -628,8 +633,8 @@ def purge_flags(app, env, docname):
 
 def setup(app):
     # The override argument to add_directive_to_domain is only supported by >= 1.8
-    sphinx_version = parse(sphinx.__version__)
-    override_arg = {'override': True} if sphinx_version >= parse('1.8') else {}
+    sphinx_version = parse_version(sphinx.__version__)
+    override_arg = {'override': True} if sphinx_version >= parse_version('1.8') else {}
 
     # Add ghc-flag directive, and override the class with our own
     app.add_object_type('ghc-flag', 'ghc-flag')



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/25d9baea3db855d77836ecfd21add1d7990827bc

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/25d9baea3db855d77836ecfd21add1d7990827bc
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230809/24a2262f/attachment-0001.html>


More information about the ghc-commits mailing list