[BUG] "pyarmor reg" command fails with "No module named 'pyarmor.cli.core.darwin.aarch64'"
Hello. I'm trying to force pyarmor to work on a Mac M1 machine. The license file registration fails with the error ""No module named 'pyarmor.cli.core.darwin.aarch64'"". I've tried to install it using "pip install pyarmor.cli.core.darwin.aarch64" but there is no such package in PyPI. According to the documentation Python 3.11 should work on Apple arm64 if pyarmor >8 as I understand. https://pyarmor.readthedocs.io/en/latest/reference/environments.html#supported-python-versions
Output of "pip list":
Package Version
----------------------- -------
cffi 1.16.0
cryptography 37.0.4
httplib2 0.20.4
pip 23.2.1
psutil 5.9.1
pyaml 23.9.7
pyarmor 8.4.6
pyarmor.cli.core 5.4.3
pyarmor.cli.core.darwin 5.4.3
pycparser 2.21
pyparsing 3.1.1
PyYAML 6.0.1
setuptools 65.5.0
six 1.16.0
wheel 0.41.3
Output of "pyarmor -d reg ../pyarmor-license/pyarmor-regfile-4363.zip":
INFO Python 3.11.5
INFO Pyarmor 8.4.6 (trial), 000000, non-profits
INFO Platform darwin.aarch64
DEBUG native platform darwin.arm64
DEBUG home path: /Users/m1/.pyarmor
INFO register "../pyarmor-license/pyarmor-regfile-4363.zip"
DEBUG extracting license.lic
DEBUG extracting .pyarmor_capsule.zip
INFO update license token
DEBUG unknown error, please check pyarmor.error.log
ERROR No module named 'pyarmor.cli.core.darwin.aarch64'
Output of "cat pyarmor.error.log":
75194 MainProcess 2024-01-22 06:50:32,036
Traceback (most recent call last):
File "/Users/m1/.pyenv/versions/3.11.5/lib/python3.11/site-packages/pyarmor/cli/core/__init__.py", line 75, in _import_pytransform3
return __import__(
^^^^^^^^^^^
ModuleNotFoundError: No module named 'pyarmor.cli.core.pytransform3'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/m1/.pyenv/versions/3.11.5/lib/python3.11/site-packages/pyarmor/cli/__main__.py", line 718, in main
main_entry(sys.argv[1:])
File "/Users/m1/.pyenv/versions/3.11.5/lib/python3.11/site-packages/pyarmor/cli/__main__.py", line 706, in main_entry
return args.func(ctx, args)
^^^^^^^^^^^^^^^^^^^^
File "/Users/m1/.pyenv/versions/3.11.5/lib/python3.11/site-packages/pyarmor/cli/__main__.py", line 305, in cmd_reg
reg.register_regfile(regfile)
File "/Users/m1/.pyenv/versions/3.11.5/lib/python3.11/site-packages/pyarmor/cli/register.py", line 210, in register_regfile
self.update_token()
File "/Users/m1/.pyenv/versions/3.11.5/lib/python3.11/site-packages/pyarmor/cli/register.py", line 117, in update_token
Pytransform3.init(self.ctx)
File "/Users/m1/.pyenv/versions/3.11.5/lib/python3.11/site-packages/pyarmor/cli/core/__init__.py", line 95, in init
Pytransform3._pytransform3 = m = _import_pytransform3()
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/m1/.pyenv/versions/3.11.5/lib/python3.11/site-packages/pyarmor/cli/core/__init__.py", line 82, in _import_pytransform3
return __import__(
^^^^^^^^^^^
ModuleNotFoundError: No module named 'pyarmor.cli.core.darwin.aarch64'
It should install this https://files.pythonhosted.org/packages/3b/ef/7949e43ee5ce3ff16df9e8a336944a78171a8aec8a019d835e933d9ba858/pyarmor.cli.core-5.4.3-cp311-none-macosx_11_0_arm64.whl
This is a patch for this issue
--- a/pyarmor/cli/core/__init__.py
+++ b/pyarmor/cli/core/__init__.py
@@ -67,6 +67,9 @@ def format_platform():
bitness = calcsize('P'.encode()) * 8
if bitness == 32:
mach = 'x86'
+ elif plat == 'darwin' and mach == 'aarch64':
+ mach = 'arm64'
+
return plat, mach
But I'm wonder why pip doesn't install wheel pyarmor.cli.core-5.4.3-cp311-none-macosx_11_0_arm64.whl in Apple M1
After applying this fix, the error below appeared.
pyarmor -d reg ../pyarmor-license/pyarmor-regfile-4363.zip
INFO Python 3.11.5
INFO Pyarmor 8.4.6 (basic), 004363, Lightrun
INFO Platform darwin.aarch64
DEBUG native platform darwin.arm64
DEBUG home path: /Users/m1/.pyarmor
INFO register "../pyarmor-license/pyarmor-regfile-4363.zip"
DEBUG extracting license.lic
DEBUG extracting .pyarmor_capsule.zip
INFO update license token
DEBUG unknown error, please check pyarmor.error.log
ERROR request license token failed (3): <h1>Server Error (500)</h1>
cat pyarmor.error.log
35260 MainProcess 2024-01-23 06:58:10,677
Traceback (most recent call last):
File "/Users/m1/.pyenv/versions/3.11.5/lib/python3.11/site-packages/pyarmor/cli/__main__.py", line 718, in main
main_entry(sys.argv[1:])
File "/Users/m1/.pyenv/versions/3.11.5/lib/python3.11/site-packages/pyarmor/cli/__main__.py", line 706, in main_entry
return args.func(ctx, args)
^^^^^^^^^^^^^^^^^^^^
File "/Users/m1/.pyenv/versions/3.11.5/lib/python3.11/site-packages/pyarmor/cli/__main__.py", line 305, in cmd_reg
reg.register_regfile(regfile)
File "/Users/m1/.pyenv/versions/3.11.5/lib/python3.11/site-packages/pyarmor/cli/register.py", line 210, in register_regfile
self.update_token()
File "/Users/m1/.pyenv/versions/3.11.5/lib/python3.11/site-packages/pyarmor/cli/register.py", line 117, in update_token
Pytransform3.init(self.ctx)
File "/Users/m1/.pyenv/versions/3.11.5/lib/python3.11/site-packages/pyarmor/cli/core/__init__.py", line 99, in init
m.init_ctx(ctx)
RuntimeError: request license token failed (3): <h1>Server Error (500)</h1>
Too many requests to license server in one minute, try it later.
Fixed in v8.5.0