[Git][ghc/ghc][master] 2 commits: users-guide: Support both distutils and packaging

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Tue Aug 15 09:44:20 UTC 2023



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
d814bda9 by Ben Gamari at 2023-08-15T05:43:53-04:00
users-guide: Support both distutils and packaging

As noted in #23818, some old distributions (e.g. Debian 9) only include
`distutils` while newer distributions only include `packaging`.

Fixes #23818.

- - - - -
1726db3f by Ben Gamari at 2023-08-15T05:43:53-04:00
users-guide: Ensure extlinks is compatible with Sphinx <4

The semantics of the `extlinks` attribute annoyingly changed in Sphinx
4. Reflect this in our configuration. See #22690.

Fixes #23807.

- - - - -


3 changed files:

- docs/users_guide/flags.py
- docs/users_guide/ghc_config.py.in
- docs/users_guide/utils.py


Changes:

=====================================
docs/users_guide/flags.py
=====================================
@@ -50,8 +50,8 @@ import sphinx
 from sphinx import addnodes
 from sphinx.domains.std import GenericObject
 from sphinx.errors import SphinxError
-from packaging.version import parse
-from utils import build_table_from_list
+
+from utils import build_table_from_list, parse_version
 
 import os.path
 
@@ -628,8 +628,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')


=====================================
docs/users_guide/ghc_config.py.in
=====================================
@@ -1,7 +1,17 @@
-extlinks = {
-    'ghc-ticket': ('https://gitlab.haskell.org/ghc/ghc/issues/%s', '%s'),
-    'ghc-wiki': ('https://gitlab.haskell.org/ghc/ghc/wikis/%s', '#%s'),
-}
+import sphinx
+from utils import parse_version
+
+if parse_version(sphinx.__version__) >= parse_version("4.0.0"):
+    # N.B. see #23807 and #22690
+    extlinks = {
+        'ghc-ticket': ('https://gitlab.haskell.org/ghc/ghc/issues/%s', '#%s'),
+        'ghc-wiki': ('https://gitlab.haskell.org/ghc/ghc/wikis/%s', '%s'),
+    }
+else:
+    extlinks = {
+        'ghc-ticket': ('https://gitlab.haskell.org/ghc/ghc/issues/%s', '#'),
+        'ghc-wiki': ('https://gitlab.haskell.org/ghc/ghc/wikis/%s', ''),
+    }
 
 libs_base_uri = '../libraries'
 


=====================================
docs/users_guide/utils.py
=====================================
@@ -1,5 +1,12 @@
 from docutils import nodes
 
+# N.B. `packaging` is not available in Ubuntu 18.04 or Debian 9
+# See #23818.
+try:
+    from packaging.version import parse as parse_version
+except ImportError as e:
+    from distutils.version import LooseVersion as parse_version
+
 # Taken from Docutils source inside the ListTable class. We must bypass
 # using the class itself, but this function comes in handy.
 def build_table_from_list(table_data, col_widths):



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e194ed2bf4002666664def87aad0c4363a917f4e...1726db3f39f1c41b92b1bdf45e9dc054b401e782

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e194ed2bf4002666664def87aad0c4363a917f4e...1726db3f39f1c41b92b1bdf45e9dc054b401e782
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/20230815/8754cc6f/attachment-0001.html>


More information about the ghc-commits mailing list