Nitrokey / pynitrokey

Python client for Nitrokey devices
Apache License 2.0
93 stars 28 forks source link

Error installing pynitrokey w/ Python 3.11 #417

Closed thyrc closed 11 months ago

thyrc commented 12 months ago

I just tried to install pynitrokey, but the installation failed with re.error.

$ pipx install pynitrokey
Fatal error from pip prevented installation. Full pip output in file:
    /home/user/.local/pipx/logs/cmd_2023-07-11_16.25.11_pip_errors.log

pip failed to build package:
    cmsis-pack-manager

Some possibly relevant errors from pip install:
    error: subprocess-exited-with-error
    re.error: global flags not at the start of the expression at position 9

Error installing pynitrokey.

The cmd.log:

   140.5ms (setup:799): 2023-07-11 16:25:11
   140.6ms (setup:800): /home/user/tmp/nitropy/bin/pipx install pynitrokey
   140.7ms (setup:801): pipx version is 1.2.0
   140.7ms (setup:802): Default python interpreter is '/home/user/tmp/nitropy/bin/python'
   142.1ms (package_name_from_spec:322): Determined package name: pynitrokey
   142.2ms (package_name_from_spec:323): Package name determined in 0.0s
   142.7ms (run_subprocess:173): running /home/user/tmp/nitropy/bin/python -m venv --without-pip /home/user/.local/pipx/venvs/pynitrokey
   185.6ms (run_subprocess:186): stdout:
   185.7ms (run_subprocess:188): stderr:
   185.7ms (run_subprocess:189): returncode: 0
   186.1ms (run_subprocess:173): running /home/user/.local/pipx/venvs/pynitrokey/bin/python -c import sysconfig; print(sysconfig.get_path('purelib'))
   207.7ms (run_subprocess:186): stdout: /home/user/.local/pipx/venvs/pynitrokey/lib/python3.11/site-packages
   207.8ms (run_subprocess:189): returncode: 0
   208.2ms (run_subprocess:173): running /home/user/.local/pipx/shared/bin/python -c import sysconfig; print(sysconfig.get_path('purelib'))
   228.4ms (run_subprocess:186): stdout: /home/user/.local/pipx/shared/lib/python3.11/site-packages
   228.4ms (run_subprocess:189): returncode: 0
   228.8ms (run_subprocess:173): running /home/user/.local/pipx/venvs/pynitrokey/bin/python --version
   231.9ms (run_subprocess:186): stdout: Python 3.11.4
   232.0ms (run_subprocess:188): stderr:
   232.0ms (run_subprocess:189): returncode: 0
   232.3ms (_parsed_package_to_package_or_url:147): cleaned package spec: pynitrokey
   232.7ms (run_subprocess:173): running /home/user/.local/pipx/venvs/pynitrokey/bin/python -m pip install pynitrokey
178040.8ms (run_subprocess:189): returncode: 1
178041.0ms (subprocess_post_check_handle_pip_error:335): '/home/user/.local/pipx/venvs/pynitrokey/bin/python -m pip install pynitrokey' failed
178041.3ms (subprocess_post_check_handle_pip_error:352): Fatal error from pip prevented installation. Full pip output in file:
    /home/user/.local/pipx/logs/cmd_2023-07-11_16.25.11_pip_errors.log
178046.2ms (analyze_pip_output:298): pip failed to build package:
    cmsis-pack-manager
178046.5ms (rmdir:55): removing directory /home/user/.local/pipx/venvs/pynitrokey
178047.3ms (cli:866): PipxError: Error installing pynitrokey.
Traceback (most recent call last):
  File "/home/user/tmp/nitropy/lib/python3.11/site-packages/pipx/main.py", line 863, in cli
    return run_pipx_command(parsed_pipx_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/tmp/nitropy/lib/python3.11/site-packages/pipx/main.py", line 214, in run_pipx_command
    return commands.install(
           ^^^^^^^^^^^^^^^^^
  File "/home/user/tmp/nitropy/lib/python3.11/site-packages/pipx/commands/install.py", line 60, in install
    venv.install_package(
  File "/home/user/tmp/nitropy/lib/python3.11/site-packages/pipx/venv.py", line 253, in install_package
    raise PipxError(
pipx.util.PipxError: Error installing pynitrokey.
178055.1ms (cli:874): pipx finished.

The relevant part in the pip_errors.log seems to be:

[...]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-0_jthvp7/cmsis-pack-manager_6832c02299354638bcced6cbfc7574a6/setup.py", line 55, in <module>
          setup(
        File "/home/user/.local/pipx/shared/lib/python3.11/site-packages/setuptools/__init__.py", line 107, in setup
          return distutils.core.setup(**attrs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/user/.local/pipx/shared/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 185, in setup
          return run_commands(dist)
                 ^^^^^^^^^^^^^^^^^^
        File "/home/user/.local/pipx/shared/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
          dist.run_commands()
        File "/home/user/.local/pipx/shared/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
          self.run_command(cmd)
        File "/home/user/.local/pipx/shared/lib/python3.11/site-packages/setuptools/dist.py", line 1234, in run_command
          super().run_command(command)
        File "/home/user/.local/pipx/shared/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/home/user/.local/pipx/shared/lib/python3.11/site-packages/wheel/bdist_wheel.py", line 343, in run
          self.run_command("build")
        File "/home/user/.local/pipx/shared/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
          self.distribution.run_command(command)
        File "/home/user/.local/pipx/shared/lib/python3.11/site-packages/setuptools/dist.py", line 1234, in run_command
          super().run_command(command)
        File "/home/user/.local/pipx/shared/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/home/user/.local/pipx/shared/lib/python3.11/site-packages/setuptools/_distutils/command/build.py", line 131, in run
          self.run_command(cmd_name)
        File "/home/user/.local/pipx/shared/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
          self.distribution.run_command(command)
        File "/home/user/.local/pipx/shared/lib/python3.11/site-packages/setuptools/dist.py", line 1234, in run_command
          super().run_command(command)
        File "/home/user/.local/pipx/shared/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/tmp/pip-install-0_jthvp7/cmsis-pack-manager_6832c02299354638bcced6cbfc7574a6/.eggs/milksnake-0.1.5-py3.11.egg/milksnake/setuptools_ext.py", line 88, in run
          func(base_path=base_path, inplace=False)
        File "/tmp/pip-install-0_jthvp7/cmsis-pack-manager_6832c02299354638bcced6cbfc7574a6/.eggs/milksnake-0.1.5-py3.11.egg/milksnake/setuptools_ext.py", line 276, in build_cffi
          ffi = make_ffi()
                ^^^^^^^^^^
        File "/tmp/pip-install-0_jthvp7/cmsis-pack-manager_6832c02299354638bcced6cbfc7574a6/.eggs/milksnake-0.1.5-py3.11.egg/milksnake/setuptools_ext.py", line 262, in make_ffi
          from milksnake.ffi import make_ffi
        File "/tmp/pip-install-0_jthvp7/cmsis-pack-manager_6832c02299354638bcced6cbfc7574a6/.eggs/milksnake-0.1.5-py3.11.egg/milksnake/ffi.py", line 8, in <module>
          _directive_re = re.compile(r'^\s*#.*?$(?m)')
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/lib/python3.11/re/__init__.py", line 227, in compile
          return _compile(pattern, flags)
                 ^^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/lib/python3.11/re/__init__.py", line 294, in _compile
          p = _compiler.compile(pattern, flags)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/lib/python3.11/re/_compiler.py", line 743, in compile
          p = _parser.parse(p, flags)
              ^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/lib/python3.11/re/_parser.py", line 980, in parse
          p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/lib/python3.11/re/_parser.py", line 455, in _parse_sub
          itemsappend(_parse(source, state, verbose, nested + 1,
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/lib/python3.11/re/_parser.py", line 841, in _parse
          raise source.error('global flags not at the start '
      re.error: global flags not at the start of the expression at position 9
thyrc commented 12 months ago

nitropy requires Python 3.9 or 3.10.

https://docs.nitrokey.com/software/nitropy/all-platforms/installation.html

Sorry, I totally missed that for some reason.

robin-nitrokey commented 12 months ago

Let’s keep this open as we want to support 3.11 at some point (and we actually advertise it in the package metadata). Currently, it looks like this is the blocker: https://github.com/getsentry/milksnake/issues/33

robin-nitrokey commented 11 months ago

This should be fixed with 0.4.39. I was able to install pynitrokey with Python 3.11.4 on Alpine.