ekalinin / nodeenv

Virtual environment for Node.js & integrator with virtualenv
http://ekalinin.github.io/nodeenv/
Other
1.7k stars 211 forks source link

Issue with os.uname() machine identifier text case #369

Open ChrisHughesLogi opened 2 weeks ago

ChrisHughesLogi commented 2 weeks ago

Trying to install nodeenv==1.9.1 and running into the following issue on an aarch64 Surface CoPilot PC:

    * Install prebuilt node (22.9.0)
    Traceback (most recent call last):
      File "<frozen runpy>", line 198, in _run_module_as_main
      File "<frozen runpy>", line 88, in _run_code
      File ".venv\Lib\site-packages\nodeenv.py", line 1548, in <module>
        main()
      File ".venv\Lib\site-packages\nodeenv.py", line 1130, in main
        create_environment(env_dir, args)
      File ".venv\Lib\site-packages\nodeenv.py", line 1006, in create_environment
        install_node(env_dir, src_dir, args)
      File ".venv\Lib\site-packages\nodeenv.py", line 763, in install_node
        install_node_wrapped(env_dir, src_dir, args)
      File ".venv\Lib\site-packages\nodeenv.py", line 779, in install_node_wrapped
        node_url = get_node_bin_url(args.node)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File ".venv\Lib\site-packages\nodeenv.py", line 570, in get_node_bin_url
        'arch': archmap[platform.machine()],
                ~~~~~~~^^^^^^^^^^^^^^^^^^^^
    KeyError: 'ARM64'

It appears as if archmap[platform.machine()] is the culprit here, as the list of architectures defined here assumes all lower-case. I would suggest converting the value of platform.machine() to lowercase before looking up in archmap.

abhikdps commented 2 days ago

I am getting a similar error on Ubuntu 24.04 while running pre-commit but with a different key aarch64


[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/usr/bin/python3', '-mnodeenv', '--prebuilt', '--clean-src', '/home/abanand/.cache/pre-commit/repo4cqrh9kz/node_env-default')
return code: 1
stdout: (none)
stderr:
    /usr/lib/python3/dist-packages/nodeenv.py:24: DeprecationWarning: 'pipes' is deprecated and slated for removal in Python 3.13
      import pipes
    /usr/lib/python3/dist-packages/nodeenv.py:37: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
      from pkg_resources import parse_version
     * Install node (23.0.0Traceback (most recent call last):
      File "<frozen runpy>", line 198, in _run_module_as_main
      File "<frozen runpy>", line 88, in _run_code
      File "/usr/lib/python3/dist-packages/nodeenv.py", line 1042, in <module>
        main()
      File "/usr/lib/python3/dist-packages/nodeenv.py", line 890, in main
        create_environment(env_dir, opt)
      File "/usr/lib/python3/dist-packages/nodeenv.py", line 731, in create_environment
        install_node(env_dir, src_dir, opt)
      File "/usr/lib/python3/dist-packages/nodeenv.py", line 594, in install_node
        node_url = get_node_src_url(opt.node, get_node_src_url_postfix(opt))
                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3/dist-packages/nodeenv.py", line 503, in get_node_src_url_postfix
        postfix_arch = arches[platform.machine()]
                       ~~~~~~^^^^^^^^^^^^^^^^^^^^
    KeyError: 'aarch64'
Check the log at /home/abanand/.cache/pre-commit/pre-commit.log```
ssbarnea commented 2 days ago

A hint here for pre-commit users, install pre-commit>=4.0.0 to avoid this error as it requires newer nodeenv. Still the bugfix proposed is still needed for a full fix of this problem on all platforms.