diff --git a/docs/changelog/2282.bugfix.rst b/docs/changelog/2282.bugfix.rst new file mode 100644 index 000000000..0a9846d56 --- /dev/null +++ b/docs/changelog/2282.bugfix.rst @@ -0,0 +1 @@ +fix "execv() arg 2 must contain only strings" error on M1 MacOS diff --git a/src/virtualenv/create/via_global_ref/builtin/cpython/mac_os.py b/src/virtualenv/create/via_global_ref/builtin/cpython/mac_os.py index d5f246374..6024c97d1 100644 --- a/src/virtualenv/create/via_global_ref/builtin/cpython/mac_os.py +++ b/src/virtualenv/create/via_global_ref/builtin/cpython/mac_os.py @@ -7,7 +7,7 @@ from abc import ABCMeta, abstractmethod from textwrap import dedent -from six import add_metaclass +from six import add_metaclass, text_type from virtualenv.create.via_global_ref.builtin.ref import ExePathRefToDest, PathRefToDest, RefMust from virtualenv.info import IS_MAC_ARM64 @@ -134,10 +134,11 @@ def fix_signature(self): # Reset the signing on Darwin since the exe has been modified. # Note codesign fails on the original exe, it needs to be copied and moved back. bak_dir.mkdir(parents=True, exist_ok=True) - subprocess.check_call(["cp", exe, bak_dir]) - subprocess.check_call(["mv", bak_dir / exe.name, exe]) + subprocess.check_call(["cp", text_type(exe), text_type(bak_dir)]) + subprocess.check_call(["mv", text_type(bak_dir / exe.name), text_type(exe)]) bak_dir.rmdir() - cmd = ["codesign", "-s", "-", "--preserve-metadata=identifier,entitlements,flags,runtime", "-f", exe] + metadata = "--preserve-metadata=identifier,entitlements,flags,runtime" + cmd = ["codesign", "-s", "-", metadata, "-f", text_type(exe)] logging.debug("Changing Signature: %s", cmd) subprocess.check_call(cmd) except Exception: