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

Error in the installation of tpm2-pytss #572

Closed aitor-garmen closed 5 months ago

aitor-garmen commented 7 months ago

I am trying to install tpm2-pytss, and I get the following error:

aitor@opcuanode:~$ python3 -m pip install tpm2-pytss Defaulting to user installation because normal site-packages is not writeable Collecting tpm2-pytss Using cached tpm2-pytss-2.2.1.tar.gz (208 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing metadata (pyproject.toml) ... error error: subprocess-exited-with-error

× Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [48 lines of output] /tmp/pip-build-env-99_it2dt/overlay/local/lib/python3.10/dist-packages/setuptools_scm/_integration/setuptools.py:30: RuntimeWarning: ERROR: setuptools==59.6.0 is used in combination with setuptools_scm>=8.x

  Your build configuration is incomplete and previously worked by accident!
  setuptools_scm requires setuptools>=61

  Suggested workaround if applicable:
   - migrating from the deprecated setup_requires mechanism to pep517/518
     and using a pyproject.toml to declare build dependencies
     which are reliably pre-installed before running the build tools

    warnings.warn(
  Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
      main()
    File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 164, in prepare_metadata_for_build_wheel
      return hook(metadata_directory, config_settings)
    File "/usr/lib/python3/dist-packages/setuptools/build_meta.py", line 174, in prepare_metadata_for_build_wheel
      self.run_setup()
    File "/usr/lib/python3/dist-packages/setuptools/build_meta.py", line 158, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 285, 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 109, in setup
      _setup_distribution = dist = klass(attrs)
    File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 459, in __init__
      _Distribution.__init__(
    File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 293, in __init__
      self.finalize_options()
    File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 837, in finalize_options
      ep(self)
    File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 858, in _finalize_setup_keywords
      ep.load()(self, ep.name, value)
    File "/tmp/pip-build-env-99_it2dt/normal/local/lib/python3.10/dist-packages/cffi/setuptools_ext.py", line 216, in cffi_modules
      add_cffi_module(dist, cffi_module)
    File "/tmp/pip-build-env-99_it2dt/normal/local/lib/python3.10/dist-packages/cffi/setuptools_ext.py", line 49, in add_cffi_module
      execfile(build_file_name, mod_vars)
    File "/tmp/pip-build-env-99_it2dt/normal/local/lib/python3.10/dist-packages/cffi/setuptools_ext.py", line 25, in execfile
      exec(code, glob, glob)
    File "scripts/libtss2_build.py", line 3, in <module>
      ffibuilder = FFI()
    File "/tmp/pip-build-env-99_it2dt/normal/local/lib/python3.10/dist-packages/cffi/api.py", line 54, in __init__
      raise Exception("Version mismatch: this is the 'cffi' package version %s, located in %r.  When we import the top-level '_cffi_backend' extension module, we get version %s, located in %r.  The two versions should be equal; check your installation." % (
  Exception: Version mismatch: this is the 'cffi' package version 1.16.0, located in '/tmp/pip-build-env-99_it2dt/normal/local/lib/python3.10/dist-packages/cffi/api.py'.  When we import the top-level '_cffi_backend' extension module, we get version 1.15.0, located in '/usr/lib/python3/dist-packages/_cffi_backend.cpython-310-x86_64-linux-gnu.so'.  The two versions should be equal; check your installation.
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed

× Encountered error while generating package metadata. ╰─> See above for output.

note: This is an issue with the package mentioned above, not pip. hint: See above for details.

I have cffi in the lastest version.

j30231 commented 7 months ago

I have to also same problem.

whooo commented 7 months ago

Which Linux distributions are you using?

j30231 commented 7 months ago

I'm using uubuntu 22.04.4 arm64. I'm using it in mac m1 environment, and I installed uubuntu in vm environment through parallells 19. For TPM chip use, I'm using the parallells setting as windows 11.

Ubuntu 22.04.4 LTS (GNU/Linux 5.15.0-105-generic aarch64)

j30231 commented 7 months ago

when i use this option, I solve version issue. : "--no-build-isolation"

$ python3 -m pip install --no-build-isolation -e .

But I have another problem like this.


jaesik@pp:~/tpm2-pytss$ python3 -m pip install --no-build-isolation -e .


Defaulting to user installation because normal site-packages is not writeable
Obtaining file:///home/jaesik/tpm2-pytss
  Checking if build backend supports build_editable ... done
  Preparing editable metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing editable metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [52 lines of output]
      /home/jaesik/.local/lib/python3.10/site-packages/setuptools_scm/_integration/setuptools.py:90: UserWarning: version of None already set
        warnings.warn(f"version of {dist_name} already set")
      adding path: /home/jaesik/tpm2-pytss/scripts
      Traceback (most recent call last):
        File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in 
          main()
        File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 191, in prepare_metadata_for_build_editable
          return hook(metadata_directory, config_settings)
        File "/home/jaesik/.local/lib/python3.10/site-packages/setuptools/build_meta.py", line 453, in prepare_metadata_for_build_editable
          return self.prepare_metadata_for_build_wheel(
        File "/home/jaesik/.local/lib/python3.10/site-packages/setuptools/build_meta.py", line 366, in prepare_metadata_for_build_wheel
          self.run_setup()
        File "/home/jaesik/.local/lib/python3.10/site-packages/setuptools/build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "", line 285, in 
        File "/home/jaesik/.local/lib/python3.10/site-packages/setuptools/__init__.py", line 104, in setup
          return distutils.core.setup(**attrs)
        File "/home/jaesik/.local/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 146, in setup
          _setup_distribution = dist = klass(attrs)
        File "/home/jaesik/.local/lib/python3.10/site-packages/setuptools/dist.py", line 307, in __init__
          _Distribution.__init__(self, dist_attrs)
        File "/home/jaesik/.local/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 284, in __init__
          self.finalize_options()
        File "/home/jaesik/.local/lib/python3.10/site-packages/setuptools/dist.py", line 658, in finalize_options
          ep(self)
        File "/home/jaesik/.local/lib/python3.10/site-packages/setuptools/dist.py", line 678, in _finalize_setup_keywords
          ep.load()(self, ep.name, value)
        File "/home/jaesik/.local/lib/python3.10/site-packages/cffi/setuptools_ext.py", line 216, in cffi_modules
          add_cffi_module(dist, cffi_module)
        File "/home/jaesik/.local/lib/python3.10/site-packages/cffi/setuptools_ext.py", line 49, in add_cffi_module
          execfile(build_file_name, mod_vars)
        File "/home/jaesik/.local/lib/python3.10/site-packages/cffi/setuptools_ext.py", line 25, in execfile
          exec(code, glob, glob)
        File "scripts/libtss2_build.py", line 69, in 
          ffibuilder.cdef(open("libesys.h").read())
        File "/home/jaesik/.local/lib/python3.10/site-packages/cffi/api.py", line 112, in cdef
          self._cdef(csource, override=override, packed=packed, pack=pack)
        File "/home/jaesik/.local/lib/python3.10/site-packages/cffi/api.py", line 126, in _cdef
          self._parser.parse(csource, override=override, **options)
        File "/home/jaesik/.local/lib/python3.10/site-packages/cffi/cparser.py", line 389, in parse
          self._internal_parse(csource)
        File "/home/jaesik/.local/lib/python3.10/site-packages/cffi/cparser.py", line 396, in _internal_parse
          self._process_macros(macros)
        File "/home/jaesik/.local/lib/python3.10/site-packages/cffi/cparser.py", line 479, in _process_macros
          raise CDefError(
      cffi.CDefError: only supports one of the following syntax:
        #define TPM2_HR_PCR ...     (literally dot-dot-dot)
        #define TPM2_HR_PCR NUMBER  (with NUMBER an integer constant, decimal/hex/octal)
      got:
        #define TPM2_HR_PCR ...<< TPM2_HR_SHIFT)
      [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed

× Encountered error while generating package metadata. ╰─> See above for output.

note: This is an issue with the package mentioned above, not pip. hint: See above for details.


and I tried to fix the cffi error grammar by modifying the libsys.h file, but it also failed. Even if I modify the libsys.h file, the fix does not apply.

whooo commented 7 months ago

Check if you have the package python3-cffi installed, and install it if it's not installed to see if that helps

baloo commented 7 months ago

this seems to be triggered by an upgrade of tpm2-tss from 4.0.1 to 4.1.0.

https://github.com/NixOS/nixpkgs/pull/307100

EDIT: https://github.com/tpm2-software/tpm2-pytss/pull/571/commits/b02fdc8e259fe977c1065389c042be69e2985bdf appears to fix the #define TPM2_HR_PCR error

j30231 commented 7 months ago

Check if you have the package python3-cffi installed, and install it if it's not installed to see if that helps

Yes, I installed the cffi package and still get an error, the error is as follows,

jj@tpm:~$ pip install tpm2-pytss
Collecting tpm2-pytss
Using cached tpm2-pytss-2.2.1.tar.gz (208 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing wheel metadata ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 /tmp/tmpkagdkub1 prepare_metadata_for_build_wheel /tmp/tmp0dfx61fb
cwd: /tmp/pip-install-l3uxflgc/tpm2-pytss
Complete output (50 lines):
/tmp/pip-build-env-oqycbzb6/overlay/lib/python3.8/site-packages/setuptools_scm/_integration/setuptools.py:90: UserWarning: version of None already set
warnings.warn(f"version of {dist_name} already set")
adding path: /tmp/pip-install-l3uxflgc/tpm2-pytss/scripts
Traceback (most recent call last):
File "/tmp/tmpkagdkub1", line 280, in 
main()
File "/tmp/tmpkagdkub1", line 263, in main
json_out['return_val'] = hook(hook_input['kwargs'])
File "/tmp/tmpkagdkub1", line 133, in prepare_metadata_for_build_wheel
return hook(metadata_directory, config_settings)
File "/tmp/pip-build-env-oqycbzb6/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 366, in prepare_metadata_for_build_wheel
self.run_setup()
File "/tmp/pip-build-env-oqycbzb6/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 311, in run_setup
exec(code, locals())
File "", line 285, in 
File "/tmp/pip-build-env-oqycbzb6/overlay/lib/python3.8/site-packages/setuptools/init.py", line 104, in setup
return distutils.core.setup(attrs)
File "/tmp/pip-build-env-oqycbzb6/overlay/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 146, in setup
_setup_distribution = dist = klass(attrs)
File "/tmp/pip-build-env-oqycbzb6/overlay/lib/python3.8/site-packages/setuptools/dist.py", line 307, in init
_Distribution.init(self, dist_attrs)
File "/tmp/pip-build-env-oqycbzb6/overlay/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 284, in init
self.finalize_options()
File "/tmp/pip-build-env-oqycbzb6/overlay/lib/python3.8/site-packages/setuptools/dist.py", line 658, in finalize_options
ep(self)
File "/tmp/pip-build-env-oqycbzb6/overlay/lib/python3.8/site-packages/setuptools/dist.py", line 678, in _finalize_setup_keywords
ep.load()(self, ep.name, value)
File "/tmp/pip-build-env-oqycbzb6/normal/lib/python3.8/site-packages/cffi/setuptools_ext.py", line 216, in cffi_modules
add_cffi_module(dist, cffi_module)
File "/tmp/pip-build-env-oqycbzb6/normal/lib/python3.8/site-packages/cffi/setuptools_ext.py", line 49, in add_cffi_module
execfile(build_file_name, mod_vars)
File "/tmp/pip-build-env-oqycbzb6/normal/lib/python3.8/site-packages/cffi/setuptools_ext.py", line 25, in execfile
exec(code, glob, glob)
File "scripts/libtss2_build.py", line 69, in 
ffibuilder.cdef(open("libesys.h").read())
File "/tmp/pip-build-env-oqycbzb6/normal/lib/python3.8/site-packages/cffi/api.py", line 112, in cdef
self._cdef(csource, override=override, packed=packed, pack=pack)
File "/tmp/pip-build-env-oqycbzb6/normal/lib/python3.8/site-packages/cffi/api.py", line 126, in _cdef
self._parser.parse(csource, override=override, **options)
File "/tmp/pip-build-env-oqycbzb6/normal/lib/python3.8/site-packages/cffi/cparser.py", line 389, in parse
self._internal_parse(csource)
File "/tmp/pip-build-env-oqycbzb6/normal/lib/python3.8/site-packages/cffi/cparser.py", line 396, in _internal_parse
self._process_macros(macros)
File "/tmp/pip-build-env-oqycbzb6/normal/lib/python3.8/site-packages/cffi/cparser.py", line 479, in _process_macros
raise CDefError(
cffi.CDefError: only supports one of the following syntax:

define TPM2_HR_PCR ... (literally dot-dot-dot)

  #define TPM2_HR_PCR NUMBER  (with NUMBER an integer constant, decimal/hex/octal)
got:
  #define TPM2_HR_PCR ...<< TPM2_HR_SHIFT)
----------------------------------------

ERROR: Command errored out with exit status 1: /usr/bin/python3 /tmp/tmpkagdkub1 prepare_metadata_for_build_wheel /tmp/tmp0dfx61fb Check the logs for full command output.

j30231 commented 7 months ago

and also, I was install pkgconfig, setuptools, testresoures. but It's not installed.

using pep517, it's not installed, too.

jj@tpm:~/tpm2-pytss$ pip install --use-pep517 .
/usr/bin/pip:6: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
from pkg_resources import load_entry_point
Processing /home/jj/tpm2-pytss
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing wheel metadata ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 /tmp/tmptv3xn95n prepare_metadata_for_build_wheel /tmp/tmppye163fn
cwd: /tmp/pip-req-build-v6y26_qp
Complete output (50 lines):
/tmp/pip-build-env-kaox78mq/overlay/lib/python3.8/site-packages/setuptools_scm/_integration/setuptools.py:90: UserWarning: version of None already set
warnings.warn(f"version of {dist_name} already set")
adding path: /tmp/pip-req-build-v6y26_qp/scripts
Traceback (most recent call last):
File "/tmp/tmptv3xn95n", line 280, in 
main()
File "/tmp/tmptv3xn95n", line 263, in main
json_out['return_val'] = hook(hook_input['kwargs'])
File "/tmp/tmptv3xn95n", line 133, in prepare_metadata_for_build_wheel
return hook(metadata_directory, config_settings)
File "/tmp/pip-build-env-kaox78mq/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 366, in prepare_metadata_for_build_wheel
self.run_setup()
File "/tmp/pip-build-env-kaox78mq/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 311, in run_setup
exec(code, locals())
File "", line 285, in 
File "/tmp/pip-build-env-kaox78mq/overlay/lib/python3.8/site-packages/setuptools/init.py", line 104, in setup
return distutils.core.setup(attrs)
File "/tmp/pip-build-env-kaox78mq/overlay/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 146, in setup
_setup_distribution = dist = klass(attrs)
File "/tmp/pip-build-env-kaox78mq/overlay/lib/python3.8/site-packages/setuptools/dist.py", line 307, in init
_Distribution.init(self, dist_attrs)
File "/tmp/pip-build-env-kaox78mq/overlay/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 284, in init
self.finalize_options()
File "/tmp/pip-build-env-kaox78mq/overlay/lib/python3.8/site-packages/setuptools/dist.py", line 658, in finalize_options
ep(self)
File "/tmp/pip-build-env-kaox78mq/overlay/lib/python3.8/site-packages/setuptools/dist.py", line 678, in _finalize_setup_keywords
ep.load()(self, ep.name, value)
File "/tmp/pip-build-env-kaox78mq/normal/lib/python3.8/site-packages/cffi/setuptools_ext.py", line 216, in cffi_modules
add_cffi_module(dist, cffi_module)
File "/tmp/pip-build-env-kaox78mq/normal/lib/python3.8/site-packages/cffi/setuptools_ext.py", line 49, in add_cffi_module
execfile(build_file_name, mod_vars)
File "/tmp/pip-build-env-kaox78mq/normal/lib/python3.8/site-packages/cffi/setuptools_ext.py", line 25, in execfile
exec(code, glob, glob)
File "scripts/libtss2_build.py", line 69, in 
ffibuilder.cdef(open("libesys.h").read())
File "/tmp/pip-build-env-kaox78mq/normal/lib/python3.8/site-packages/cffi/api.py", line 112, in cdef
self._cdef(csource, override=override, packed=packed, pack=pack)
File "/tmp/pip-build-env-kaox78mq/normal/lib/python3.8/site-packages/cffi/api.py", line 126, in _cdef
self._parser.parse(csource, override=override, **options)
File "/tmp/pip-build-env-kaox78mq/normal/lib/python3.8/site-packages/cffi/cparser.py", line 389, in parse
self._internal_parse(csource)
File "/tmp/pip-build-env-kaox78mq/normal/lib/python3.8/site-packages/cffi/cparser.py", line 396, in _internal_parse
self._process_macros(macros)
File "/tmp/pip-build-env-kaox78mq/normal/lib/python3.8/site-packages/cffi/cparser.py", line 479, in _process_macros
raise CDefError(
cffi.CDefError: only supports one of the following syntax:

define TPM2_HR_PCR ... (literally dot-dot-dot)

  #define TPM2_HR_PCR NUMBER  (with NUMBER an integer constant, decimal/hex/octal)
got:
  #define TPM2_HR_PCR ...<< TPM2_HR_SHIFT)
----------------------------------------

ERROR: Command errored out with exit status 1: /usr/bin/python3 /tmp/tmptv3xn95n prepare_metadata_for_build_wheel /tmp/tmppye163fn Check the logs for full command output.

whooo commented 7 months ago

It's two different issues, one is updates to tpm2-tss which affects some regex we use, which is fixed in https://github.com/tpm2-software/tpm2-pytss/pull/571 the other is related to difference in versions between cffi and cffi backend.

j30231 commented 7 months ago

~~I solve this problem using TPM2-TSS 4.0.1 ver. and Install python3-cffi , upgrade setuptools and cffi~~ @baloo Thank you.

this seems to be triggered by an upgrade of tpm2-tss from 4.0.1 to 4.1.0.

NixOS/nixpkgs#307100

EDIT: b02fdc8 appears to fix the #define TPM2_HR_PCR error

# TPM2 Installing software stacks and tools
sudo apt update
sudo apt -y install   autoconf-archive   libcmocka0   libcmocka-dev   procps   iproute2   build-essential   git   pkg-config   gcc   libtool   automake   libssl-dev   uthash-dev   autoconf   doxygen   libjson-c-dev   libini-config-dev   libcurl4-openssl-dev   uuid-dev   libltdl-dev   libusb-1.0-0-dev   libftdi-dev python3-pip 

# TPM2 TSS Installing a software stack (version 4.0.1 - pytss compatibility issues)
git clone --branch 4.0.1 https://github.com/tpm2-software/tpm2-tss.git
cd tpm2-tss/
./bootstrap
./configure
make
sudo make install
sudo ldconfig
pip install --upgrade setuptools
pip install --upgrade cffi
sudo apt install python3-cffi

# TPM2 Python Library installation
pip install tpm2-pytss

This method occur another issue.

python3 -c "import tpm2_pytss"
Traceback (most recent call last):
  File "/home/jaesik/.local/lib/python3.10/site-packages/tpm2_pytss/__init__.py", line 6, in <module>
    from ._libtpm2_pytss import lib
ImportError: /home/jaesik/.local/lib/python3.10/site-packages/tpm2_pytss/_libtpm2_pytss.abi3.so: undefined symbol: Esys_MAC_Start_Async

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/jaesik/.local/lib/python3.10/site-packages/tpm2_pytss/__init__.py", line 14, in <module>
    raise ImportError(
ImportError: failed to load tpm2-tss bindigs in /home/jaesik/.local/lib/python3.10/site-packages/tpm2_pytss/_libtpm2_pytss.abi3.so due to missing symbol Esys_MAC_Start_Async, ensure that you are using the same libraries the python module was built against.
whooo commented 7 months ago

@aitor-garmen, could you try installing python3-cffi via apt=

j30231 commented 7 months ago

When I was install tpm2-tss v 4.0.1 and tpm2-pytss 2.2.1
I meet this error message

jaesik@pp:~/tpm2-pytss$ python3 -c "import tpm2_pytss"
Traceback (most recent call last):
  File "/home/jaesik/.local/lib/python3.10/site-packages/tpm2_pytss/__init__.py", line 6, in <module>
    from ._libtpm2_pytss import lib
ImportError: /home/jaesik/.local/lib/python3.10/site-packages/tpm2_pytss/_libtpm2_pytss.abi3.so: undefined symbol: Esys_MAC_Start_Async

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/jaesik/.local/lib/python3.10/site-packages/tpm2_pytss/__init__.py", line 14, in <module>
    raise ImportError(
ImportError: failed to load tpm2-tss bindigs in /home/jaesik/.local/lib/python3.10/site-packages/tpm2_pytss/_libtpm2_pytss.abi3.so due to missing symbol Esys_MAC_Start_Async, ensure that you are using the same libraries the python module was built against.

when I installed tpm2-tss v4.0.1 , I can install tpm2-pytss using only PyPi "python3 -m pip install tpm2-pytss"

jaesik@pp:~/tpm2-pytss$ python3 -m pip install tpm2-pytss
Defaulting to user installation because normal site-packages is not writeable
Collecting tpm2-pytss
  Using cached tpm2_pytss-2.2.1-cp310-cp310-linux_aarch64.whl
Requirement already satisfied: pyyaml in /usr/lib/python3/dist-packages (from tpm2-pytss) (5.4.1)
Requirement already satisfied: asn1crypto in /home/jaesik/.local/lib/python3.10/site-packages (from tpm2-pytss) (1.5.1)
Requirement already satisfied: cryptography>=3.0 in /usr/lib/python3/dist-packages (from tpm2-pytss) (3.4.8)
Requirement already satisfied: packaging in /home/jaesik/.local/lib/python3.10/site-packages (from tpm2-pytss) (24.0)
Requirement already satisfied: cffi>=1.0.0 in /home/jaesik/.local/lib/python3.10/site-packages (from tpm2-pytss) (1.16.0)
Requirement already satisfied: pycparser in /usr/lib/python3/dist-packages (from cffi>=1.0.0->tpm2-pytss) (2.21)
Installing collected packages: tpm2-pytss
Successfully installed tpm2-pytss-2.2.1

However, if I download and install the tpm2-pytsss 2.2.1 version directly through git, I get the same error as when I installed tpm2-tsss 4.1.0.

jaesik@pp:~/tpm2-pytss$ python3 -m pip install -e .
Defaulting to user installation because normal site-packages is not writeable
Obtaining file:///home/jaesik/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: packaging in /home/jaesik/.local/lib/python3.10/site-packages (from tpm2-pytss==2.2.2.dev5+g19aee3f) (24.0)
Requirement already satisfied: asn1crypto in /home/jaesik/.local/lib/python3.10/site-packages (from tpm2-pytss==2.2.2.dev5+g19aee3f) (1.5.1)
Requirement already satisfied: cryptography>=3.0 in /usr/lib/python3/dist-packages (from tpm2-pytss==2.2.2.dev5+g19aee3f) (3.4.8)
Requirement already satisfied: pyyaml in /usr/lib/python3/dist-packages (from tpm2-pytss==2.2.2.dev5+g19aee3f) (5.4.1)
Requirement already satisfied: cffi>=1.0.0 in /home/jaesik/.local/lib/python3.10/site-packages (from tpm2-pytss==2.2.2.dev5+g19aee3f) (1.16.0)
Requirement already satisfied: pycparser in /usr/lib/python3/dist-packages (from cffi>=1.0.0->tpm2-pytss==2.2.2.dev5+g19aee3f) (2.21)
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
    ╰─> [42 lines of output]
        /tmp/pip-build-env-iutgrooj/overlay/local/lib/python3.10/dist-packages/setuptools_scm/_integration/setuptools.py:30: RuntimeWarning:
        ERROR: setuptools==59.6.0 is used in combination with setuptools_scm>=8.x

        Your build configuration is incomplete and previously worked by accident!
        setuptools_scm requires setuptools>=61

        Suggested workaround if applicable:
         - migrating from the deprecated setup_requires mechanism to pep517/518
           and using a pyproject.toml to declare build dependencies
           which are reliably pre-installed before running the build tools

          warnings.warn(
        adding path: /home/jaesik/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 "/home/jaesik/tpm2-pytss/setup.py", line 285, 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
╰─> [42 lines of output]
    /tmp/pip-build-env-iutgrooj/overlay/local/lib/python3.10/dist-packages/setuptools_scm/_integration/setuptools.py:30: RuntimeWarning:
    ERROR: setuptools==59.6.0 is used in combination with setuptools_scm>=8.x

    Your build configuration is incomplete and previously worked by accident!
    setuptools_scm requires setuptools>=61

    Suggested workaround if applicable:
     - migrating from the deprecated setup_requires mechanism to pep517/518
       and using a pyproject.toml to declare build dependencies
       which are reliably pre-installed before running the build tools

      warnings.warn(
    adding path: /home/jaesik/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 "/home/jaesik/tpm2-pytss/setup.py", line 285, 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.

In conclusion, I think there is a compatibility issue between the tpm2-tss 4.1.0 version and tpm2-pytsss 2.2.1 version. Also, I think the tpm2-tss 4.0.1 version and tpm2-pytsss 2.2.1 version also have other issues.

of course I was installed cffi v1.16.0 and setuptools 69.5.1

jaesik@pp:~/tpm2-pytss$ pip list
Package                Version
---------------------- ----------------
...
cffi                   1.16.0
...
setuptools             69.5.1
...
whooo commented 7 months ago

When I was install tpm2-tss v 4.0.1 and tpm2-pytss 2.2.1 I meet this error message

jaesik@pp:~/tpm2-pytss$ python3 -c "import tpm2_pytss"
Traceback (most recent call last):
  File "/home/jaesik/.local/lib/python3.10/site-packages/tpm2_pytss/__init__.py", line 6, in <module>
    from ._libtpm2_pytss import lib
ImportError: /home/jaesik/.local/lib/python3.10/site-packages/tpm2_pytss/_libtpm2_pytss.abi3.so: undefined symbol: Esys_MAC_Start_Async

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/jaesik/.local/lib/python3.10/site-packages/tpm2_pytss/__init__.py", line 14, in <module>
    raise ImportError(
ImportError: failed to load tpm2-tss bindigs in /home/jaesik/.local/lib/python3.10/site-packages/tpm2_pytss/_libtpm2_pytss.abi3.so due to missing symbol Esys_MAC_Start_Async, ensure that you are using the same libraries the python module was built against.

Ensure you are using the same library during build and runtime, compare the output between pkg-config --libs tss2-esys and /home/jaesik/.local/lib/python3.10/site-packages/tpm2_pytss/_libtpm2_pytss.abi3.so

when I installed tpm2-tss v4.0.1 , I can install tpm2-pytss using only PyPi "python3 -m pip install tpm2-pytss"

jaesik@pp:~/tpm2-pytss$ python3 -m pip install tpm2-pytss
Defaulting to user installation because normal site-packages is not writeable
Collecting tpm2-pytss
  Using cached tpm2_pytss-2.2.1-cp310-cp310-linux_aarch64.whl
Requirement already satisfied: pyyaml in /usr/lib/python3/dist-packages (from tpm2-pytss) (5.4.1)
Requirement already satisfied: asn1crypto in /home/jaesik/.local/lib/python3.10/site-packages (from tpm2-pytss) (1.5.1)
Requirement already satisfied: cryptography>=3.0 in /usr/lib/python3/dist-packages (from tpm2-pytss) (3.4.8)
Requirement already satisfied: packaging in /home/jaesik/.local/lib/python3.10/site-packages (from tpm2-pytss) (24.0)
Requirement already satisfied: cffi>=1.0.0 in /home/jaesik/.local/lib/python3.10/site-packages (from tpm2-pytss) (1.16.0)
Requirement already satisfied: pycparser in /usr/lib/python3/dist-packages (from cffi>=1.0.0->tpm2-pytss) (2.21)
Installing collected packages: tpm2-pytss
Successfully installed tpm2-pytss-2.2.1

However, if I download and install the tpm2-pytsss 2.2.1 version directly through git, I get the same error as when I installed tpm2-tsss 4.1.0.

jaesik@pp:~/tpm2-pytss$ python3 -m pip install -e .
Defaulting to user installation because normal site-packages is not writeable
Obtaining file:///home/jaesik/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: packaging in /home/jaesik/.local/lib/python3.10/site-packages (from tpm2-pytss==2.2.2.dev5+g19aee3f) (24.0)
Requirement already satisfied: asn1crypto in /home/jaesik/.local/lib/python3.10/site-packages (from tpm2-pytss==2.2.2.dev5+g19aee3f) (1.5.1)
Requirement already satisfied: cryptography>=3.0 in /usr/lib/python3/dist-packages (from tpm2-pytss==2.2.2.dev5+g19aee3f) (3.4.8)
Requirement already satisfied: pyyaml in /usr/lib/python3/dist-packages (from tpm2-pytss==2.2.2.dev5+g19aee3f) (5.4.1)
Requirement already satisfied: cffi>=1.0.0 in /home/jaesik/.local/lib/python3.10/site-packages (from tpm2-pytss==2.2.2.dev5+g19aee3f) (1.16.0)
Requirement already satisfied: pycparser in /usr/lib/python3/dist-packages (from cffi>=1.0.0->tpm2-pytss==2.2.2.dev5+g19aee3f) (2.21)
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
    ╰─> [42 lines of output]
        /tmp/pip-build-env-iutgrooj/overlay/local/lib/python3.10/dist-packages/setuptools_scm/_integration/setuptools.py:30: RuntimeWarning:
        ERROR: setuptools==59.6.0 is used in combination with setuptools_scm>=8.x

        Your build configuration is incomplete and previously worked by accident!
        setuptools_scm requires setuptools>=61

        Suggested workaround if applicable:
         - migrating from the deprecated setup_requires mechanism to pep517/518
           and using a pyproject.toml to declare build dependencies
           which are reliably pre-installed before running the build tools

          warnings.warn(
        adding path: /home/jaesik/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 "/home/jaesik/tpm2-pytss/setup.py", line 285, 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

Try upgrading setuptools, as it's an issue with setuptools.

× python setup.py develop did not run successfully.
│ exit code: 1
╰─> [42 lines of output]
    /tmp/pip-build-env-iutgrooj/overlay/local/lib/python3.10/dist-packages/setuptools_scm/_integration/setuptools.py:30: RuntimeWarning:
    ERROR: setuptools==59.6.0 is used in combination with setuptools_scm>=8.x

    Your build configuration is incomplete and previously worked by accident!
    setuptools_scm requires setuptools>=61

    Suggested workaround if applicable:
     - migrating from the deprecated setup_requires mechanism to pep517/518
       and using a pyproject.toml to declare build dependencies
       which are reliably pre-installed before running the build tools

      warnings.warn(
    adding path: /home/jaesik/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 "/home/jaesik/tpm2-pytss/setup.py", line 285, 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.

See answer above

In conclusion, I think there is a compatibility issue between the tpm2-tss 4.1.0 version and tpm2-pytsss 2.2.1 version. Also, I think the tpm2-tss 4.0.1 version and tpm2-pytsss 2.2.1 version also have other issues. As mentioned in https://github.com/tpm2-software/tpm2-pytss/issues/570 and https://github.com/tpm2-software/tpm2-pytss/issues/573 it's fixed by https://github.com/tpm2-software/tpm2-pytss/pull/571 The other issues you are having is not related to any specific version of tpm2-tss and tpm2-pytss.

of course I was installed cffi v1.16.0 and setuptools 69.5.1

jaesik@pp:~/tpm2-pytss$ pip list
Package                Version
---------------------- ----------------
...
cffi                   1.16.0
...
setuptools             69.5.1
...

An older version of setuptools is used for some reason, see ERROR: setuptools==59.6.0 is used in combination with setuptools_scm>=8.x

carloscn commented 7 months ago

this seems to be triggered by an upgrade of tpm2-tss from 4.0.1 to 4.1.0.

NixOS/nixpkgs#307100

EDIT: b02fdc8 appears to fix the #define TPM2_HR_PCR error

Yes, I tried to rollback tpm2-tss to 4.0.0, none of CDefError was prompted.

whooo commented 5 months ago

Closing as fixed in 2.3.0-rc0