Dev Build on mac

pip install -e . “suddenly” stopped working for me on MacOS 13.1. It’s possible I haven’t tried since 13.1 upgrade, but not sure. Looks like tis failing on freetype. Any hints?

Building wheels for collected packages: matplotlib
  Building editable for matplotlib (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building editable for matplotlib (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [97 lines of output]
      /private/var/folders/kx/4c3bx_w92t31pqyvg6ws03200000gn/T/pip-build-env-hgw8x14v/overlay/lib/python3.10/site-packages/setuptools/dist.py:285: SetuptoolsDeprecationWarning: The namespace_packages parameter is deprecated, consider using implicit namespaces instead (PEP 420).
        warnings.warn(msg, SetuptoolsDeprecationWarning)

      Edit mplsetup.cfg to change the build options; suppress output with --quiet.

      BUILDING MATPLOTLIB
            python: yes [3.10.6 | packaged by conda-forge | (main, Aug 22 2022,
                        20:41:22) [Clang 13.0.1 ]]
          platform: yes [darwin]
             tests: no  [skipping due to configuration]
            macosx: yes [installing]

      running editable_wheel
      creating /private/var/folders/kx/4c3bx_w92t31pqyvg6ws03200000gn/T/pip-wheel-vuvac8ev/.tmp-9kdikhzw/matplotlib.egg-info
      writing /private/var/folders/kx/4c3bx_w92t31pqyvg6ws03200000gn/T/pip-wheel-vuvac8ev/.tmp-9kdikhzw/matplotlib.egg-info/PKG-INFO
      writing dependency_links to /private/var/folders/kx/4c3bx_w92t31pqyvg6ws03200000gn/T/pip-wheel-vuvac8ev/.tmp-9kdikhzw/matplotlib.egg-info/dependency_links.txt
      writing namespace_packages to /private/var/folders/kx/4c3bx_w92t31pqyvg6ws03200000gn/T/pip-wheel-vuvac8ev/.tmp-9kdikhzw/matplotlib.egg-info/namespace_packages.txt
      writing requirements to /private/var/folders/kx/4c3bx_w92t31pqyvg6ws03200000gn/T/pip-wheel-vuvac8ev/.tmp-9kdikhzw/matplotlib.egg-info/requires.txt
      writing top-level names to /private/var/folders/kx/4c3bx_w92t31pqyvg6ws03200000gn/T/pip-wheel-vuvac8ev/.tmp-9kdikhzw/matplotlib.egg-info/top_level.txt
      writing manifest file '/private/var/folders/kx/4c3bx_w92t31pqyvg6ws03200000gn/T/pip-wheel-vuvac8ev/.tmp-9kdikhzw/matplotlib.egg-info/SOURCES.txt'
      adding license file 'LICENSE/LICENSE'
      adding license file 'LICENSE/LICENSE_AMSFONTS'
      adding license file 'LICENSE/LICENSE_BAKOMA'
      adding license file 'LICENSE/LICENSE_CARLOGO'
      adding license file 'LICENSE/LICENSE_COLORBREWER'
      adding license file 'LICENSE/LICENSE_COURIERTEN'
      adding license file 'LICENSE/LICENSE_JSXTOOLS_RESIZE_OBSERVER'
      adding license file 'LICENSE/LICENSE_QT4_EDITOR'
      adding license file 'LICENSE/LICENSE_SOLARIZED'
      adding license file 'LICENSE/LICENSE_STIX'
      adding license file 'LICENSE/LICENSE_YORICK'
      writing manifest file '/private/var/folders/kx/4c3bx_w92t31pqyvg6ws03200000gn/T/pip-wheel-vuvac8ev/.tmp-9kdikhzw/matplotlib.egg-info/SOURCES.txt'
      creating '/private/var/folders/kx/4c3bx_w92t31pqyvg6ws03200000gn/T/pip-wheel-vuvac8ev/.tmp-9kdikhzw/matplotlib-3.7.0.dev1267+gff17bc3bc2.dist-info'
      creating /private/var/folders/kx/4c3bx_w92t31pqyvg6ws03200000gn/T/pip-wheel-vuvac8ev/.tmp-9kdikhzw/matplotlib-3.7.0.dev1267+gff17bc3bc2.dist-info/WHEEL
      Installing /var/folders/kx/4c3bx_w92t31pqyvg6ws03200000gn/T/tmpoqg_c0pumatplotlib-3.7.0.dev1267+gff17bc3bc2-0.editable-cp310-cp310-macosx_11_0_arm64.whl/matplotlib-3.7.0-nspkg.pth
      running build_py
      running build_ext
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /Users/jklymak/miniconda3/envs/mpl-dev/include -arch arm64 -fPIC -O2 -isystem /Users/jklymak/miniconda3/envs/mpl-dev/include -arch arm64 -I/Users/jklymak/miniconda3/envs/mpl-dev/include/python3.10 -c /var/folders/kx/4c3bx_w92t31pqyvg6ws03200000gn/T/tmpx0dd16fi.cpp -o var/folders/kx/4c3bx_w92t31pqyvg6ws03200000gn/T/tmpx0dd16fi.o -fvisibility=hidden
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /Users/jklymak/miniconda3/envs/mpl-dev/include -arch arm64 -fPIC -O2 -isystem /Users/jklymak/miniconda3/envs/mpl-dev/include -arch arm64 -I/Users/jklymak/miniconda3/envs/mpl-dev/include/python3.10 -c /var/folders/kx/4c3bx_w92t31pqyvg6ws03200000gn/T/tmpr8kcfodl.cpp -o var/folders/kx/4c3bx_w92t31pqyvg6ws03200000gn/T/tmpr8kcfodl.o -fvisibility-inlines-hidden
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /Users/jklymak/miniconda3/envs/mpl-dev/include -arch arm64 -fPIC -O2 -isystem /Users/jklymak/miniconda3/envs/mpl-dev/include -arch arm64 -I/Users/jklymak/miniconda3/envs/mpl-dev/include/python3.10 -c /var/folders/kx/4c3bx_w92t31pqyvg6ws03200000gn/T/tmprqh6vnxi.cpp -o var/folders/kx/4c3bx_w92t31pqyvg6ws03200000gn/T/tmprqh6vnxi.o -flto

      FreeType build system -- automatic system detection

      The following settings are used:

        platform                    unix
        compiler                    clang
        configuration directory     ./builds/unix
        configuration rules         ./builds/unix/unix.mk

      If this does not correspond to your system or settings please remove the file
      `config.mk' from this directory then read the INSTALL file for help.

      Otherwise, simply type `/Library/Developer/CommandLineTools/usr/bin/make' again to build the library,
      or `/Library/Developer/CommandLineTools/usr/bin/make refdoc' to build the API reference (this needs python >= 2.6).

      cd builds/unix; \
                  ./configure  '--with-zlib=no' '--with-bzip2=no' '--with-png=no' '--with-harfbuzz=no' '--enable-static' '--disable-shared' '--host=arm64-apple-darwin20.0.0'
      checking build system type... arm-apple-darwin22.2.0
      checking host system type... Invalid configuration `arm64-apple-darwin20.0.0': machine `arm64-apple' not recognized
      configure: error: /bin/sh ./config.sub arm64-apple-darwin20.0.0 failed
      make: *** [setup] Error 1
      Traceback (most recent call last):
        File "/private/var/folders/kx/4c3bx_w92t31pqyvg6ws03200000gn/T/pip-build-env-hgw8x14v/overlay/lib/python3.10/site-packages/setuptools/command/editable_wheel.py", line 140, in run
          self._create_wheel_file(bdist_wheel)
        File "/private/var/folders/kx/4c3bx_w92t31pqyvg6ws03200000gn/T/pip-build-env-hgw8x14v/overlay/lib/python3.10/site-packages/setuptools/command/editable_wheel.py", line 330, in _create_wheel_file
          files, mapping = self._run_build_commands(dist_name, unpacked, lib, tmp)
        File "/private/var/folders/kx/4c3bx_w92t31pqyvg6ws03200000gn/T/pip-build-env-hgw8x14v/overlay/lib/python3.10/site-packages/setuptools/command/editable_wheel.py", line 261, in _run_build_commands
          self._run_build_subcommands()
        File "/private/var/folders/kx/4c3bx_w92t31pqyvg6ws03200000gn/T/pip-build-env-hgw8x14v/overlay/lib/python3.10/site-packages/setuptools/command/editable_wheel.py", line 288, in _run_build_subcommands
          self.run_command(name)
        File "/private/var/folders/kx/4c3bx_w92t31pqyvg6ws03200000gn/T/pip-build-env-hgw8x14v/overlay/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
          self.distribution.run_command(command)
        File "/private/var/folders/kx/4c3bx_w92t31pqyvg6ws03200000gn/T/pip-build-env-hgw8x14v/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 1208, in run_command
          super().run_command(command)
        File "/private/var/folders/kx/4c3bx_w92t31pqyvg6ws03200000gn/T/pip-build-env-hgw8x14v/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/private/var/folders/kx/4c3bx_w92t31pqyvg6ws03200000gn/T/pip-build-env-hgw8x14v/overlay/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 84, in run
          _build_ext.run(self)
        File "/private/var/folders/kx/4c3bx_w92t31pqyvg6ws03200000gn/T/pip-build-env-hgw8x14v/overlay/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 346, in run
          self.build_extensions()
        File "<string>", line 183, in build_extensions
        File "/Users/jklymak/matplotlib/setupext.py", line 654, in do_custom_build
          subprocess.check_call(configure, env=env, cwd=src_path)
        File "/Users/jklymak/miniconda3/envs/mpl-dev/lib/python3.10/subprocess.py", line 369, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['./configure', '--with-zlib=no', '--with-bzip2=no', '--with-png=no', '--with-harfbuzz=no', '--enable-static', '--disable-shared', '--host=arm64-apple-darwin20.0.0']' returned non-zero exit status 2.
      Building freetype in build/freetype-2.6.1
      error: Support for editable installs via PEP 660 was recently introduced
      in `setuptools`. If you are seeing this error, please report to:

      https://github.com/pypa/setuptools/issues

      Meanwhile you can try the legacy behavior by setting an
      environment variable and trying to install again:

      SETUPTOOLS_ENABLE_FEATURES="legacy-editable"
      [end of output]

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

This seems to be an issue with the host reported by conda

a conda python:

(mpl-dev) tcaswell@seven matplotlib % ipython
Python 3.10.6 | packaged by conda-forge | (main, Aug 22 2022, 20:41:22) [Clang 13.0.1 ]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.5.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: sysconfig.get_config_var('HOST_GNU_TYPE')
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In [1], line 1
----> 1 sysconfig.get_config_var('HOST_GNU_TYPE')

NameError: name 'sysconfig' is not defined

In [2]: import sysconfig

In [3]: sysconfig.get_config_var('HOST_GNU_TYPE')
Out[3]: 'arm64-apple-darwin20.0.0'

In [4]:

A homebrew python:

tcaswell@seven matplotlib % python3
Python 3.10.8 (main, Oct 13 2022, 09:48:40) [Clang 14.0.0 (clang-1400.0.29.102)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sysconfig
>>> sysconfig.get_config_var('HOST_GNU_TYPE')
'aarch64-apple-darwin21.6.0'
>>>

Using a venv from homebrew Python I can get it to compile and naively changing the host parameter we pass to .configure to us aarch64 rather than arm64 results in in the conda context the c-complier reporting it does not work.

I strongly suspect that in the conda case we are seeing a mixed tool chain (some chimera of conda, homebrew (at least for me), and system) with respect to the compilers.

Dropping passing --host on arm seems to work

diff --git a/environment.yml b/environment.yml
index 22cf6796ac..f82364689b 100644
--- a/environment.yml
+++ b/environment.yml
@@ -41,12 +41,12 @@ dependencies:
   - pip:
       - mpl-sphinx-theme
       - sphinxcontrib-svg2pdfconverter
-      - pikepdf
+  #    - pikepdf
   # testing
   - coverage
   - flake8>=3.8
   - flake8-docstrings>=1.4.0
-  - gtk4
+  # - gtk4
   - ipykernel
   - nbconvert[execute]!=6.0.0,!=6.0.1
   - nbformat!=5.0.0,!=5.0.1
diff --git a/setupext.py b/setupext.py
index 4d41bdd44a..4a602b2e8d 100644
--- a/setupext.py
+++ b/setupext.py
@@ -649,8 +649,13 @@ class FreeType(SetupPackage):
                 "--disable-shared"
             ]
             host = sysconfig.get_config_var('HOST_GNU_TYPE')
-            if host is not None:  # May be unset on PyPy.
+
+            if (
+                host is not None and  # May be unset on PyPy.
+                'arm64-apple' not in host # Bad value with conda-forge?
+            ):
                 configure.append(f"--host={host}")
+
             subprocess.check_call(configure, env=env, cwd=src_path)
             if 'GNUMAKE' in env:
                 make = env['GNUMAKE']

(The change to environment.yaml were needed to get the environment to re-create with py311)

Confirmed for me that commenting out the --host in setupext.py allows the dev build to work.