[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 13:01:51 UTC 2023



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


Commits:
291963af by Ben Gamari at 2023-08-09T09:01:45-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.version 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/291963af49a12a05c40d9ed6fd000cba8b15595b

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/291963af49a12a05c40d9ed6fd000cba8b15595b
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/64562bcd/attachment-0001.html>


More information about the ghc-commits mailing list