diff --git a/docs/changelog/bugfix.2271.rst b/docs/changelog/bugfix.2271.rst new file mode 100644 index 000000000..89c0410c6 --- /dev/null +++ b/docs/changelog/bugfix.2271.rst @@ -0,0 +1,2 @@ +Fix ``PermissionError: [Errno 1] Operation not permitted`` when creating a +Python 2.x virtualenv on macOS/arm64 - by ``moreati`` 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 84549f7e6..d191bf09c 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 @@ -136,7 +136,7 @@ def fix_signature(self): bak_dir.mkdir(parents=True, exist_ok=True) subprocess.check_call(["cp", exe, bak_dir]) subprocess.check_call(["mv", bak_dir / exe.name, exe]) - bak_dir.unlink() + bak_dir.rmdir() cmd = ["codesign", "-s", "-", "--preserve-metadata=identifier,entitlements,flags,runtime", "-f", exe] logging.debug("Changing Signature: %s", cmd) subprocess.check_call(cmd)