Patchwork D10301: setup: copy python3.dll next to hg.exe when building on Windows for hgext.git

login
register
mail settings
Submitter phabricator
Date April 4, 2021, 3:12 a.m.
Message ID <differential-rev-PHID-DREV-62qy2ny3woubiv3zq2r2-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48618/
State Superseded
Headers show

Comments

phabricator - April 4, 2021, 3:12 a.m.
mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I thought I took care of this already, but it must have been that I just
  manually copied the file over locally when debugging why the pygit2 library
  wasn't loading.  The problem with that is what was copied over was from py38,
  and then running a py39 build hard crashed when the extension was loaded.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  setup.py

CHANGE DETAILS




To: mharbison72, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -817,6 +817,22 @@ 
                 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'