[Updated] D11726: backout: backed out changeset f78d8b8c46d7

Alphare (Raphaël Gomès) phabricator at mercurial-scm.org
Thu Nov 4 20:45:59 UTC 2021


Closed by commit rHG2ce31dbde4b1: backout: backed out changeset f78d8b8c46d7 (authored by Alphare).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D11726?vs=31000&id=31026

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D11726/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D11726

AFFECTED FILES
  setup.py

CHANGE DETAILS

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -780,6 +780,9 @@
 
         pythonlib = None
 
+        dir = os.path.dirname(self.get_ext_fullpath('dummy'))
+        self.hgtarget = os.path.join(dir, 'hg')
+
         if getattr(sys, 'dllhandle', None):
             # Different Python installs can have different Python library
             # names. e.g. the official CPython distribution uses pythonXY.dll
@@ -805,6 +808,35 @@
                     )
                 pythonlib = dllbasename[:-4]
 
+                # Copy the pythonXY.dll next to the binary so that it runs
+                # without tampering with PATH.
+                fsdecode = lambda x: x
+                if sys.version_info[0] >= 3:
+                    fsdecode = os.fsdecode
+                dest = os.path.join(
+                    os.path.dirname(self.hgtarget),
+                    fsdecode(dllbasename),
+                )
+
+                if not os.path.exists(dest):
+                    shutil.copy(buf.value, dest)
+
+                # Also overwrite python3.dll so that hgext.git is usable.
+                # TODO: also handle the MSYS flavor
+                if sys.version_info[0] >= 3:
+                    python_x = os.path.join(
+                        os.path.dirname(fsdecode(buf.value)),
+                        "python3.dll",
+                    )
+
+                    if os.path.exists(python_x):
+                        dest = os.path.join(
+                            os.path.dirname(self.hgtarget),
+                            os.path.basename(python_x),
+                        )
+
+                        shutil.copy(python_x, dest)
+
         if not pythonlib:
             log.warn(
                 'could not determine Python DLL filename; assuming pythonXY'
@@ -827,8 +859,6 @@
             output_dir=self.build_temp,
             macros=macros,
         )
-        dir = os.path.dirname(self.get_ext_fullpath('dummy'))
-        self.hgtarget = os.path.join(dir, 'hg')
         self.compiler.link_executable(
             objects, self.hgtarget, libraries=[], output_dir=self.build_temp
         )



To: Alphare, #hg-reviewers, mharbison72
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20211104/5c73a81e/attachment-0001.html>


More information about the Mercurial-patches mailing list