mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Windows doesn't have `python3.exe` as part of the python.org distribution, and
  that broke every script with a shebang after c102b704edb5 
<https://phab.mercurial-scm.org/rHGc102b704edb5191ed15ed4b02b625a888b8be816>.  
Windows itself
  provides a `python3.exe` app execution alias[1], but it is some sort of 
reparse
  point that MSYS is incapable of handling[2].  When run by MSYS, it simply 
prints
  
    $ python3 -V
     - Cannot open
  
  That in turn caused every `hghave` check, and test that invokes shebang 
scripts
  directly, to fail.  Rather than try to patch up every script call to be 
invoked
  with `$PYTHON` (and regress when non Windows developers forget), copying the
  executable into the test binary directory with the new name just works.  Since
  this directory is prepended to the system PATH value, it also overrides the
  broken execution alias.  (The `_tmpbindir` is used instead of `_bindir` 
because
  the latter causes python3.exe to be copied into the repo next to hg.exe when
  `test-run-tests.t` runs.  Something runs with this version of the executable 
and
  subsequent runs of `run-tests.py` inside `test-run-tests.t` try to copy over 
it
  while it is in use, and fail.  This avoids the failures and the clutter.)
  
  I didn't conditionalize this on py3 because `python3.exe` needs to be present
  (for the shebangs) even when running py2 tests.  It shouldn't matter to these
  simple scripts, and I think the intention is to make the test runner use py3
  always, even if testing a py2 build.  For now, still supporting py2 is helping
  to clean up the mess that is py3 tests.
  
  [1] https://stackoverflow.com/a/57168165
  [2] 
https://stackoverflow.com/questions/59148628/solved-unable-to-run-python-3-7-on-windows-10-permission-denied#comment104524397_59148666

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -3466,6 +3466,16 @@
                     if err.errno != errno.EEXIST:
                         raise
         else:
+            # Windows doesn't have `python3.exe`, and MSYS cannot understand 
the
+            # reparse point with that name provided by Microsoft.  Copy the
+            # current interpreter to PATH with that name so the shebang lines
+            # work.
+            if os.getenv('MSYSTEM'):
+                shutil.copy(
+                    sys.executable,
+                    _bytes2sys(self._tmpbindir + b'/python3.exe'),
+                )
+
             exedir, exename = os.path.split(sysexecutable)
             vlog(
                 "# Modifying search path to find %s as %s in '%s'"



To: mharbison72, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to