Issue 1:
By example, the issue is that NumPy scalars are formatted to strings differently:

import numpy as np

x = np.float32(101.1)
print(f"unexpected: {x}") # unexpected: 101.0999984741211
print(f"expected str: {x!s}") # expected str: 101.1
print(f"expected repr: {x!r}") # expected repr: 101.1
print(f"expected ascii: {x!a}") # expected ascii: 101.1

The unexpected outcome is because the 32-bit float value is converted to native Python double precision, and then formatted as a string type. The last three examples with expected outputs use a format conversion field, which call (e.g.) __repr__.

A suggested fix would be to implement a __format__ method for (some?) numpy scalar types.

Issue 2:
Describe the issue:

This could be related:

pypa/setuptools#3197 (comment)

Latest numpy release (1.22.3) cannot build from source when using latest setuptools.

Reproduce the code example:

python3 -m pip install -Uv setuptools==61.3.1
python3 -m pip install -Uv git+https://github.com/numpy/numpy.git@v1.22.3

Error message:

#9 529.2 Using pip 22.0.4 from /usr/local/lib/python3.9/dist-packages/pip (python 3.9)
#9 529.3 Looking in indexes: https://mirrors.aliyun.com/pypi/simple
#9 529.3 Processing ./mirrored-pip-GRCQUK/numpy
#9 529.5 Installing build dependencies: started
#9 529.5 Running command pip subprocess to install build dependencies
#9 531.1 Looking in indexes: https://mirrors.aliyun.com/pypi/simple
#9 531.1 Ignoring packaging: markers 'platform_machine == "arm64"' don't match your environment
#9 531.7 Collecting setuptools==59.2.0
#9 531.8 Downloading https://mirrors.aliyun.com/pypi/packages/18/ad/ec41343a49a0371ea40daf37b1ba2c11333cdd121cb378161635d14b9750/setuptools-59.2.0-py3-none-any.whl (952 kB)
#9 533.1 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 952.0/952.0 KB 734.9 kB/s eta 0:00:00
#9 533.2 Collecting wheel==0.37.0
#9 533.2 Downloading https://mirrors.aliyun.com/pypi/packages/04/80/cad93b40262f5d09f6de82adbee452fd43cdff60830b56a74c5930f7e277/wheel-0.37.0-py2.py3-none-any.whl (35 kB)
#9 534.0 Collecting Cython<3.0,>=0.29.24
#9 534.0 Downloading https://mirrors.aliyun.com/pypi/packages/9a/26/d2b6bc4cb7d716c82ebc89690cbd5ba0f547db364809cd42dad34d593182/Cython-0.29.28-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (1.9 MB)
#9 536.6 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.9/1.9 MB 761.3 kB/s eta 0:00:00
#9 536.9 Installing collected packages: wheel, setuptools, Cython
#9 537.8 Successfully installed Cython-0.29.28 setuptools-59.2.0 wheel-0.37.0
#9 537.8 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
#9 537.9 Installing build dependencies: finished with status 'done'
#9 537.9 Getting requirements to build wheel: started
#9 537.9 Running command Getting requirements to build wheel
#9 538.3 Running from numpy source directory.
#9 539.2 error: Multiple top-level packages discovered in a flat-layout: ['numpy', 'branding'].
#9 539.2
#9 539.2 To avoid accidental inclusion of unwanted files or directories,
#9 539.2 setuptools will not proceed with this build.
#9 539.2
#9 539.2 If you are trying to create a single distribution with multiple packages
#9 539.2 on purpose, you should not rely on automatic discovery.
#9 539.2 Instead, consider the following options:
#9 539.2
#9 539.2 1. set up custom discovery (`find` directive with `include` or `exclude`)
#9 539.2 2. use a `src-layout`
#9 539.2 3. explicitly set `py_modules` or `packages` with a list of names
#9 539.2
#9 539.2 To find more information, look for "package discovery" on setuptools docs.
#9 539.3 error: subprocess-exited-with-error
#9 539.3
#9 539.3 × Getting requirements to build wheel did not run successfully.
#9 539.3 │ exit code: 1
#9 539.3 ╰─> See above for output.
#9 539.3
#9 539.3 note: This error originates from a subprocess, and is likely not a problem with pip.
#9 539.3 full command: /usr/bin/python3 /usr/local/lib/python3.9/dist-packages/pip/_vendor/pep517/in_process/_in_process.py get_requires_for_build_wheel /tmp/tmpis1s8vl8
#9 539.3 cwd: /tmp/scratch/mirrored-pip-GRCQUK/numpy
#9 539.3 Getting requirements to build wheel: finished with status 'error'
#9 539.3 error: subprocess-exited-with-error
#9 539.3
#9 539.3 × Getting requirements to build wheel did not run successfully.
#9 539.3 │ exit code: 1
#9 539.3 ╰─> See above for output.
#9 539.3
#9 539.3 note: This error originates from a subprocess, and is likely not a problem with pip.

NumPy/Python version information:

Numpy 1.22.3

Python 3.9

Debian 11

Setuptools 61.3.1