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

cffi.CDefError: only supports one of the following syntax #603

Closed DylanFromEdwards closed 2 months ago

DylanFromEdwards commented 2 months ago

Hi,

I'm attempting to install tpm2-pytss into a venv and I get a metadata error preventing me from doing so.

I suspect the offending line is the (-1) ???

  cffi.CDefError: only supports one of the following syntax:
    #define TSS2_TCTI_TIMEOUT_BLOCK ...     (literally dot-dot-dot)
    #define TSS2_TCTI_TIMEOUT_BLOCK NUMBER  (with NUMBER an integer constant, decimal/hex/octal)
  got:
    #define TSS2_TCTI_TIMEOUT_BLOCK (-1)

The full output is included below. Would someone be able to help me solve this issue?

Kind regards, Dylan

(venv) tpm@OracleDebianTPM:~/pytpm$ python3 -m pip install tpm2-pytss Collecting tpm2-pytss Using cached tpm2-pytss-2.3.0.tar.gz (213 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 ╰─> [54 lines of output] /tmp/pip-build-env-cfah9q4m/overlay/lib/python3.11/site-packages/setuptools_scm/_integration/setuptools.py:92: UserWarning: version of None already set warnings.warn(f"version of {dist_name} already set") adding path: /tmp/pip-install-5l1yi5ft/tpm2-pytss_dd9af7615ade4088b7167914a01a82bc/scripts Traceback (most recent call last): File "/home/tpm/pytpm/venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in main() File "/home/tpm/pytpm/venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main json_out['return_val'] = hook(hook_input['kwargs']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/tpm/pytpm/venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 149, in prepare_metadata_for_build_wheel return hook(metadata_directory, config_settings) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/tmp/pip-build-env-cfah9q4m/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 373, in prepare_metadata_for_build_wheel self.run_setup() File "/tmp/pip-build-env-cfah9q4m/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 318, in run_setup exec(code, locals()) File "", line 285, in File "/tmp/pip-build-env-cfah9q4m/overlay/lib/python3.11/site-packages/setuptools/init.py", line 117, in setup return distutils.core.setup(attrs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/tmp/pip-build-env-cfah9q4m/overlay/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 145, in setup _setup_distribution = dist = klass(attrs) ^^^^^^^^^^^^ File "/tmp/pip-build-env-cfah9q4m/overlay/lib/python3.11/site-packages/setuptools/dist.py", line 283, in init _Distribution.init(self, dist_attrs) File "/tmp/pip-build-env-cfah9q4m/overlay/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 279, in init self.finalize_options() File "/tmp/pip-build-env-cfah9q4m/overlay/lib/python3.11/site-packages/setuptools/dist.py", line 635, in finalize_options ep(self) File "/tmp/pip-build-env-cfah9q4m/overlay/lib/python3.11/site-packages/setuptools/dist.py", line 655, in _finalize_setup_keywords ep.load()(self, ep.name, value) File "/tmp/pip-build-env-cfah9q4m/normal/lib/python3.11/site-packages/cffi/setuptools_ext.py", line 216, in cffi_modules add_cffi_module(dist, cffi_module) File "/tmp/pip-build-env-cfah9q4m/normal/lib/python3.11/site-packages/cffi/setuptools_ext.py", line 49, in add_cffi_module execfile(build_file_name, mod_vars) File "/tmp/pip-build-env-cfah9q4m/normal/lib/python3.11/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-cfah9q4m/normal/lib/python3.11/site-packages/cffi/api.py", line 112, in cdef self._cdef(csource, override=override, packed=packed, pack=pack) File "/tmp/pip-build-env-cfah9q4m/normal/lib/python3.11/site-packages/cffi/api.py", line 126, in _cdef self._parser.parse(csource, override=override, **options) File "/tmp/pip-build-env-cfah9q4m/normal/lib/python3.11/site-packages/cffi/cparser.py", line 390, in parse self._internal_parse(csource) File "/tmp/pip-build-env-cfah9q4m/normal/lib/python3.11/site-packages/cffi/cparser.py", line 397, in _internal_parse self._process_macros(macros) File "/tmp/pip-build-env-cfah9q4m/normal/lib/python3.11/site-packages/cffi/cparser.py", line 488, in _process_macros raise CDefError( cffi.CDefError: only supports one of the following syntax:

define TSS2_TCTI_TIMEOUT_BLOCK ... (literally dot-dot-dot)

    #define TSS2_TCTI_TIMEOUT_BLOCK NUMBER  (with NUMBER an integer constant, decimal/hex/octal)
  got:
    #define TSS2_TCTI_TIMEOUT_BLOCK (-1)
  [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.

whooo commented 2 months ago

Try installing tpm2-pytss with python3 -m pip install git+https://github.com/tpm2-software/tpm2-pytss.git I think it's already fixed in the repo, but not in a release yet

DylanFromEdwards commented 2 months ago

Thank you. That was quick. Works from the main.

An FYI for anyone else facing this I had to open a root shell with: su -

and do the install.

DylanFromEdwards commented 2 months ago

Thanks - I'll close this issue now.