Unable to build Linux wheel for PyGraphviz 1.11

375 views
Skip to first unread message

George Reilly

unread,
Sep 29, 2023, 3:51:05 PM9/29/23
to pygraphviz-discuss
I'm trying to build a Linux amd64 wheel for Python 3.8 inside of a manylinux container (quay.io/pypa/manylinux2014_x86_64:2023-09-04-0828984).

I've installed graphviz as a system package:
    yum install graphviz graphviz-devel

And the results can be found here:
    [root@ef49d283544a src]# ls -l /usr/include/graphviz/cgraph.h /usr/lib64/graphviz/libgvplugin_core.so.6.0.0
    -rw-r--r-- 1 root root  17025 Oct 13  2020 /usr/include/graphviz/cgraph.h
    -rwxr-xr-x 1 root root 120024 Oct 13  2020 /usr/lib64/graphviz/libgvplugin_core.so.6.0.0

I created a virtualenv and installed recent copies of pip, setuptools, and wheel.

    /opt/python/cp38-cp38/bin/python3 -m venv /venv-graphviz-38
    /venv-graphviz-38/bin/python3 -m pip install --upgrade pip setuptools wheel

Package versions:
    [root@ef49d283544a src]# /venv-graphviz-38/bin/python3 -m pip freeze --all
    pip==23.0.1
    setuptools==68.0.0
    wheel==0.41.0

But I haven't found the right incantations to get the C code to compile:
    [root@ef49d283544a src]# /venv-graphviz-38/bin/python -m pip -vvv wheel --global-option=build_ext --build-option="-I/usr/include/graphviz/" --build-option="-L/usr/lib64/graphviz/" pygraphviz==1.11
    Created temporary directory: /tmp/pip-ephem-wheel-cache-bzqsxk0g
    Created temporary directory: /tmp/pip-build-tracker-xr49n4of
    Initialized build tracking at /tmp/pip-build-tracker-xr49n4of
    Created build tracker: /tmp/pip-build-tracker-xr49n4of
    Entered build tracker: /tmp/pip-build-tracker-xr49n4of
    Created temporary directory: /tmp/pip-wheel-4cg2ypvt
    WARNING: Implying --no-binary=:all: due to the presence of --build-option / --global-option / --install-option. Consider using --config-settings for more flexibility.
    DEPRECATION: --no-binary currently disables reading from the cache of locally built wheels. In the future --no-binary will not influence the wheel cache. pip 23.1 will enforce this behaviour change. A possible replacement is to use the --no-cache-dir option. You can use the flag --use-feature=no-binary-enable-wheel-cache to test the upcoming behaviour. Discussion can be found at https://github.com/pypa/pip/issues/11453
    Created temporary directory: /tmp/pip-ephem-wheel-cache-znau9wax
    1 location(s) to search for versions of pygraphviz:
    * https://pypi.org/simple/pygraphviz/
    Fetching project page and analyzing links: https://pypi.org/simple/pygraphviz/
    Getting page https://pypi.org/simple/pygraphviz/
    Found index url https://pypi.org/simple
    Starting new HTTPS connection (1): pypi.org:443
    https://pypi.org:443 "GET /simple/pygraphviz/ HTTP/1.1" 200 6756
    Fetched page https://pypi.org/simple/pygraphviz/ as application/vnd.pypi.simple.v1+json
      Found link https://files.pythonhosted.org/packages/aa/37/2e91cb7257c465e9cc88c0001fe40aba9d3c1f4997399b21c434f9877e64/pygraphviz-0.34.tar.gz (from https://pypi.org/simple/pygraphviz/), version: 0.34
... snip ...
      Found link https://files.pythonhosted.org/packages/53/75/729b6fed1e4246e6b6caebb5d4ff918349f7536d3ccfc5c8b686672d356b/pygraphviz-1.11rc1.zip (from https://pypi.org/simple/pygraphviz/) (requires-python:>=3.8), version: 1.11rc1
      Found link https://files.pythonhosted.org/packages/19/db/cc09516573e79a35ac73f437bdcf27893939923d1d06b439897ffc7f3217/pygraphviz-1.11.zip (from https://pypi.org/simple/pygraphviz/) (requires-python:>=3.8), version: 1.11
    Skipping link: not a file: https://pypi.org/simple/pygraphviz/
    Given no hashes to check 1 links for project 'pygraphviz': discarding no candidates
    Collecting pygraphviz==1.11
      Created temporary directory: /tmp/pip-unpack-pz9t0cyp
      Starting new HTTPS connection (1): files.pythonhosted.org:443
      https://files.pythonhosted.org:443 "GET /packages/19/db/cc09516573e79a35ac73f437bdcf27893939923d1d06b439897ffc7f3217/pygraphviz-1.11.zip HTTP/1.1" 200 120803
      Downloading pygraphviz-1.11.zip (120 kB)
         ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 120.8/120.8 kB 20.7 MB/s eta 0:00:00
      Added pygraphviz==1.11 from https://files.pythonhosted.org/packages/19/db/cc09516573e79a35ac73f437bdcf27893939923d1d06b439897ffc7f3217/pygraphviz-1.11.zip to build tracker '/tmp/pip-build-tracker-xr49n4of'
      Running setup.py (path:/tmp/pip-wheel-4cg2ypvt/pygraphviz_4ee143d595cb4c09868d5667383532da/setup.py) egg_info for package pygraphviz
      Created temporary directory: /tmp/pip-pip-egg-info-lwgzb5va
      Running command python setup.py egg_info
      running egg_info
      creating /tmp/pip-pip-egg-info-lwgzb5va/pygraphviz.egg-info
      writing /tmp/pip-pip-egg-info-lwgzb5va/pygraphviz.egg-info/PKG-INFO
      writing dependency_links to /tmp/pip-pip-egg-info-lwgzb5va/pygraphviz.egg-info/dependency_links.txt
      writing top-level names to /tmp/pip-pip-egg-info-lwgzb5va/pygraphviz.egg-info/top_level.txt
      writing manifest file '/tmp/pip-pip-egg-info-lwgzb5va/pygraphviz.egg-info/SOURCES.txt'
      reading manifest file '/tmp/pip-pip-egg-info-lwgzb5va/pygraphviz.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      warning: no files found matching '*.png' under directory 'doc'
      warning: no files found matching '*.txt' under directory 'doc'
      warning: no files found matching '*.css' under directory 'doc'
      warning: no previously-included files matching '*~' found anywhere in distribution
      warning: no previously-included files matching '*.pyc' found anywhere in distribution
      warning: no previously-included files matching '.svn' found anywhere in distribution
      no previously-included directories found matching 'doc/build'
      adding license file 'LICENSE'
      writing manifest file '/tmp/pip-pip-egg-info-lwgzb5va/pygraphviz.egg-info/SOURCES.txt'
      Preparing metadata (setup.py) ... done
      Source in /tmp/pip-wheel-4cg2ypvt/pygraphviz_4ee143d595cb4c09868d5667383532da has version 1.11, which satisfies requirement pygraphviz==1.11 from https://files.pythonhosted.org/packages/19/db/cc09516573e79a35ac73f437bdcf27893939923d1d06b439897ffc7f3217/pygraphviz-1.11.zip
      Removed pygraphviz==1.11 from https://files.pythonhosted.org/packages/19/db/cc09516573e79a35ac73f437bdcf27893939923d1d06b439897ffc7f3217/pygraphviz-1.11.zip from build tracker '/tmp/pip-build-tracker-xr49n4of'
    Created temporary directory: /tmp/pip-unpack-4yv5dkf9
    Building wheels for collected packages: pygraphviz
      Created temporary directory: /tmp/pip-wheel-two93crv
      Building wheel for pygraphviz (setup.py) ...   Destination directory: /tmp/pip-wheel-two93crv
      Running command python setup.py bdist_wheel
      usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
         or: setup.py --help [cmd1 cmd2 ...]
         or: setup.py --help-commands
         or: setup.py cmd --help

      error: option -I not recognized
      error: subprocess-exited-with-error

      × python setup.py bdist_wheel did not run successfully.
      │ exit code: 1
      ╰─> See above for output.

      note: This error originates from a subprocess, and is likely not a problem with pip.
      full command: /venv-graphviz-38/bin/python -u -c '
      exec(compile('"'"''"'"''"'"'
      # This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py
      #
      # - It imports setuptools before invoking setup.py, to enable projects that directly
      #   import from `distutils.core` to work with newer packaging standards.
      # - It provides a clear error message when setuptools is not installed.
      # - It sets `sys.argv[0]` to the underlying `setup.py`, when invoking `setup.py` so
      #   setuptools doesn'"'"'t think the script is `-c`. This avoids the following warning:
      #     manifest_maker: standard file '"'"'-c'"'"' not found".
      # - It generates a shim setup.py, for handling setup.cfg-only projects.
      import os, sys, tokenize

      try:
          import setuptools
      except ImportError as error:
          print(
              "ERROR: Can not execute `setup.py` since setuptools is not available in "
              "the build environment.",
              file=sys.stderr,
          )
          sys.exit(1)

      __file__ = %r
      sys.argv[0] = __file__

      if os.path.exists(__file__):
          filename = __file__
          with tokenize.open(__file__) as f:
              setup_py_code = f.read()
      else:
          filename = "<auto-generated setuptools caller>"
          setup_py_code = "from setuptools import setup; setup()"

      exec(compile(setup_py_code, filename, "exec"))
      '"'"''"'"''"'"' % ('"'"'/tmp/pip-wheel-4cg2ypvt/pygraphviz_4ee143d595cb4c09868d5667383532da/setup.py'"'"',), "<pip-setuptools-caller>", "exec"))' build_ext bdist_wheel -d /tmp/pip-wheel-two93crv -I/usr/include/graphviz/ -L/usr/lib64/graphviz/
      cwd: /tmp/pip-wheel-4cg2ypvt/pygraphviz_4ee143d595cb4c09868d5667383532da/
    error
      ERROR: Failed building wheel for pygraphviz
      Running setup.py clean for pygraphviz
      Running command python setup.py clean
      running build_ext
      building 'pygraphviz._graphviz' extension
      creating build
      creating build/temp.linux-x86_64-cpython-38
      creating build/temp.linux-x86_64-cpython-38/pygraphviz
      gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DSWIG_PYTHON_STRICT_BYTE_CHAR -I/venv-graphviz-38/include -I/opt/_internal/cpython-3.8.18/include/python3.8 -c pygraphviz/graphviz_wrap.c -o build/temp.linux-x86_64-cpython-38/pygraphviz/graphviz_wrap.o
      In file included from /usr/include/graphviz/gvc.h:17,
                       from pygraphviz/graphviz_wrap.c:3021:
      /usr/include/graphviz/types.h:49:10: fatal error: cgraph.h: No such file or directory
         49 | #include <cgraph.h>
            |          ^~~~~~~~~~
      compilation terminated.
      error: command '/opt/rh/devtoolset-10/root/usr/bin/gcc' failed with exit code 1
      error: subprocess-exited-with-error

      × python setup.py clean did not run successfully.
      │ exit code: 1
      ╰─> See above for output.

      note: This error originates from a subprocess, and is likely not a problem with pip.
      full command: /venv-graphviz-38/bin/python -u -c '
      exec(compile('"'"''"'"''"'"'
      # This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py
      #
      # - It imports setuptools before invoking setup.py, to enable projects that directly
      #   import from `distutils.core` to work with newer packaging standards.
      # - It provides a clear error message when setuptools is not installed.
      # - It sets `sys.argv[0]` to the underlying `setup.py`, when invoking `setup.py` so
      #   setuptools doesn'"'"'t think the script is `-c`. This avoids the following warning:
      #     manifest_maker: standard file '"'"'-c'"'"' not found".
      # - It generates a shim setup.py, for handling setup.cfg-only projects.
      import os, sys, tokenize

      try:
          import setuptools
      except ImportError as error:
          print(
              "ERROR: Can not execute `setup.py` since setuptools is not available in "
              "the build environment.",
              file=sys.stderr,
          )
          sys.exit(1)

      __file__ = %r
      sys.argv[0] = __file__

      if os.path.exists(__file__):
          filename = __file__
          with tokenize.open(__file__) as f:
              setup_py_code = f.read()
      else:
          filename = "<auto-generated setuptools caller>"
          setup_py_code = "from setuptools import setup; setup()"

      exec(compile(setup_py_code, filename, "exec"))
      '"'"''"'"''"'"' % ('"'"'/tmp/pip-wheel-4cg2ypvt/pygraphviz_4ee143d595cb4c09868d5667383532da/setup.py'"'"',), "<pip-setuptools-caller>", "exec"))' build_ext clean --all
      cwd: /tmp/pip-wheel-4cg2ypvt/pygraphviz_4ee143d595cb4c09868d5667383532da
      ERROR: Failed cleaning build dir for pygraphviz
    Failed to build pygraphviz
    ERROR: Failed to build one or more wheels
    Exception information:
    Traceback (most recent call last):
      File "/venv-graphviz-38/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 160, in exc_logging_wrapper
        status = run_func(*args)
      File "/venv-graphviz-38/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 247, in wrapper
        return func(self, options, args)
      File "/venv-graphviz-38/lib/python3.8/site-packages/pip/_internal/commands/wheel.py", line 201, in run
        raise CommandError("Failed to build one or more wheels")
    pip._internal.exceptions.CommandError: Failed to build one or more wheels
    Removed build tracker: '/tmp/pip-build-tracker-xr49n4of'

George Reilly

unread,
Sep 29, 2023, 6:29:06 PM9/29/23
to pygraphviz-discuss
I have worked around this by setting the include and library paths as environment variables:
/usr/bin/env CPATH=/usr/include/graphviz/ LIBRARY_PATH=/usr/lib64/graphviz/ \
python -m pip -v wheel --no-deps --wheel-dir ./wheels/ pygraphviz=1.11

Reply all
Reply to author
Forward
0 new messages