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

[BUG] option --include-path not recognized (pygraphviz) #2740

Closed
1 task done
anastasiiakim opened this issue Jul 23, 2021 · 12 comments
Closed
1 task done

[BUG] option --include-path not recognized (pygraphviz) #2740

anastasiiakim opened this issue Jul 23, 2021 · 12 comments
Labels

Comments

@anastasiiakim
Copy link

setuptools version

57.4.0

Python version

3.8.5

OS

10.15.7 Catalina

Additional environment information

No response

Description

Posted the issue here:pygraphviz/pygraphviz#361

Tried to install with --include-option and --global-option but it fails:
pip install --global-option="-I/usr/local/include/graphviz/" --global-option="-L/usr/local/lib/graphviz" pygraphviz
pip install pygraphviz --install-option="--include-path=/usr/local/include/graphviz/" --install-option="--library-path=/usr/local/lib/graphviz"

Expected behavior

I installed graphviz but it seems pip install pygraphviz doesn't know where the graphviz is so I tried to include path to it with --include-path and global-options, but they are not recognizable.

How to Reproduce

brew install graphviz
pip install --global-option="-I/usr/local/include/graphviz/" --global-option="-L/usr/local/lib/graphviz" pygraphviz
pip install pygraphviz --install-option="--include-path=/usr/local/include/graphviz/" --install-option="--library-path=/usr/local/lib/graphviz"

Output

Collecting pygraphviz
Using cached pygraphviz-1.7.zip (118 kB)
Skipping wheel build for pygraphviz, due to binaries being disabled for it.
Installing collected packages: pygraphviz
Running setup.py install for pygraphviz ... error
ERROR: Command errored out with exit status 1:
command: /opt/anaconda3/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/z1/9v98kv1j6kj_wdm9f2v1x7s80012jb/T/pip-install-opnitgqo/pygraphviz_940432cb2c62475896c051ed944a799d/setup.py'"'"'; file='"'"'/private/var/folders/z1/9v98kv1j6kj_wdm9f2v1x7s80012jb/T/pip-install-opnitgqo/pygraphviz_940432cb2c62475896c051ed944a799d/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /private/var/folders/z1/9v98kv1j6kj_wdm9f2v1x7s80012jb/T/pip-record-w717thbz/install-record.txt --single-version-externally-managed --compile --install-headers /opt/anaconda3/include/python3.8/pygraphviz --include-path=/usr/local/include/graphviz/ --library-path=/usr/local/lib/graphviz
cwd: /private/var/folders/z1/9v98kv1j6kj_wdm9f2v1x7s80012jb/T/pip-install-opnitgqo/pygraphviz_940432cb2c62475896c051ed944a799d/
Complete output (6 lines):
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 --include-path not recognized
----------------------------------------

ERROR: Command errored out with exit status 1: /opt/anaconda3/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/z1/9v98kv1j6kj_wdm9f2v1x7s80012jb/T/pip-install-opnitgqo/pygraphviz_940432cb2c62475896c051ed944a799d/setup.py'"'"'; file='"'"'/private/var/folders/z1/9v98kv1j6kj_wdm9f2v1x7s80012jb/T/pip-install-opnitgqo/pygraphviz_940432cb2c62475896c051ed944a799d/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /private/var/folders/z1/9v98kv1j6kj_wdm9f2v1x7s80012jb/T/pip-record-w717thbz/install-record.txt --single-version-externally-managed --compile --install-headers /opt/anaconda3/include/python3.8/pygraphviz --include-path=/usr/local/include/graphviz/ --library-path=/usr/local/lib/graphviz Check the logs for full command output.

Code of Conduct

  • I agree to follow the PSF Code of Conduct
@anastasiiakim anastasiiakim added bug Needs Triage Issues that need to be evaluated for severity and status. labels Jul 23, 2021
@DiddiLeija
Copy link
Member

Hi @anastasiiakim. I don't think this is a setuptools issue. If I search --include-path on the setuptools documentation, I find nothing related to that "option".

I believe this could be an Anaconda issue, or even a pip issue, I'm not sure. Any suggestions from the maintainers?

@phetdam
Copy link

phetdam commented Aug 21, 2021

install command help does not show any --include-path flag. /usr/local/include should be part of the system include path and so you shouldn't need to specify headers, but if you need to, I think what you are looking for is probably the --include-dirs/-I flag for build_ext, which must be run to build the pygraphviz._graphviz C extension in the pygraphviz setup.py.

You can pass extra commands and options to setup.py before the install command with --global-option, so following the example in the pygraphviz documentation, try something like

pip install --global-option=build_ext --global-option="-I/usr/local/include/graphviz/" \
    --global-option="-L/usr/local/lib/graphviz" pygraphviz

I think what you are missing was the initial passing of build_ext to pip before the -I, -L flags. Worse comes to worse, you can always clone the pygraphviz repo, checkout the desired tag, and in the repo home run

python setup.py build_ext -I/usr/local/include/graphviz/ -L/usr/local/lib/graphviz --inplace && pip install .

This will manually trigger the build_ext command with the right flags, build the pygraphviz._graphviz C extension inplace (shared object in same directory as the source file) and then do a proper pip install of the package.

@jaraco jaraco changed the title [BUG] [BUG] option --include-path not recognized (pygraphviz) Sep 12, 2021
@jaraco jaraco added invalid and removed bug Needs Triage Issues that need to be evaluated for severity and status. labels Sep 12, 2021
@jaraco
Copy link
Member

jaraco commented Sep 12, 2021

From my reading it looks like the issue was addressed. Thanks for reporting and thanks everyone for chiming in to help.

@jaraco jaraco closed this as completed Sep 12, 2021
@alxrcs
Copy link

alxrcs commented Apr 4, 2022

Just to add to the above, if you've installed graphviz via homebrew (as of 3.0.0) the paths are as follows.

pip install --global-option=build_ext --global-option="-I/opt/homebrew/Cellar/graphviz/3.0.0/include/" \
          --global-option="-L/opt/homebrew/Cellar/graphviz/3.0.0/lib" pygraphviz

EDIT: I ran into other issues after that, so if you're using Conda as I was, it's probably easier to just do

conda install --channel conda-forge pygraphviz

...as mentioned in pygraphviz/pygraphviz#400

@csquires
Copy link

Above almost worked for me, but my homebrew (version 3.4.7) had a different path:
pip install --global-option=build_ext --global-option="-I/usr/local/include/" --global-option="-L/usr/local/lib/" pygraphviz

@fleicher
Copy link

@csquires, Thank you that worked for me as well.

@noHairMan
Copy link

noHairMan commented Feb 22, 2023

python3.10
macOS 13.1

brew install graphviz
pip install --global-option=build_ext --global-option="-I/opt/homebrew/Cellar/graphviz/7.1.0/include" --global-option="-L/opt/homebrew/Cellar/graphviz/7.1.0/lib" pygraphviz

@ColdZoo
Copy link

ColdZoo commented Oct 19, 2023

It looks like the documentation for quick-start in Readme.md is outdated. Maybe we should replace --install-option with : pip install --global-option=build_ext --global-option="-I/usr/local/include/" --global-option="-L/usr/local/lib/" pygraphviz

@matthosking-mydeal
Copy link

For Windows users, this took me waaayyyy too long to work out:
pip3 install --config-settings="--global-option=build_ext" --config-settings="--global-option=-IC:\Program Files\Graphviz\include" --config-settings="--global-option=-LC:\Program Files\Graphviz\lib" pygraphviz

@nlpx
Copy link

nlpx commented Jan 3, 2024

For Windows users, this took me waaayyyy too long to work out: pip3 install --config-settings="--global-option=build_ext" --config-settings="--global-option=-IC:\Program Files\Graphviz\include" --config-settings="--global-option=-LC:\Program Files\Graphviz\lib" pygraphviz

Can confirm. This was painful.

@phetdam
Copy link

phetdam commented Jan 4, 2024

Wow, more than 2.5 years since I last commented and this thread is still relevant.

For any other future PyGraphviz users, the installation docs should be very helpful as it more or less addresses all the issues raised here, e.g. include/linker search paths when building via build_ext. This does require that you already have a C compiler installed, however, so Windows users should make sure they have the Visual Studio compiler installed.

Although it would be nice if the PyGraphviz folks could pre-package standalone binary wheels a la NumPy, etc., they mention in the PyGraphviz documentation install guide that there are a few complications regarding this since the way the PyGraphviz extension is built requires Graphviz executables, libraries, and headers to be available at compile time as mentioned in the installation FAQ. Graphviz has existed for far longer than PyGraphviz has and was originally a standalone set of C programs + libraries typically called from the command line, e.g. the dot tool for drawing directed graphs.

In a sense you can consider this building-from-source exercise a modern taste of the old ./configure && make idiom that used to be the de-factor standard for building GNU software, which was canonically distributed in source form.

@wockerman
Copy link

For Windows users, this took me waaayyyy too long to work out: pip3 install --config-settings="--global-option=build_ext" --config-settings="--global-option=-IC:\Program Files\Graphviz\include" --config-settings="--global-option=-LC:\Program Files\Graphviz\lib" pygraphviz

make sure to also upgrade pip on windows with:
python.exe -m pip install --upgrade pip

In case you get an error using the above pip3 install command like:

  Collecting pygraphviz
  Using cached pygraphviz-1.12.tar.gz (104 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]
      usage: _in_process.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
         or: _in_process.py --help [cmd1 cmd2 ...]
         or: _in_process.py --help-commands
         or: _in_process.py cmd --help
     
      error: option -L not recognized

I my case this upgraded pip from 23.0.1 to 24.0

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

No branches or pull requests