rust-pyo3: change the name of the Python module to pyo3_rustext
authorGeorges Racinet <georges.racinet@cloudcrane.io>
Fri, 29 Nov 2024 22:59:16 +0100
changeset 52406 c28ba6fb3fae
parent 52405 cf5b47b885b1
child 52407 c5128c541021
rust-pyo3: change the name of the Python module to pyo3_rustext Two reasons for doing so - `pyo3-rustext` is not a valid Python identifier, hence the module could only be imported with `__import__("mercurial.pyo3-rustext")` and then retrieved by getattr. Normal usage is throught `mercurial.policy`. Hovever manual testing for development and perhaps unit tests can benefit a more natural way of doing. - The module's `__name__` attribute was already `pyo3_rustext`. This can lead to some discrepancies, in particular when we introduce submodules.
mercurial/policy.py
setup.py
--- a/mercurial/policy.py	Sat Nov 30 19:12:02 2024 +0100
+++ b/mercurial/policy.py	Fri Nov 29 22:59:16 2024 +0100
@@ -145,7 +145,7 @@
     if not policy.startswith(b'rust'):
         return default
 
-    dlib_name = "pyo3-rustext" if pyo3 else "rustext"
+    dlib_name = "pyo3_rustext" if pyo3 else "rustext"
 
     try:
         mod = _importfrom(dlib_name, modname)
--- a/setup.py	Sat Nov 30 19:12:02 2024 +0100
+++ b/setup.py	Fri Nov 29 22:59:16 2024 +0100
@@ -1663,7 +1663,7 @@
         'librusthg',
     ),
     RustStandaloneExtension(
-        'mercurial.pyo3-rustext',
+        'mercurial.pyo3_rustext',
         'hg-pyo3',
         'librusthgpyo3',
     ),