Build of CMSIS pack manager fails

I am following the instructions to setup mbed for the PSoC prototyping kit at https://os.mbed.com/teams/Cypress/wiki/Cypress-products-with-Mbed-OS
I am using Cygwin64 and get the following error complaining that Python.h could not be found. The Python development package is installed and the include path in the gcc command points to the correct location, highlighted below. I am a bit frustrated as I had to install a bunch of extra packages in Cygwin to get even this far.

I appreciate any help.

$ pip3 install --upgrade pip ‘mbed-ls>=1.7.1’ ‘pyocd>=0.16’
Requirement already up-to-date: pip in /usr/lib/python3.6/site-packages (20.2.2)
Collecting mbed-ls>=1.7.1
Using cached mbed-ls-1.7.12.tar.gz (174 kB)
Collecting pyocd>=0.16
Using cached pyocd-0.27.2-py2.py3-none-any.whl (7.7 MB)
Collecting PrettyTable>=0.7.2
Using cached prettytable-0.7.2.tar.bz2 (21 kB)
Collecting mbed-os-tools<0.1.0,>=0.0.9
Using cached mbed-os-tools-0.0.15.tar.gz (286 kB)
Collecting colorama
Using cached colorama-0.4.3-py2.py3-none-any.whl (15 kB)
Collecting pylink-square
Using cached pylink_square-0.6.1-py2.py3-none-any.whl (75 kB)
Collecting six<2.0,>=1.0
Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting cmsis-pack-manager>=0.2.7
Using cached cmsis-pack-manager-0.2.10.tar.gz (45 kB)
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3.6 -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-3w03u50t/cmsis-pack-manager/setup.py’"’"’; file=’"’"’/tmp/pip-install-3w03u50t/cmsis-pack-manager/setup.py’"’"’;f=getattr(tokenize, ‘"’"‘open’"’"’, open)(file);code=f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ egg_info --egg-base /tmp/pip-pip-egg-info-5_2251up
cwd: /tmp/pip-install-3w03u50t/cmsis-pack-manager/
Complete output (71 lines):
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3.6 -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-wheel-z3_iqwl6/cffi/setup.py’"’"’; file=’"’"’/tmp/pip-wheel-z3_iqwl6/cffi/setup.py’"’"’;f=getattr(tokenize, ‘"’"‘open’"’"’, open)(file);code=f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ bdist_wheel -d /tmp/pip-wheel-bm6ilgln
cwd: /tmp/pip-wheel-z3_iqwl6/cffi/
Complete output (34 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.cygwin-3.1.6-x86_64-3.6
creating build/lib.cygwin-3.1.6-x86_64-3.6/cffi
copying cffi/api.py -> build/lib.cygwin-3.1.6-x86_64-3.6/cffi
copying cffi/backend_ctypes.py -> build/lib.cygwin-3.1.6-x86_64-3.6/cffi
copying cffi/cffi_opcode.py -> build/lib.cygwin-3.1.6-x86_64-3.6/cffi
copying cffi/commontypes.py -> build/lib.cygwin-3.1.6-x86_64-3.6/cffi
copying cffi/cparser.py -> build/lib.cygwin-3.1.6-x86_64-3.6/cffi
copying cffi/error.py -> build/lib.cygwin-3.1.6-x86_64-3.6/cffi
copying cffi/ffiplatform.py -> build/lib.cygwin-3.1.6-x86_64-3.6/cffi
copying cffi/lock.py -> build/lib.cygwin-3.1.6-x86_64-3.6/cffi
copying cffi/model.py -> build/lib.cygwin-3.1.6-x86_64-3.6/cffi
copying cffi/pkgconfig.py -> build/lib.cygwin-3.1.6-x86_64-3.6/cffi
copying cffi/recompiler.py -> build/lib.cygwin-3.1.6-x86_64-3.6/cffi
copying cffi/setuptools_ext.py -> build/lib.cygwin-3.1.6-x86_64-3.6/cffi
copying cffi/vengine_cpy.py -> build/lib.cygwin-3.1.6-x86_64-3.6/cffi
copying cffi/vengine_gen.py -> build/lib.cygwin-3.1.6-x86_64-3.6/cffi
copying cffi/verifier.py -> build/lib.cygwin-3.1.6-x86_64-3.6/cffi
copying cffi/init.py -> build/lib.cygwin-3.1.6-x86_64-3.6/cffi
copying cffi/_cffi_include.h -> build/lib.cygwin-3.1.6-x86_64-3.6/cffi
copying cffi/parse_c_type.h -> build/lib.cygwin-3.1.6-x86_64-3.6/cffi
copying cffi/_embedding.h -> build/lib.cygwin-3.1.6-x86_64-3.6/cffi
copying cffi/_cffi_errors.h -> build/lib.cygwin-3.1.6-x86_64-3.6/cffi
running build_ext
building ‘_cffi_backend’ extension
creating build/temp.cygwin-3.1.6-x86_64-3.6
creating build/temp.cygwin-3.1.6-x86_64-3.6/c
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -ggdb -O2 -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -fdebug-prefix-map=/pub/devel/python/python36/python36-3.6.10-1.x86_64/build=/usr/src/debug/python36-3.6.10-1 -fdebug-prefix-map=/pub/devel/python/python36/python36-3.6.10-1.x86_64/src/Python-3.6.10=/usr/src/debug/python36-3.6.10-1 -ggdb -O2 -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -fdebug-prefix-map=/pub/devel/python/python36/python36-3.6.10-1.x86_64/build=/usr/src/debug/python36-3.6.10-1 -fdebug-prefix-map=/pub/devel/python/python36/python36-3.6.10-1.x86_64/src/Python-3.6.10=/usr/src/debug/python36-3.6.10-1 -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/python3.6m -c c/_cffi_backend.c -o build/temp.cygwin-3.1.6-x86_64-3.6/c/_cffi_backend.o
c/_cffi_backend.c:2:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command ‘gcc’ failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for cffi
ERROR: Failed to build one or more wheels
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/setuptools/installer.py”, line 128, in fetch_build_egg
subprocess.check_call(cmd)
File “/usr/lib/python3.6/subprocess.py”, line 311, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command ‘[’/usr/bin/python3.6’, ‘-m’, ‘pip’, ‘–disable-pip-version-check’, ‘wheel’, ‘–no-deps’, ‘-w’, ‘/tmp/tmpagjqkq6n’, ‘–quiet’, ‘cffi>=1.6.0’]’ returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pip-install-3w03u50t/cmsis-pack-manager/setup.py", line 73, in <module>
    test_suite="tests"
  File "/usr/lib/python3.6/site-packages/setuptools/__init__.py", line 143, in setup
    _install_setup_requires(attrs)
  File "/usr/lib/python3.6/site-packages/setuptools/__init__.py", line 138, in _install_setup_requires
    dist.fetch_build_eggs(dist.setup_requires)
  File "/usr/lib/python3.6/site-packages/setuptools/dist.py", line 698, in fetch_build_eggs
    replace_conflicting=True,
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 783, in resolve
    replace_conflicting=replace_conflicting
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1066, in best_match
    return self.obtain(req, installer)
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1078, in obtain
    return installer(requirement)
  File "/usr/lib/python3.6/site-packages/setuptools/dist.py", line 754, in fetch_build_egg
    return fetch_build_egg(self, req)
  File "/usr/lib/python3.6/site-packages/setuptools/installer.py", line 130, in fetch_build_egg
    raise DistutilsError(str(e))
distutils.errors.DistutilsError: Command '['/usr/bin/python3.6', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmpagjqkq6n', '--quiet', 'cffi>=1.6.0']' returned non-zero exit status 1.
----------------------------------------

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Most of the time these are dependency-issues. Python.h is used by GNU Compiler Collection (gcc) to build applications. You need to install a package called python-dev for building Python modules, extending the Python interpreter or embedding Python in applications. You encounter “Python.h: No such file or directory” error while trying to build a shared library using the file extension of another language ( e.g. ‘C’ ). If you are trying to build a shared library using the file extension of another language, you need to install the correct development version of Python.

Reason for this error:

  • You haven’t properly installed the header files and static libraries for python dev.
  • Also, sometimes include files might not be default in the include path.

How to solve this error:

  • Install the missing files and libraries.
  • Include Path and Library.
  • Finally, Compile it.