iriusrisk / startleft

StartLeft is an automation tool for generating Threat Models written in the Open Threat Model (OTM) format from a variety of different sources such as IaC files, diagrams or projects exported from Threat Modelling tools.
https://iriusrisk.github.io/startleft/
Apache License 2.0
48 stars 13 forks source link

Issues with pygraphviz on MAC M1 #329

Open muddassir-khan-r opened 1 year ago

muddassir-khan-r commented 1 year ago

Using legacy 'setup.py install' for pygraphviz, since package 'wheel' is not installed. Installing collected packages: zipp, sniffio, rpds-py, idna, exceptiongroup, attrs, typing-extensions, referencing, packaging, MarkupSafe, importlib-resources, anyio, urllib3, tomli, starlette, six, setuptools, pydantic, pluggy, platformdirs, pkgutil-resolve-name, numpy, lark, jsonschema-specifications, Jinja2, iniconfig, importlib-metadata, h11, filelock, distlib, deprecation, click, charset-normalizer, certifi, vsdx, virtualenv, uvicorn, types-PyYAML, shapely, setuptools-scm, requests, pyyaml, python-multipart, python-magic, python-hcl2, pytest, pyproject-api, pygraphviz, ordered-set, networkx, jsonschema, jmespath, httpcore, google-re2, fastapi, dependency-injector, defusedxml, deepmerge, colorama, chardet, cachetools, tox, startleft, responses, pytest-runner, pytest-mock, httpx, deepdiff, coverage Attempting uninstall: setuptools Found existing installation: setuptools 56.0.0 Uninstalling setuptools-56.0.0: Successfully uninstalled setuptools-56.0.0 Running setup.py install for pygraphviz ... error ERROR: Command errored out with exit status 1: command: /Users/m.khan/tools/startleft/startleft/venv/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/9h/k99tbk6n0vz456t433hyhcrs629579/T/pip-install-kmyhn_ry/pygraphviz_19d94bd2da6c4225a948b1c01b9e187f/setup.py'"'"'; file='"'"'/private/var/folders/9h/k99tbk6n0vz456t433hyhcrs629579/T/pip-install-kmyhn_ry/pygraphviz_19d94bd2da6c4225a948b1c01b9e187f/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/9h/k99tbk6n0vz456t433hyhcrs629579/T/pip-record-pnwve_ji/install-record.txt --single-version-externally-managed --compile --install-headers /Users/m.khan/tools/startleft/startleft/venv/include/site/python3.8/pygraphviz cwd: /private/var/folders/9h/k99tbk6n0vz456t433hyhcrs629579/T/pip-install-kmyhn_ry/pygraphviz_19d94bd2da6c4225a948b1c01b9e187f/ Complete output (87 lines): running install /Users/m.khan/tools/startleft/startleft/venv/lib/python3.8/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated. !!

        ********************************************************************************
        Please avoid running ``setup.py`` directly.
        Instead, use pypa/build, pypa/installer, pypa/build or
        other standards-based tools.

        See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
        ********************************************************************************

!!
  self.initialize_options()
running build
running build_py
creating build
creating build/lib.macosx-11-universal2-cpython-38
creating build/lib.macosx-11-universal2-cpython-38/pygraphviz
copying pygraphviz/scraper.py -> build/lib.macosx-11-universal2-cpython-38/pygraphviz
copying pygraphviz/graphviz.py -> build/lib.macosx-11-universal2-cpython-38/pygraphviz
copying pygraphviz/__init__.py -> build/lib.macosx-11-universal2-cpython-38/pygraphviz
copying pygraphviz/agraph.py -> build/lib.macosx-11-universal2-cpython-38/pygraphviz
copying pygraphviz/testing.py -> build/lib.macosx-11-universal2-cpython-38/pygraphviz
creating build/lib.macosx-11-universal2-cpython-38/pygraphviz/tests
copying pygraphviz/tests/test_unicode.py -> build/lib.macosx-11-universal2-cpython-38/pygraphviz/tests
copying pygraphviz/tests/test_scraper.py -> build/lib.macosx-11-universal2-cpython-38/pygraphviz/tests
copying pygraphviz/tests/test_readwrite.py -> build/lib.macosx-11-universal2-cpython-38/pygraphviz/tests
copying pygraphviz/tests/test_string.py -> build/lib.macosx-11-universal2-cpython-38/pygraphviz/tests
copying pygraphviz/tests/__init__.py -> build/lib.macosx-11-universal2-cpython-38/pygraphviz/tests
copying pygraphviz/tests/test_html.py -> build/lib.macosx-11-universal2-cpython-38/pygraphviz/tests
copying pygraphviz/tests/test_node_attributes.py -> build/lib.macosx-11-universal2-cpython-38/pygraphviz/tests
copying pygraphviz/tests/test_drawing.py -> build/lib.macosx-11-universal2-cpython-38/pygraphviz/tests
copying pygraphviz/tests/test_repr_mimebundle.py -> build/lib.macosx-11-universal2-cpython-38/pygraphviz/tests
copying pygraphviz/tests/test_subgraph.py -> build/lib.macosx-11-universal2-cpython-38/pygraphviz/tests
copying pygraphviz/tests/test_close.py -> build/lib.macosx-11-universal2-cpython-38/pygraphviz/tests
copying pygraphviz/tests/test_edge_attributes.py -> build/lib.macosx-11-universal2-cpython-38/pygraphviz/tests
copying pygraphviz/tests/test_clear.py -> build/lib.macosx-11-universal2-cpython-38/pygraphviz/tests
copying pygraphviz/tests/test_layout.py -> build/lib.macosx-11-universal2-cpython-38/pygraphviz/tests
copying pygraphviz/tests/test_attribute_defaults.py -> build/lib.macosx-11-universal2-cpython-38/pygraphviz/tests
copying pygraphviz/tests/test_graph.py -> build/lib.macosx-11-universal2-cpython-38/pygraphviz/tests
running egg_info
writing pygraphviz.egg-info/PKG-INFO
writing dependency_links to pygraphviz.egg-info/dependency_links.txt
writing top-level names to pygraphviz.egg-info/top_level.txt
ERROR setuptools_scm._file_finders.git listing git files failed - pretending there aren't any
reading manifest file '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 'pygraphviz.egg-info/SOURCES.txt'
copying pygraphviz/graphviz.i -> build/lib.macosx-11-universal2-cpython-38/pygraphviz
copying pygraphviz/graphviz_wrap.c -> build/lib.macosx-11-universal2-cpython-38/pygraphviz
running build_ext
building 'pygraphviz._graphviz' extension
creating build/temp.macosx-11-universal2-cpython-38
creating build/temp.macosx-11-universal2-cpython-38/pygraphviz
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -DSWIG_PYTHON_STRICT_BYTE_CHAR -I/Users/m.khan/tools/startleft/startleft/venv/include -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c pygraphviz/graphviz_wrap.c -o build/temp.macosx-11-universal2-cpython-38/pygraphviz/graphviz_wrap.o
pygraphviz/graphviz_wrap.c:1756:7: warning: 'tp_print' is deprecated [-Wdeprecated-declarations]
      0,                                    /* tp_print */
      ^
/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8/cpython/object.h:260:5: note: 'tp_print' has been explicitly marked deprecated here
    Py_DEPRECATED(3.8) int (*tp_print)(PyObject *, FILE *, int);
    ^
/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8/pyport.h:515:54: note: expanded from macro 'Py_DEPRECATED'
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
                                                     ^
pygraphviz/graphviz_wrap.c:1923:7: warning: 'tp_print' is deprecated [-Wdeprecated-declarations]
      0,                                    /* tp_print */
      ^
/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8/cpython/object.h:260:5: note: 'tp_print' has been explicitly marked deprecated here
    Py_DEPRECATED(3.8) int (*tp_print)(PyObject *, FILE *, int);
    ^
/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8/pyport.h:515:54: note: expanded from macro 'Py_DEPRECATED'
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
                                                     ^
pygraphviz/graphviz_wrap.c:2711:10: fatal error: 'graphviz/cgraph.h' file not found
#include "graphviz/cgraph.h"
         ^~~~~~~~~~~~~~~~~~~
2 warnings and 1 error generated.
error: command '/usr/bin/gcc' failed with exit code 1
----------------------------------------

ERROR: Command errored out with exit status 1: /Users/m.khan/tools/startleft/startleft/venv/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/9h/k99tbk6n0vz456t433hyhcrs629579/T/pip-install-kmyhn_ry/pygraphviz_19d94bd2da6c4225a948b1c01b9e187f/setup.py'"'"'; file='"'"'/private/var/folders/9h/k99tbk6n0vz456t433hyhcrs629579/T/pip-install-kmyhn_ry/pygraphviz_19d94bd2da6c4225a948b1c01b9e187f/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/9h/k99tbk6n0vz456t433hyhcrs629579/T/pip-record-pnwve_ji/install-record.txt --single-version-externally-managed --compile --install-headers /Users/m.khan/tools/startleft/startleft/venv/include/site/python3.8/pygraphviz Check the logs for full command output.

dantolin-iriusrisk commented 1 year ago

Hi, @muddassir-khan-r! First of all, thank you for your interest in StartLeft!

We had experienced issues when locally installing StartLeft related to pygraphviz. This Python lib depends on OS packages to work that are a bit tricky to install. Please, take a look at this troubleshooting section, where some particular configuration for MacOS is provided.

As extra advice, once you have correctly configured Graphviz following the link above, I would try to install pygraphviz and StartLeft in separate steps to get cleaner info on the error, if it persists. If you do so, you need to install a specific version with this command: pip install pygraphviz==1.10.