Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on installation #579

Open
try0010 opened this issue Jun 6, 2024 · 12 comments
Open

Error on installation #579

try0010 opened this issue Jun 6, 2024 · 12 comments

Comments

@try0010
Copy link

try0010 commented Jun 6, 2024

(venv) $ pip3 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 metadata (pyproject.toml) ... done
Requirement already satisfied: cffi>=1.0.0 in /home/tom/tpm/venv/lib/python3.9/site-packages (from tpm2-pytss) (1.16.0)
Collecting asn1crypto (from tpm2-pytss)
  Using cached asn1crypto-1.5.1-py2.py3-none-any.whl.metadata (13 kB)
Requirement already satisfied: cryptography>=3.0 in /home/tom/tpm/venv/lib/python3.9/site-packages (from tpm2-pytss) (42.0.8)
Collecting packaging (from tpm2-pytss)
  Using cached packaging-24.0-py3-none-any.whl.metadata (3.2 kB)
Requirement already satisfied: pyyaml in /home/tom/tpm/venv/lib/python3.9/site-packages (from tpm2-pytss) (6.0.1)
Requirement already satisfied: pycparser in /home/tom/tpm/venv/lib/python3.9/site-packages (from cffi>=1.0.0->tpm2-pytss) (2.22)
Using cached asn1crypto-1.5.1-py2.py3-none-any.whl (105 kB)
Using cached packaging-24.0-py3-none-any.whl (53 kB)
Building wheels for collected packages: tpm2-pytss
  Building wheel for tpm2-pytss (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for tpm2-pytss (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [42 lines of output]
      /tmp/pip-build-env-qfoqlliw/overlay/lib/python3.9/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-76wemfzz/tpm2-pytss_0f34374e3e1445eb859b68bbc7d8ffe0/scripts
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-39
      creating build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/FAPI.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/ESAPI.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/TCTISPIHelper.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/TCTILdr.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/TSS2_Exception.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/__init__.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/policy.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/constants.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/TCTI.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/utils.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/encoding.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/types.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/fapi_info.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/tsskey.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      creating build/lib.linux-x86_64-cpython-39/tpm2_pytss/internal
      copying src/tpm2_pytss/internal/__init__.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss/internal
      copying src/tpm2_pytss/internal/utils.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss/internal
      copying src/tpm2_pytss/internal/templates.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss/internal
      copying src/tpm2_pytss/internal/crypto.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss/internal
      running build_ext
      generating cffi module 'build/temp.linux-x86_64-cpython-39/tpm2_pytss._libtpm2_pytss.c'
      creating build/temp.linux-x86_64-cpython-39
      building 'tpm2_pytss._libtpm2_pytss' extension
      creating build/temp.linux-x86_64-cpython-39/build
      creating build/temp.linux-x86_64-cpython-39/build/temp.linux-x86_64-cpython-39
      x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/build/python3.9-RNBry6/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/local/include -I/usr/local/include/tss2 -I/usr/local/include -I/usr/local/include/tss2 -I/usr/local/include -I/usr/local/include/tss2 -I/usr/local/include -I/usr/local/include/tss2 -I/usr/local/include -I/usr/local/include/tss2 -I/usr/local/include -I/usr/local/include/tss2 -I/usr/local/include -I/usr/local/include/tss2 -I/usr/local/include -I/usr/local/include/tss -I/usr/include/x86_64-linux-gnu -I/usr/include -I/usr/include/json-c -I/home/tom/tpm/venv/include -I/usr/include/python3.9 -c build/temp.linux-x86_64-cpython-39/tpm2_pytss._libtpm2_pytss.c -o build/temp.linux-x86_64-cpython-39/build/temp.linux-x86_64-cpython-39/tpm2_pytss._libtpm2_pytss.o
      In file included from build/temp.linux-x86_64-cpython-39/tpm2_pytss._libtpm2_pytss.c:589:
      build/temp.linux-x86_64-cpython-39/tpm2_pytss._libtpm2_pytss.c: In function ‘_cffi_const_TSS2_POLICY_RC_NULL_CALLBACK’:
      build/temp.linux-x86_64-cpython-39/tpm2_pytss._libtpm2_pytss.c:66173:12: error: ‘TSS2_BASE_RC_CALLBACK_NULL’ undeclared (first use in this function)
      66173 |   int n = (TSS2_POLICY_RC_NULL_CALLBACK) <= 0;
            |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      build/temp.linux-x86_64-cpython-39/tpm2_pytss._libtpm2_pytss.c:66173:12: note: each undeclared identifier is reported only once for each function it appears in
      error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for tpm2-pytss
Failed to build tpm2-pytss
ERROR: Could not build wheels for tpm2-pytss, which is required to install pyproject.toml-based projects
(venv) $ uname -a && python3 --version && pip3 --version
Linux 5.10.0-30-amd64 #1 SMP Debian 5.10.218-1 (2024-06-01) x86_64 GNU/Linux
Python 3.9.2
pip 24.0 from /home/tom/tpm/venv/lib/python3.9/site-packages/pip (python 3.9)

Shortly beforehand I've rm -rf ~/.cache/pip/ instead of pip3 cache purge if it helps.

@whooo
Copy link
Contributor

whooo commented Jun 6, 2024

could you run pkg-config --modversion tss2-esys and give me the output?
Also, does it work if you install from the master branch of tpm2--pytss?

@try0010
Copy link
Author

try0010 commented Jun 10, 2024

@whooo, hi!

$ pkg-config --modversion tss2-esys
3.2.2

does it work if you install from the master branch of tpm2-pytss?
Not sure if prior cleanings are required, I've made none.

(venv) $ python3 -m pip install git+https://github.com/tpm2-software/tpm2-pytss.git
Collecting git+https://github.com/tpm2-software/tpm2-pytss.git
  Cloning https://github.com/tpm2-software/tpm2-pytss.git to /tmp/pip-req-build-e0vyvuou
  Running command git clone --filter=blob:none --quiet https://github.com/tpm2-software/tpm2-pytss.git /tmp/pip-req-build-e0vyvuou
  Resolved https://github.com/tpm2-software/tpm2-pytss.git to commit 16c7e4bf127e8b2f2800e741804a909a90876408
  Running command git submodule update --init --recursive -q
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: cffi>=1.0.0 in ./venv/lib/python3.9/site-packages (from tpm2-pytss==2.3.0rc0) (1.16.0)
Collecting asn1crypto (from tpm2-pytss==2.3.0rc0)
  Using cached asn1crypto-1.5.1-py2.py3-none-any.whl.metadata (13 kB)
Requirement already satisfied: cryptography>=3.0 in ./venv/lib/python3.9/site-packages (from tpm2-pytss==2.3.0rc0) (42.0.8)
Collecting packaging (from tpm2-pytss==2.3.0rc0)
  Using cached packaging-24.1-py3-none-any.whl.metadata (3.2 kB)
Requirement already satisfied: pyyaml in ./venv/lib/python3.9/site-packages (from tpm2-pytss==2.3.0rc0) (6.0.1)
Requirement already satisfied: pycparser in ./venv/lib/python3.9/site-packages (from cffi>=1.0.0->tpm2-pytss==2.3.0rc0) (2.22)
Using cached asn1crypto-1.5.1-py2.py3-none-any.whl (105 kB)
Using cached packaging-24.1-py3-none-any.whl (53 kB)
Building wheels for collected packages: tpm2-pytss
  Building wheel for tpm2-pytss (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for tpm2-pytss (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [43 lines of output]
      /tmp/pip-build-env-ik2nl2rn/overlay/lib/python3.9/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-req-build-e0vyvuou/scripts
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-39
      creating build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/FAPI.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/ESAPI.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/TCTISPIHelper.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/TCTILdr.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/TSS2_Exception.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/__init__.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/policy.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/constants.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/TCTI.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/utils.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/encoding.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/types.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/cryptography.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/fapi_info.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      copying src/tpm2_pytss/tsskey.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss
      creating build/lib.linux-x86_64-cpython-39/tpm2_pytss/internal
      copying src/tpm2_pytss/internal/__init__.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss/internal
      copying src/tpm2_pytss/internal/utils.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss/internal
      copying src/tpm2_pytss/internal/templates.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss/internal
      copying src/tpm2_pytss/internal/crypto.py -> build/lib.linux-x86_64-cpython-39/tpm2_pytss/internal
      running build_ext
      generating cffi module 'build/temp.linux-x86_64-cpython-39/tpm2_pytss._libtpm2_pytss.c'
      creating build/temp.linux-x86_64-cpython-39
      building 'tpm2_pytss._libtpm2_pytss' extension
      creating build/temp.linux-x86_64-cpython-39/build
      creating build/temp.linux-x86_64-cpython-39/build/temp.linux-x86_64-cpython-39
      x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/build/python3.9-RNBry6/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/local/include -I/usr/local/include/tss2 -I/usr/local/include -I/usr/local/include/tss2 -I/usr/local/include -I/usr/local/include/tss2 -I/usr/local/include -I/usr/local/include/tss2 -I/usr/local/include -I/usr/local/include/tss2 -I/usr/local/include -I/usr/local/include/tss2 -I/usr/local/include -I/usr/local/include/tss2 -I/usr/local/include -I/usr/local/include/tss -I/usr/include/x86_64-linux-gnu -I/usr/include -I/usr/include/json-c -I/home/tom/tpm/venv/include -I/usr/include/python3.9 -c build/temp.linux-x86_64-cpython-39/tpm2_pytss._libtpm2_pytss.c -o build/temp.linux-x86_64-cpython-39/build/temp.linux-x86_64-cpython-39/tpm2_pytss._libtpm2_pytss.o
      In file included from build/temp.linux-x86_64-cpython-39/tpm2_pytss._libtpm2_pytss.c:589:
      build/temp.linux-x86_64-cpython-39/tpm2_pytss._libtpm2_pytss.c: In function ‘_cffi_const_TSS2_POLICY_RC_NULL_CALLBACK’:
      build/temp.linux-x86_64-cpython-39/tpm2_pytss._libtpm2_pytss.c:66173:12: error: ‘TSS2_BASE_RC_CALLBACK_NULL’ undeclared (first use in this function)
      66173 |   int n = (TSS2_POLICY_RC_NULL_CALLBACK) <= 0;
            |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      build/temp.linux-x86_64-cpython-39/tpm2_pytss._libtpm2_pytss.c:66173:12: note: each undeclared identifier is reported only once for each function it appears in
      error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for tpm2-pytss
Failed to build tpm2-pytss
ERROR: Could not build wheels for tpm2-pytss, which is required to install pyproject.toml-based projects

@whooo
Copy link
Contributor

whooo commented Jun 10, 2024

Could you run the following python code and give me the output?

import pkgconfig

libraries = ["tss2-esys", "tss2-tctildr", "tss2-rc", "tss2-mu"]
libs = " ".join(libraries)
paths = pkgconfig.parse(libs)

print(paths["include_dirs"])

I suspect that TSS2_POLICY_RC_NULL_CALLBACK comes from another tpm2-tss installation, but the build uses another.

@try0010
Copy link
Author

try0010 commented Jun 13, 2024

@whooo,

$ python3 test.py 
['/usr/local/include', '/usr/local/include/tss2', '/usr/local/include', '/usr/local/include/tss2', '/usr/local/include', '/usr/local/include/tss2', '/usr/local/include', '/usr/local/include/tss2', '/usr/local/include', '/usr/local/include/tss2']

@try0010
Copy link
Author

try0010 commented Jun 13, 2024

I've also made sudo make uninstall within the "tpm2-tss-3.2.2" directory (after running the script above).

@whooo
Copy link
Contributor

whooo commented Jun 13, 2024

Could you run grep -r TSS2_POLICY_RC_NULL_CALLBACK /usr/include/ and grep -r TSS2_POLICY_RC_NULL_CALLBACK /usr/local/include/ and see if you see anything? Which linux distro are you using?

@try0010
Copy link
Author

try0010 commented Jun 13, 2024

@whooo,

(venv) $ grep -r TSS2_POLICY_RC_NULL_CALLBACK /usr/include/

(venv) $ grep -r TSS2_POLICY_RC_NULL_CALLBACK /usr/local/include/
/usr/local/include/tss2/tss2_policy.h:#define TSS2_POLICY_RC_NULL_CALLBACK               ((TSS2_RC)(TSS2_POLICY_RC_LAYER | \

(venv) $ uname -a
Linux 5.10.0-30-amd64 #1 SMP Debian 5.10.218-1 (2024-06-01) x86_64 GNU/Linux

(venv) $ grep PRETTY_NAME /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"

@whooo
Copy link
Contributor

whooo commented Jun 13, 2024

after doing an uninstall, does pkg-config --modversion tss2-esys give another output?

@try0010
Copy link
Author

try0010 commented Jun 14, 2024

@whooo, yes.

(venv) $ pkg-config --modversion tss2-esys
3.0.3

@whooo
Copy link
Contributor

whooo commented Jun 14, 2024

It looks like you have some leftover installation from tpm2-tss 4.0.0 or newer.
Do you have any of the libtss2 libraries under /usr/local/lib?
The build has two steps that uses the include files, the first one to get all the different functions, data types and constants.
The other during the actual build, and it seems that the first picks up the /usr/local/include/tss2/tss2_policy.h but the second part doesn't.
Could you try pkg-config --modversion tss2-policy ?
My recommendation would be to try to clean up previously installations under /usr/local if possible, uninstall the debian package libtss2-dev and then do a new local installation of libtss2.

@try0010
Copy link
Author

try0010 commented Jun 14, 2024

(venv) $ find /usr/local/lib/ 2>/dev/null | grep -i libtss2 | sort
/usr/local/lib/libtss2-esys.so.0.0.1
/usr/local/lib/libtss2-mu.so.0.0.1
/usr/local/lib/libtss2-policy.a
/usr/local/lib/libtss2-policy.la
/usr/local/lib/libtss2-policy.so
/usr/local/lib/libtss2-policy.so.0
/usr/local/lib/libtss2-policy.so.0.0.0
/usr/local/lib/libtss2-sys.so.1.0.1
/usr/local/lib/libtss2-tcti-i2c-ftdi.a
/usr/local/lib/libtss2-tcti-i2c-ftdi.la
/usr/local/lib/libtss2-tcti-i2c-ftdi.so
/usr/local/lib/libtss2-tcti-i2c-ftdi.so.0
/usr/local/lib/libtss2-tcti-i2c-ftdi.so.0.0.0
/usr/local/lib/libtss2-tcti-i2c-helper.a
/usr/local/lib/libtss2-tcti-i2c-helper.la
/usr/local/lib/libtss2-tcti-i2c-helper.so
/usr/local/lib/libtss2-tcti-i2c-helper.so.0
/usr/local/lib/libtss2-tcti-i2c-helper.so.0.0.0
/usr/local/lib/libtss2-tcti-spidev.a
/usr/local/lib/libtss2-tcti-spidev.la
/usr/local/lib/libtss2-tcti-spidev.so
/usr/local/lib/libtss2-tcti-spidev.so.0
/usr/local/lib/libtss2-tcti-spidev.so.0.0.0
/usr/local/lib/libtss2-tcti-spi-ftdi.a
/usr/local/lib/libtss2-tcti-spi-ftdi.la
/usr/local/lib/libtss2-tcti-spi-ftdi.so
/usr/local/lib/libtss2-tcti-spi-ftdi.so.0
/usr/local/lib/libtss2-tcti-spi-ftdi.so.0.0.0
/usr/local/lib/libtss2-tcti-spi-helper.a
/usr/local/lib/libtss2-tcti-spi-helper.la
/usr/local/lib/libtss2-tcti-spi-helper.so
/usr/local/lib/libtss2-tcti-spi-helper.so.0
/usr/local/lib/libtss2-tcti-spi-helper.so.0.0.0
/usr/local/lib/libtss2-tcti-spi-ltt2go.a
/usr/local/lib/libtss2-tcti-spi-ltt2go.la
/usr/local/lib/libtss2-tcti-spi-ltt2go.so
/usr/local/lib/libtss2-tcti-spi-ltt2go.so.0
/usr/local/lib/libtss2-tcti-spi-ltt2go.so.0.0.0
(venv) $ pkg-config --modversion tss2-policy
4.1.0-26-g6c46325b

Uninstalling libtss2-dev

(venv) $ sudo apt remove libtss2-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required: 
  libgcrypt20-dev libgpg-error-dev libtss2-fapi1
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED: 
  libtss2-dev
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 440 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 335143 files and directories currently installed.)
Removing libtss2-dev:amd64 (3.0.3-2) ...
Processing triggers for man-db (2.9.4-2) ...

Unable to apt purge, I've used find to locate the package leftovers and remove them manually.

/usr/local/etc/tpm2-tss
/usr/local/etc/tpm2-tss/fapi-profiles
/usr/local/etc/tpm2-tss/fapi-profiles/P_ECCP384SHA384.json
/usr/local/etc/tpm2-tss/fapi-profiles/P_RSA3072SHA384.json
/usr/local/var/lib/tpm2-tss
/usr/local/var/lib/tpm2-tss/system
/usr/local/var/lib/tpm2-tss/system/keystore
/usr/local/var/run/tpm2-tss
/usr/local/var/run/tpm2-tss/eventlog

(venv) $ find / 2>/dev/null | grep -i tpm2-tss
(venv) $

I haven't removed the above-listed /usr/local/lib/libtss2-* files. Do I have to before a fresh installation?

@whooo
Copy link
Contributor

whooo commented Jun 14, 2024

You could probably keep them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants