flupke / pypotrace

Python bindings for potrace library
Other
166 stars 43 forks source link

How to install pypotrace on Mac M1 Sonoma 14.1(Solution) #51

Closed oncealong closed 7 months ago

oncealong commented 7 months ago

My computer info, my cpu is m1.

23.1.0 Darwin Kernel Version 23.1.0: Mon Oct  9 21:27:24 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T6000 arm64

For me, if I install it directly according to the github guide, I will get an error. install command like

# step 1:
brew install libagg pkg-config potrace
# step 2:
pip install pypotrace
## or
git clone https://github.com/flupke/pypotrace.git
cd pypotrace
pip install numpy
pip install .

errors like:

pip install .
Processing /Users/xxxxxx/Downloads/pypotrace
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: numpy in /opt/homebrew/Caskroom/miniforge/base/envs/pypotrace/lib/python3.11/site-packages (from potrace==0.3) (1.26.4)
Building wheels for collected packages: potrace
  Building wheel for potrace (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for potrace (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [70 lines of output]
      /private/var/folders/bz/__145y293d94dg6zsklnfmt80000gn/T/pip-build-env-9judqgb7/overlay/lib/python3.11/site-packages/Cython/Compiler/Main.py:381: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: /Users/xxxxxx/Downloads/pypotrace/potrace/_potrace.pxd
        tree = Parsing.p_module(s, pxd, full_module_name)
      warning: potrace/_potrace.pyx:328:30: Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). Each pointer declaration should be on its own line.
      warning: potrace/_potrace.pyx:328:35: Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). Each pointer declaration should be on its own line.
      warning: potrace/_potrace.pyx:328:40: Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). Each pointer declaration should be on its own line.
      /private/var/folders/bz/__145y293d94dg6zsklnfmt80000gn/T/pip-build-env-9judqgb7/overlay/lib/python3.11/site-packages/Cython/Compiler/Main.py:381: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: /Users/xxxxxx/Downloads/pypotrace/potrace/agg/curves.pxd
        tree = Parsing.p_module(s, pxd, full_module_name)
      /private/var/folders/bz/__145y293d94dg6zsklnfmt80000gn/T/pip-build-env-9judqgb7/overlay/lib/python3.11/site-packages/Cython/Compiler/Main.py:381: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: /Users/xxxxxx/Downloads/pypotrace/potrace/bezier.pxd
        tree = Parsing.p_module(s, pxd, full_module_name)
      ['-I/opt/homebrew/Cellar/libagg/2.5_1/include/agg2']
      ['-L/opt/homebrew/Cellar/libagg/2.5_1/lib', '-Wl,-rpath,/opt/homebrew/Cellar/libagg/2.5_1/lib', '-lagg']
      Compiling potrace/_potrace.pyx because it changed.
      Compiling potrace/bezier.pyx because it changed.
      Compiling potrace/agg/curves.pyx because it changed.
      [1/3] Cythonizing potrace/_potrace.pyx
      [2/3] Cythonizing potrace/agg/curves.pyx
      [3/3] Cythonizing potrace/bezier.pyx
      running build
      running build_py
      creating /Users/xxxxxx/Downloads/pypotrace/build
      creating /Users/xxxxxx/Downloads/pypotrace/build/lib.macosx-11.1-arm64-cpython-311
      creating /Users/xxxxxx/Downloads/pypotrace/build/lib.macosx-11.1-arm64-cpython-311/potrace
      copying potrace/__init__.py -> /Users/xxxxxx/Downloads/pypotrace/build/lib.macosx-11.1-arm64-cpython-311/potrace
      creating /Users/xxxxxx/Downloads/pypotrace/build/lib.macosx-11.1-arm64-cpython-311/potrace/agg
      copying potrace/agg/__init__.py -> /Users/xxxxxx/Downloads/pypotrace/build/lib.macosx-11.1-arm64-cpython-311/potrace/agg
      copying potrace/_potrace.c -> /Users/xxxxxx/Downloads/pypotrace/build/lib.macosx-11.1-arm64-cpython-311/potrace
      copying potrace/bezier.pxd -> /Users/xxxxxx/Downloads/pypotrace/build/lib.macosx-11.1-arm64-cpython-311/potrace
      copying potrace/bezier.cpp -> /Users/xxxxxx/Downloads/pypotrace/build/lib.macosx-11.1-arm64-cpython-311/potrace
      copying potrace/_potrace.pxd -> /Users/xxxxxx/Downloads/pypotrace/build/lib.macosx-11.1-arm64-cpython-311/potrace
      copying potrace/__init__.py -> /Users/xxxxxx/Downloads/pypotrace/build/lib.macosx-11.1-arm64-cpython-311/potrace
      copying potrace/_potrace.pyx -> /Users/xxxxxx/Downloads/pypotrace/build/lib.macosx-11.1-arm64-cpython-311/potrace
      copying potrace/bezier.pyx -> /Users/xxxxxx/Downloads/pypotrace/build/lib.macosx-11.1-arm64-cpython-311/potrace
      copying potrace/agg/curves.pyx -> /Users/xxxxxx/Downloads/pypotrace/build/lib.macosx-11.1-arm64-cpython-311/potrace/agg
      copying potrace/agg/basics.pxd -> /Users/xxxxxx/Downloads/pypotrace/build/lib.macosx-11.1-arm64-cpython-311/potrace/agg
      copying potrace/agg/__init__.py -> /Users/xxxxxx/Downloads/pypotrace/build/lib.macosx-11.1-arm64-cpython-311/potrace/agg
      copying potrace/agg/curves.pxd -> /Users/xxxxxx/Downloads/pypotrace/build/lib.macosx-11.1-arm64-cpython-311/potrace/agg
      copying potrace/agg/curves.cpp -> /Users/xxxxxx/Downloads/pypotrace/build/lib.macosx-11.1-arm64-cpython-311/potrace/agg
      running build_ext
      building 'potrace._potrace' extension
      creating /Users/xxxxxx/Downloads/pypotrace/build/temp.macosx-11.1-arm64-cpython-311
      creating /Users/xxxxxx/Downloads/pypotrace/build/temp.macosx-11.1-arm64-cpython-311/potrace
      clang -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /opt/homebrew/Caskroom/miniforge/base/envs/pypotrace/include -arch arm64 -fPIC -O2 -isystem /opt/homebrew/Caskroom/miniforge/base/envs/pypotrace/include -arch arm64 -I/private/var/folders/bz/__145y293d94dg6zsklnfmt80000gn/T/pip-build-env-9judqgb7/overlay/lib/python3.11/site-packages/numpy/core/include -I/private/var/folders/bz/__145y293d94dg6zsklnfmt80000gn/T/pip-build-env-9judqgb7/overlay/lib/python3.11/site-packages/numpy/core/include -I/opt/homebrew/Caskroom/miniforge/base/envs/pypotrace/include/python3.11 -c potrace/_potrace.c -o /Users/xxxxxx/Downloads/pypotrace/build/temp.macosx-11.1-arm64-cpython-311/potrace/_potrace.o
      potrace/_potrace.c:1247:10: fatal error: 'potracelib.h' file not found
      #include "potracelib.h"
               ^~~~~~~~~~~~~~
      1 error generated.
      error: command '/usr/bin/clang' failed with exit code 1
      Traceback (most recent call last):
        File "/opt/homebrew/Caskroom/miniforge/base/envs/pypotrace/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/opt/homebrew/Caskroom/miniforge/base/envs/pypotrace/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/opt/homebrew/Caskroom/miniforge/base/envs/pypotrace/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 251, in build_wheel
          return _build_backend().build_wheel(wheel_directory, config_settings,
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/bz/__145y293d94dg6zsklnfmt80000gn/T/pip-build-env-9judqgb7/overlay/lib/python3.11/site-packages/poetry/core/masonry/api.py", line 58, in build_wheel
          return WheelBuilder.make_in(
                 ^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/bz/__145y293d94dg6zsklnfmt80000gn/T/pip-build-env-9judqgb7/overlay/lib/python3.11/site-packages/poetry/core/masonry/builders/wheel.py", line 88, in make_in
          wb.build(target_dir=directory)
        File "/private/var/folders/bz/__145y293d94dg6zsklnfmt80000gn/T/pip-build-env-9judqgb7/overlay/lib/python3.11/site-packages/poetry/core/masonry/builders/wheel.py", line 121, in build
          self._build(zip_file)
        File "/private/var/folders/bz/__145y293d94dg6zsklnfmt80000gn/T/pip-build-env-9judqgb7/overlay/lib/python3.11/site-packages/poetry/core/masonry/builders/wheel.py", line 182, in _build
          self._run_build_command(setup)
        File "/private/var/folders/bz/__145y293d94dg6zsklnfmt80000gn/T/pip-build-env-9judqgb7/overlay/lib/python3.11/site-packages/poetry/core/masonry/builders/wheel.py", line 248, in _run_build_command
          subprocess.check_call([
        File "/opt/homebrew/Caskroom/miniforge/base/envs/pypotrace/lib/python3.11/subprocess.py", line 413, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['/opt/homebrew/Caskroom/miniforge/base/envs/pypotrace/bin/python', '/Users/xxxxxx/Downloads/pypotrace/setup.py', 'build', '-b', '/Users/xxxxxx/Downloads/pypotrace/build', '--build-purelib', '/Users/xxxxxx/Downloads/pypotrace/build/lib', '--build-platlib', '/Users/xxxxxx/Downloads/pypotrace/build/lib.macosx-11.1-arm64-cpython-311']' returned non-zero exit status 1.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for potrace
Failed to build potrace
ERROR: Could not build wheels for potrace, which is required to install pyproject.toml-based projects

After many attempts and reading various github issues, I found the solution, modify build.py, add include path and lib path.

git clone https://github.com/flupke/pypotrace.git
cd pypotrace
pip install numpy

edit build.py likes:

extensions = [
        Extension(
            "potrace._potrace",
            sources=["potrace/_potrace.pyx"],
            include_dirs=[np.get_include(), '/opt/homebrew/opt/potrace/include/'],
            library_dirs=['/opt/homebrew/opt/potrace/lib/'],
            libraries=["potrace"],
        ),
        Extension(
            "potrace.bezier",
            sources=["potrace/bezier.pyx"],
            include_dirs=[np.get_include(), '/opt/homebrew/opt/libagg/include/'],
            language="c++",
            extra_compile_args=extra_compile_args,
            extra_link_args=extra_link_args,
        ),
        Extension(
            "potrace.agg.curves",
            sources=["potrace/agg/curves.pyx"],
            include_dirs=[np.get_include(), '/opt/homebrew/opt/libagg/include/'],
            language="c++",
            extra_compile_args=extra_compile_args,
            extra_link_args=extra_link_args,
        ),
    ]

install pypotrace likes:

pip install .

I submitted the modification code to one of my temporary branches: https://github.com/oncealong/pypotrace/commit/7ae1b69860dd52c3dc09bd888f65ae9d1a0b62a1

This is a temporary solution. I am not familiar with the pip build process. It would be better if someone familiar with pip can send an MR.

kevinlinxc commented 6 months ago

Your advice worked, but then I ran into these errors:

      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:97:60: note: insert '_Nullable' if the pointer may be null
      int     sigprocmask(int, const sigset_t * __restrict, sigset_t * __restrict);
                                                                     ^
                                                                       _Nullable
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:97:60: note: insert '_Nonnull' if the pointer should never be null
      int     sigprocmask(int, const sigset_t * __restrict, sigset_t * __restrict);
                                                                     ^
                                                                       _Nonnull
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:100:31: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
      int     sigsuspend(const sigset_t *) __DARWIN_ALIAS_C(sigsuspend);
                                        ^
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:100:31: note: insert '_Nullable' if the pointer may be null
      int     sigsuspend(const sigset_t *) __DARWIN_ALIAS_C(sigsuspend);
                                        ^
                                         _Nullable
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:100:31: note: insert '_Nonnull' if the pointer should never be null
      int     sigsuspend(const sigset_t *) __DARWIN_ALIAS_C(sigsuspend);
                                        ^
                                         _Nonnull
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:101:28: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
      int     sigwait(const sigset_t * __restrict, int * __restrict) __DARWIN_ALIAS_C(sigwait);
                                     ^
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:101:28: note: insert '_Nullable' if the pointer may be null
      int     sigwait(const sigset_t * __restrict, int * __restrict) __DARWIN_ALIAS_C(sigwait);
                                     ^
                                       _Nullable
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:101:28: note: insert '_Nonnull' if the pointer should never be null
      int     sigwait(const sigset_t * __restrict, int * __restrict) __DARWIN_ALIAS_C(sigwait);
                                     ^
                                       _Nonnull
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:101:46: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
      int     sigwait(const sigset_t * __restrict, int * __restrict) __DARWIN_ALIAS_C(sigwait);
                                                       ^
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:101:46: note: insert '_Nullable' if the pointer may be null
      int     sigwait(const sigset_t * __restrict, int * __restrict) __DARWIN_ALIAS_C(sigwait);
                                                       ^
                                                         _Nullable
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:101:46: note: insert '_Nonnull' if the pointer should never be null
      int     sigwait(const sigset_t * __restrict, int * __restrict) __DARWIN_ALIAS_C(sigwait);
                                                       ^
                                                         _Nonnull
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:103:30: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
      void    psignal(int, const char *);
                                      ^
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:103:30: note: insert '_Nullable' if the pointer may be null
      void    psignal(int, const char *);
                                      ^
                                       _Nullable
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:103:30: note: insert '_Nonnull' if the pointer should never be null
      void    psignal(int, const char *);
                                      ^
                                       _Nonnull
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:108:31: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
      int     sigvec(int, struct sigvec *, struct sigvec *);
                                        ^
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:108:31: note: insert '_Nullable' if the pointer may be null
      int     sigvec(int, struct sigvec *, struct sigvec *);
                                        ^
                                         _Nullable
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:108:31: note: insert '_Nonnull' if the pointer should never be null
      int     sigvec(int, struct sigvec *, struct sigvec *);
                                        ^
                                         _Nonnull
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:108:48: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
      int     sigvec(int, struct sigvec *, struct sigvec *);
                                                         ^
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:108:48: note: insert '_Nullable' if the pointer may be null
      int     sigvec(int, struct sigvec *, struct sigvec *);
                                                         ^
                                                          _Nullable
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:108:48: note: insert '_Nonnull' if the pointer should never be null
      int     sigvec(int, struct sigvec *, struct sigvec *);
                                                         ^
                                                          _Nonnull
      In file included from potrace/bezier.cpp:1534:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/complex:236:
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:320:5: error: <cmath> tried including <math.h> but didn't find libc++'s <math.h> header.           This usually means that your header search paths are not configured properly.           The header search paths should contain the C++ Standard Library headers before           any C Standard Library, and you are probably using compiler flags that make that           not be the case.
      #   error <cmath> tried including <math.h> but didn't find libc++'s <math.h> header. \
          ^
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:587:17: error: expected unqualified-id
          return std::isnan(__lcpp_x);
                      ^
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/math.h:166:5: note: expanded from macro 'isnan'
          ( sizeof(x) == sizeof(float)  ? __inline_isnanf((float)(x))          \
          ^
      In file included from potrace/bezier.cpp:1534:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/complex:236:
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:607:17: error: expected unqualified-id
          return std::isinf(__lcpp_x);
                      ^
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/math.h:161:5: note: expanded from macro 'isinf'
          ( sizeof(x) == sizeof(float)  ? __inline_isinff((float)(x))          \
          ^
      In file included from potrace/bezier.cpp:1534:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/complex:236:
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:646:38: error: no member named '__promote' in namespace 'std'
                                      std::__promote<_A1, _A2> >::type
                                      ~~~~~^
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:646:48: error: '_A1' does not refer to a value
                                      std::__promote<_A1, _A2> >::type
                                                     ^
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:643:17: note: declared here
      template <class _A1, class _A2>
                      ^
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:646:58: error: expected unqualified-id
                                      std::__promote<_A1, _A2> >::type
                                                               ^
      In file included from potrace/bezier.cpp:1534:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/complex:236:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:833:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:421:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/invoke.h:15:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__type_traits/apply_cv.h:15:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__type_traits/remove_reference.h:13:
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cstddef:46:5: error: <cstddef> tried including <stddef.h> but didn't find libc++'s <stddef.h> header.           This usually means that your header search paths are not configured properly.           The header search paths should contain the C++ Standard Library headers before           any C Standard Library, and you are probably using compiler flags that make that           not be the case.
      #   error <cstddef> tried including <stddef.h> but didn't find libc++'s <stddef.h> header. \
          ^
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cstddef:59:9: error: no member named 'nullptr_t' in the global namespace
      using ::nullptr_t;
            ~~^
      In file included from potrace/bezier.cpp:1534:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/complex:236:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:833:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:456:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__type_traits/is_compound.h:14:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__type_traits/is_fundamental.h:14:
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__type_traits/is_null_pointer.h:24:49: error: use of undeclared identifier 'nullptr_t'
      template <>          struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
                                                      ^
      In file included from potrace/bezier.cpp:1534:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/complex:236:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:833:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:538:
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cstdint:149:5: error: <cstdint> tried including <stdint.h> but didn't find libc++'s <stdint.h> header.           This usually means that your header search paths are not configured properly.           The header search paths should contain the C++ Standard Library headers before           any C Standard Library, and you are probably using compiler flags that make that           not be the case.
      #   error <cstdint> tried including <stdint.h> but didn't find libc++'s <stdint.h> header. \
          ^
      In file included from potrace/bezier.cpp:1534:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/complex:238:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/stdexcept:46:
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cstdlib:90:5: error: <cstdlib> tried including <stdlib.h> but didn't find libc++'s <stdlib.h> header.           This usually means that your header search paths are not configured properly.           The header search paths should contain the C++ Standard Library headers before           any C Standard Library, and you are probably using compiler flags that make that           not be the case.
      #   error <cstdlib> tried including <stdlib.h> but didn't find libc++'s <stdlib.h> header. \
          ^
      In file included from potrace/bezier.cpp:1534:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/complex:238:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/stdexcept:47:
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/exception:199:45: error: field has incomplete type 'exception_ptr'
          _LIBCPP_INLINE_VISIBILITY exception_ptr(nullptr_t) _NOEXCEPT : __ptr_() {}
                                                  ^
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/exception:194:24: note: definition of 'std::exception_ptr' is not complete until the closing '}'
      class _LIBCPP_TYPE_VIS exception_ptr
                             ^
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/exception:199:5: error: '__abi_tag__' attribute only applies to structs, variables, functions, and namespaces
          _LIBCPP_INLINE_VISIBILITY exception_ptr(nullptr_t) _NOEXCEPT : __ptr_() {}
          ^
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:709:37: note: expanded from macro '_LIBCPP_INLINE_VISIBILITY'
      #  define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
                                          ^
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:688:26: note: expanded from macro '_LIBCPP_HIDE_FROM_ABI'
                __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_VERSIONED_IDENTIFIER))))
                               ^
      In file included from potrace/bezier.cpp:1534:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/complex:238:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/stdexcept:47:
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/exception:199:55: error: expected ';' at end of declaration list
          _LIBCPP_INLINE_VISIBILITY exception_ptr(nullptr_t) _NOEXCEPT : __ptr_() {}
                                                            ^
      In file included from potrace/bezier.cpp:1534:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/complex:243:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/sstream:191:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/istream:165:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/ostream:168:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/shared_ptr.h:31:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:17:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/hash.h:28:
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cstring:66:5: error: <cstring> tried including <string.h> but didn't find libc++'s <string.h> header.           This usually means that your header search paths are not configured properly.           The header search paths should contain the C++ Standard Library headers before           any C Standard Library, and you are probably using compiler flags that make that           not be the case.
      #   error <cstring> tried including <string.h> but didn't find libc++'s <string.h> header. \
          ^
      In file included from potrace/bezier.cpp:1534:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/complex:243:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/sstream:191:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/istream:165:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/ostream:168:
      In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/shared_ptr.h:31:
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:188:32: error: member 'nullptr_t' declared as a template
        _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {}
                                     ^
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:188:42: error: expected ';' at end of declaration list
        _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {}
                                               ^
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:265:81: error: unknown type name 'nullptr_t'
        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(nullptr_t) _NOEXCEPT {
                                                                                      ^
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:386:32: error: member 'nullptr_t' declared as a template
        _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {}
                                     ^
      fatal error: too many errors emitted, stopping now [-ferror-limit=]

This answer on SO solved it for me: https://apple.stackexchange.com/a/462888/509971,

I just did

cd /Library/Developer/CommandLineTools/SDKs
sudo mv MacOSX.sdk MacOSX_old.sdk

and then went back to pypotrace and did pip install . and it worked. Hope I could help someone!

lky1433223 commented 5 months ago

Thanks a lot. I have the same question, and solved it according to your guidence