flyingcircusio / appenv

Self-contained bootstrapping/updating of Python applications deployed through shared repositories
BSD 3-Clause "New" or "Revised" License
5 stars 1 forks source link

venv create fails under macOS #40

Closed wosc closed 4 months ago

wosc commented 1 year ago

So, here's a weird one: a) The default values for python -m venv and import venv; venv.create() are not the same. The former uses symlinks=True, but the latter, which is used by batou/appenv, has symlinks=False). b) At least with my brew install python, the variant with symlinks=False has recently(?) stopped working:

$ python3 -m venv venv; venv/bin/python --version; rm -rf venv
Python 3.11.5
$ python3 -c 'import venv; venv.create("venv")'; venv/bin/python --version; rm -rf venv
dyld: Library not loaded: @loader_path/../../../../Python.framework/Versions/3.11/Python
  Referenced from: /Users/schnerring/Downloads/venv/bin/python
  Reason: image not found
fish: Job 1, 'venv/bin/python --version' terminated by signal SIGABRT (Abort)
$ python3 -c 'import venv; venv.create("venv", symlinks=True)'; venv/bin/python --version; rm -rf venv
Python 3.11.5

I don't understand neither (a) nor (b), and the closest related bug I could find was https://github.com/python/cpython/issues/82886 (but that talks about Apple's Python, not Homebrew), so my proposal would be this:

diff --git a/batou b/batou
index e509e153..691d9cca 100755
--- a/batou
+++ b/batou
@@ -69,7 +69,7 @@ def ensure_venv(target):
     version = sys.version.split()[0]
     python_maj_min = ".".join(str(x) for x in sys.version_info[:2])
     print("Creating venv ...")
-    venv.create(target, with_pip=False)
+    venv.create(target, with_pip=False, symlinks=True)
zagy commented 1 year ago

Ohhh … interesting. I ran into this, too! I think this needs to go into appenv now, but I'll take care of it.