But the gcc build is looking for it here: -I/usr/include/python3.9
I'm running Ubuntu 23.04:
$uname -a
Linux x1c9 6.2.0-24-generic #24-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 16 12:03:50 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
$lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 23.04
Release: 23.04
Codename: lunar
I considered whether I could install an APK for Python 3.9 that would provide /usr/include/python3.9. Note that I can't use the deadsnakes PPA, because that only supports LTS versions of Ubuntu and I'm on 23.04.
I also considered just giving up on pyenv and using venv, but venv has problems of its own:
python3.9 -m venv ~/cairo_venv
Error: Command '['/home/e/cairo_venv/bin/python3.9', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
I recall that changing the system Python on Ubuntu breaks the OS badly. So I won't be doing that.
But python3.9-dev is not an available package on 23.04:
sudo apt install python3.9-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package python3.9-dev
E: Couldn't find any package by glob 'python3.9-dev'
Here's what I do have installed for Python 3.9:
$apt list --installed | grep python3.9
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
libpython3.9-minimal/now 3.9.16-1+jammy1 amd64 [installed,local]
libpython3.9-stdlib/now 3.9.16-1+jammy1 amd64 [installed,local]
python3.9-distutils/now 3.9.16-1+jammy1 all [installed,local]
python3.9-lib2to3/now 3.9.16-1+jammy1 all [installed,local]
python3.9-minimal/now 3.9.16-1+jammy1 amd64 [installed,local]
python3.9/now 3.9.16-1+jammy1 amd64 [installed,local]
-minimal sounds bad here but I can find no way to get python3.9-dev installed.
Of course, the workaround is just to use the docker container.
Full output of the pip install attempt:
$pip install ecdsa fastecdsa sympy
Defaulting to user installation because normal site-packages is not writeable
Collecting ecdsa
Using cached ecdsa-0.18.0-py2.py3-none-any.whl (142 kB)
Collecting fastecdsa
Using cached fastecdsa-2.3.0.tar.gz (49 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
Collecting sympy
Using cached sympy-1.12-py3-none-any.whl (5.7 MB)
Requirement already satisfied: six>=1.9.0 in /usr/lib/python3/dist-packages (from ecdsa) (1.16.0)
Collecting mpmath>=0.19 (from sympy)
Using cached mpmath-1.3.0-py3-none-any.whl (536 kB)
Building wheels for collected packages: fastecdsa
Building wheel for fastecdsa (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for fastecdsa (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [60 lines of output]
/tmp/pip-build-env-i8zvygtl/overlay/lib/python3.9/site-packages/setuptools/config/pyprojecttoml.py:66: _BetaConfiguration: Support for `[tool.setuptools]` in `pyproject.toml` is still *beta*.
config = read_configuration(filepath, True, ignore_option_errors, dist)
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/fastecdsa
copying fastecdsa/keys.py -> build/lib.linux-x86_64-cpython-39/fastecdsa
copying fastecdsa/point.py -> build/lib.linux-x86_64-cpython-39/fastecdsa
copying fastecdsa/__init__.py -> build/lib.linux-x86_64-cpython-39/fastecdsa
copying fastecdsa/curve.py -> build/lib.linux-x86_64-cpython-39/fastecdsa
copying fastecdsa/benchmark.py -> build/lib.linux-x86_64-cpython-39/fastecdsa
copying fastecdsa/ecdsa.py -> build/lib.linux-x86_64-cpython-39/fastecdsa
copying fastecdsa/util.py -> build/lib.linux-x86_64-cpython-39/fastecdsa
creating build/lib.linux-x86_64-cpython-39/fastecdsa/encoding
copying fastecdsa/encoding/__init__.py -> build/lib.linux-x86_64-cpython-39/fastecdsa/encoding
copying fastecdsa/encoding/der.py -> build/lib.linux-x86_64-cpython-39/fastecdsa/encoding
copying fastecdsa/encoding/pem.py -> build/lib.linux-x86_64-cpython-39/fastecdsa/encoding
copying fastecdsa/encoding/asn1.py -> build/lib.linux-x86_64-cpython-39/fastecdsa/encoding
copying fastecdsa/encoding/sec1.py -> build/lib.linux-x86_64-cpython-39/fastecdsa/encoding
copying fastecdsa/encoding/util.py -> build/lib.linux-x86_64-cpython-39/fastecdsa/encoding
creating build/lib.linux-x86_64-cpython-39/fastecdsa/tests
copying fastecdsa/tests/test_nonce_generation.py -> build/lib.linux-x86_64-cpython-39/fastecdsa/tests
copying fastecdsa/tests/test_rfc6979_ecdsa.py -> build/lib.linux-x86_64-cpython-39/fastecdsa/tests
copying fastecdsa/tests/__init__.py -> build/lib.linux-x86_64-cpython-39/fastecdsa/tests
copying fastecdsa/tests/test_key_recovery.py -> build/lib.linux-x86_64-cpython-39/fastecdsa/tests
copying fastecdsa/tests/test_brainpool_ecdh.py -> build/lib.linux-x86_64-cpython-39/fastecdsa/tests
copying fastecdsa/tests/test_whitespace_parsing.py -> build/lib.linux-x86_64-cpython-39/fastecdsa/tests
copying fastecdsa/tests/test_keygen.py -> build/lib.linux-x86_64-cpython-39/fastecdsa/tests
copying fastecdsa/tests/test_whycheproof_vectors.py -> build/lib.linux-x86_64-cpython-39/fastecdsa/tests
copying fastecdsa/tests/test_key_export_import.py -> build/lib.linux-x86_64-cpython-39/fastecdsa/tests
copying fastecdsa/tests/test_point.py -> build/lib.linux-x86_64-cpython-39/fastecdsa/tests
copying fastecdsa/tests/test_prehashed.py -> build/lib.linux-x86_64-cpython-39/fastecdsa/tests
copying fastecdsa/tests/test_p256_ecdsa.py -> build/lib.linux-x86_64-cpython-39/fastecdsa/tests
copying fastecdsa/tests/test_prime_field_curve_math.py -> build/lib.linux-x86_64-cpython-39/fastecdsa/tests
creating build/lib.linux-x86_64-cpython-39/fastecdsa/tests/encoding
copying fastecdsa/tests/encoding/test_der.py -> build/lib.linux-x86_64-cpython-39/fastecdsa/tests/encoding
copying fastecdsa/tests/encoding/__init__.py -> build/lib.linux-x86_64-cpython-39/fastecdsa/tests/encoding
copying fastecdsa/tests/encoding/test_sec1.py -> build/lib.linux-x86_64-cpython-39/fastecdsa/tests/encoding
running egg_info
writing fastecdsa.egg-info/PKG-INFO
writing dependency_links to fastecdsa.egg-info/dependency_links.txt
writing top-level names to fastecdsa.egg-info/top_level.txt
reading manifest file 'fastecdsa.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
adding license file 'LICENSE'
writing manifest file 'fastecdsa.egg-info/SOURCES.txt'
running build_ext
building 'fastecdsa.curvemath' extension
creating build/temp.linux-x86_64-cpython-39
creating build/temp.linux-x86_64-cpython-39/src
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Isrc/ -I/usr/include/python3.9 -c src/curve.c -o build/temp.linux-x86_64-cpython-39/src/curve.o -O2
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Isrc/ -I/usr/include/python3.9 -c src/curveMath.c -o build/temp.linux-x86_64-cpython-39/src/curveMath.o -O2
In file included from src/curveMath.c:1:
src/curveMath.h:4:10: fatal error: Python.h: No such file or directory
4 | #include <Python.h>
| ^~~~~~~~~~
compilation terminated.
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 fastecdsa
Failed to build fastecdsa
ERROR: Could not build wheels for fastecdsa, which is required to install pyproject.toml-based projects
Hey @eliotstock, thank you for the feedback. It was really painful to install everything using python. But now you can do it with the new tooling which makes it much easier.
In the environment setup, this step fails on installing
fastecdsa
:I'm using
pyenv
, I've used Python 3.9.0 for myvirtualenv
and have activated it.It's failing to find the
Python.h
header, which is in these places on my machine:But the gcc build is looking for it here:
-I/usr/include/python3.9
I'm running Ubuntu 23.04:
I considered whether I could install an APK for Python 3.9 that would provide
/usr/include/python3.9
. Note that I can't use thedeadsnakes
PPA, because that only supports LTS versions of Ubuntu and I'm on 23.04.I also considered just giving up on
pyenv
and usingvenv
, butvenv
has problems of its own:I recall that changing the system Python on Ubuntu breaks the OS badly. So I won't be doing that.
This (closed) bug on
fastecdsa
is relevant: https://github.com/AntonKueltz/fastecdsa/issues/81But
python3.9-dev
is not an available package on 23.04:Here's what I do have installed for Python 3.9:
-minimal
sounds bad here but I can find no way to getpython3.9-dev
installed.Of course, the workaround is just to use the docker container.
Full output of the
pip install
attempt: