tpm2-software / tpm2-pytss

Python bindings for TSS
https://tpm2-pytss.readthedocs.io/en/latest/
BSD 2-Clause "Simplified" License
65 stars 45 forks source link

Replace deprecated easy_install; aka install not working on Ubuntu 22.04 #361

Open AndreasFuchsTPM opened 2 years ago

AndreasFuchsTPM commented 2 years ago

pip install is not working on Ubuntu 22.04

Apparently, easy_install is deprecated, but also broken on Ubuntu 22.04; see https://github.com/pypa/setuptools/issues/2938

So of course, Ubuntu should update setuptools but since easy_install is deprecated anyways, maybe pytss could update instead ?

Here is the error log

$ python3 -m pip install --user -e .
Obtaining file:///.../tpm2-pytss                                                                                                                                                               Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: cffi>=1.0.0 in /.../lib/python3.10/site-packages (from tpm2-pytss==1.2.0) (1.15.0)
Requirement already satisfied: pyyaml in /.../lib/python3/dist-packages (from tpm2-pytss==1.2.0) (5.4.1)
Requirement already satisfied: asn1crypto in /.../lib/python3.10/site-packages (from tpm2-pytss==1.2.0) (1.5.1)
Requirement already satisfied: cryptography>=3.0 in /.../lib/python3/dist-packages (from tpm2-pytss==1.2.0) (3.4.8)
Requirement already satisfied: packaging in /.../lib/python3.10/site-packages (from tpm2-pytss==1.2.0) (21.3)
Requirement already satisfied: pycparser in /.../lib/python3.10/site-packages (from cffi>=1.0.0->tpm2-pytss==1.2.0) (2.21)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /.../lib/python3/dist-packages (from packaging->tpm2-pytss==1.2.0) (2.4.7)
Installing collected packages: tpm2-pytss                                                                                                                                                                            Running setup.py develop for tpm2-pytss
    error: subprocess-exited-with-error

    × python setup.py develop did not run successfully.
    │ exit code: 1
    ╰─> [30 lines of output]
        adding path: /.../tpm2-pytss/scripts
        running develop
        /.../lib/python3/dist-packages/setuptools/command/easy_install.py:158: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
          warnings.warn(
        Traceback (most recent call last):
          File "<string>", line 2, in <module>
          File "<pip-setuptools-caller>", line 34, in <module>
          File "/.../tpm2-pytss/setup.py", line 237, in <module>
            setup(
          File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 153, in setup
            return distutils.core.setup(**attrs)
          File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 148, in setup
            return run_commands(dist)
          File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 163, in run_commands
            dist.run_commands()                                                                                                                                                                                              File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 967, in run_commands
            self.run_command(cmd)                                                                                                                                                                                            File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 985, in run_command
            cmd_obj.ensure_finalized()                                                                                                                                                                                       File "/usr/lib/python3/dist-packages/setuptools/_distutils/cmd.py", line 107, in ensure_finalized
            self.finalize_options()
          File "/usr/lib/python3/dist-packages/setuptools/command/develop.py", line 52, in finalize_options
            easy_install.finalize_options(self)
          File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 270, in finalize_options
            self._fix_install_dir_for_user_site()                                                                                                                                                                         File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 400, in _fix_install_dir_for_user_site                                                                                                self.select_scheme(scheme_name)                                                                                                                                                                                  File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 741, in select_scheme                                                                                                                 scheme = INSTALL_SCHEMES[name]
        KeyError: 'unix_user'
        [end of output]

    note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error                                                                                                                                                                                
× python setup.py develop did not run successfully.                                                                                                                                                                │ exit code: 1                                                                                                                                                                                                     ╰─> [30 lines of output]                                                                                                                                                                                               adding path: /.../tpm2-pytss/scripts                                                                                                                                                         running develop                                                                                                                                                                                                    /usr/lib/python3/dist-packages/setuptools/command/easy_install.py:158: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.                         warnings.warn(
    Traceback (most recent call last):
      File "<string>", line 2, in <module>
      File "<pip-setuptools-caller>", line 34, in <module>
      File "/.../tpm2-pytss/setup.py", line 237, in <module>
        setup(
      File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 153, in setup
        return distutils.core.setup(**attrs)
      File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 148, in setup                                                                                                                              return run_commands(dist)
      File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 163, in run_commands
        dist.run_commands()
      File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 967, in run_commands
        self.run_command(cmd)
      File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 985, in run_command
        cmd_obj.ensure_finalized()
      File "/usr/lib/python3/dist-packages/setuptools/_distutils/cmd.py", line 107, in ensure_finalized
        self.finalize_options()
      File "/usr/lib/python3/dist-packages/setuptools/command/develop.py", line 52, in finalize_options
        easy_install.finalize_options(self)
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 270, in finalize_options                                                                                                              self._fix_install_dir_for_user_site()
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 400, in _fix_install_dir_for_user_site                                                                                                self.select_scheme(scheme_name)
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 741, in select_scheme                                                                                                                 scheme = INSTALL_SCHEMES[name]                                                                                                                                                                                 KeyError: 'unix_user'
    [end of output]                                                                                                                                                                                                
note: This error originates from a subprocess, and is likely not a problem with pip.
whooo commented 2 years ago

As it's internal to setuptools it's hard to replace, there seems to be a PEP-660 implementation in the main branch now ( https://github.com/pypa/setuptools/pull/3265 ) which we could test when there is a release with it included.

williamcroberts commented 2 years ago

We don't use easy_install components AFAICT so I don't think theirs anything to fix for us

AndreasFuchsTPM commented 2 years ago

Hmmm... So setuptools is just broken...

In any case; Ubuntu 22.04 pip --user install fails. Workaround was a venv. (As with everything)

Maybe this helps someone, until ubuntu's setuptools is fixed...