Issue 1:
I am using Anaconda Python distribution. I have noticed, that among 1000 randomly generated unitary matrices (that I get from QR decomposition), there always is one "bad" matrix. It is bad in the sense of results of DGETRF -- it returns the same pivot twice.

Here is simple example of what is happening (pivot 247 is duplicated):

In [1]: import numpy as np

In [2]: np.random.seed(100)

In [3]: a = [np.linalg.qr(np.random.randn(1800, 60))[0].copy(order='F') for i in range(141)]

In [4]: from scipy.linalg.lapack import dgetrf

In [5]: dgetrf(a[140])[2]
Out[5]: 0

In [6]: dgetrf(a[140])[1]
Out[6]:
array([ 624, 1296, 240, 285, 538, 762, 748, 1318, 247, 793, 470,
1604, 247, 1461, 1694, 975, 781, 80, 805, 1160, 580, 79,
226, 65, 225, 771, 1403, 242, 515, 1450, 213, 822, 552,
842, 326, 1223, 248, 702, 350, 1625, 873, 620, 349, 660,
1663, 406, 547, 749, 1230, 1585, 488, 1298, 1475, 408, 993,
578, 1068, 1108, 1405, 248], dtype=int32)

I also attach matrix in npz format, which is "bad" for scipy.linalg.lapack.dgetrf (pivot 810 is duplicated)

matrix.zip

However, if I use scipy.linalg.lu, then no pivot is duplicated, although resulting pivots are, practically, the same, as from scipy.linalg.lapack.dgetrf

Issue 2:
Describe your issue.

Hi, I just got the MBA M1 and I am trying to install SciPy, but for some reason I am getting errors which I don't quite understand. Would appreciate any advice on how to move forward. I am running Monterey 12.0.1. I have been able to install most libraries, just scipy has been giving me problems. The whole error message is too long to post, but I can reply with relevant information, just get back to me on this thread.

Reproducing Code Example

~ % brew --version
Homebrew 3.3.3
Homebrew/homebrew-core (git revision 4530cc439e5; last commit 2021-11-12)
Homebrew/homebrew-cask (git revision e60e8f7a05; last commit 2021-11-13)
~ % pip install cython pybind11 pythran numpy
Requirement already satisfied: cython in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (0.29.24)
Requirement already satisfied: pybind11 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (2.8.1)
Requirement already satisfied: pythran in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (0.10.0)
Requirement already satisfied: numpy in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (1.21.4)
Requirement already satisfied: beniget~=0.4.0 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from pythran) (0.4.1)
Requirement already satisfied: gast~=0.5.0 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from pythran) (0.5.2)
Requirement already satisfied: ply>=3.4 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from pythran) (3.11)
~ % OPENBLAS=$(brew --prefix openblas) CFLAGS="-falign-functions=8 ${CFLAGS}" pip install --no-use-pep517 scipy==1.7.0

Error message

ollecting scipy==1.7.0
Using cached scipy-1.7.0.tar.gz (36.1 MB)
Preparing metadata (setup.py) ... done
Requirement already satisfied: numpy<1.23.0,>=1.16.5 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from scipy==1.7.0) (1.21.4)
Building wheels for collected packages: scipy
Building wheel for scipy (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/lx/_pkqc2sj3x9g0yfndm_4n4vh0000gn/T/pip-install-otct1we2/scipy_443d1f5e1f1e403f84a3325c1b1e3401/setup.py'"'"'; __file__='"'"'/private/var/folders/lx/_pkqc2sj3x9g0yfndm_4n4vh0000gn/T/pip-install-otct1we2/scipy_443d1f5e1f1e403f84a3325c1b1e3401/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'"'"'))' bdist_wheel -d /private/var/folders/lx/_pkqc2sj3x9g0yfndm_4n4vh0000gn/T/pip-wheel-uozvxwo6
cwd: /private/var/folders/lx/_pkqc2sj3x9g0yfndm_4n4vh0000gn/T/pip-install-otct1we2/scipy_443d1f5e1f1e403f84a3325c1b1e3401/

error: Command "ar rcs build/temp.macosx-10.9-universal2-3.9/libsc_cephes.a build/temp.macosx-10.9-universal2-3.9/scipy/special/cephes/scipy_iv.o build/temp.macosx-10.9-universal2-3.9/scipy/special/cephes/shichi.o build/temp.macosx-10.9-universal2-3.9/scipy/special/cephes/sici.o build/temp.macosx-10.9-universal2-3.9/scipy/special/cephes/sindg.o build/temp.macosx-10.9-universal2-3.9/scipy/special/cephes/sinpi.o build/temp.macosx-10.9-universal2-3.9/scipy/special/cephes/spence.o build/temp.macosx-10.9-universal2-3.9/scipy/special/cephes/stdtr.o build/temp.macosx-10.9-universal2-3.9/scipy/special/cephes/struve.o build/temp.macosx-10.9-universal2-3.9/scipy/special/cephes/tandg.o build/temp.macosx-10.9-universal2-3.9/scipy/special/cephes/tukey.o build/temp.macosx-10.9-universal2-3.9/scipy/special/cephes/unity.o build/temp.macosx-10.9-universal2-3.9/scipy/special/cephes/yn.o build/temp.macosx-10.9-universal2-3.9/scipy/special/cephes/yv.o build/temp.macosx-10.9-universal2-3.9/scipy/special/cephes/zeta.o build/temp.macosx-10.9-universal2-3.9/scipy/special/cephes/zetac.o" failed with exit status 1

########### CLIB COMPILER OPTIMIZATION ###########
Platform :
Architecture: unsupported
Compiler : gcc

CPU baseline :
Requested : optimization disabled
Enabled : none
Flags : none
Extra checks: none
Requested : optimization disabled

CPU dispatch :
Enabled : none
Generated : none
CCompilerOpt.cache_flush[809] : write cache to path -> /private/var/folders/lx/_pkqc2sj3x9g0yfndm_4n4vh0000gn/T/pip-install-otct1we2/scipy_443d1f5e1f1e403f84a3325c1b1e3401/build/temp.macosx-10.9-universal2-3.9/ccompiler_opt_cache_clib.py
----------------------------------------
ERROR: Command errored out with exit status 1: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/lx/_pkqc2sj3x9g0yfndm_4n4vh0000gn/T/pip-install-otct1we2/scipy_443d1f5e1f1e403f84a3325c1b1e3401/setup.py'"'"'; __file__='"'"'/private/var/folders/lx/_pkqc2sj3x9g0yfndm_4n4vh0000gn/T/pip-install-otct1we2/scipy_443d1f5e1f1e403f84a3325c1b1e3401/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/lx/_pkqc2sj3x9g0yfndm_4n4vh0000gn/T/pip-record-bkv6xrzk/install-record.txt --single-version-externally-managed --compile --install-headers /Library/Frameworks/Python.framework/Versions/3.9/include/python3.9/scipy Check the logs for full command output.

SciPy/NumPy/Python version information

print(numpy.version, sys.version_info) 1.21.4 sys.version_info(major=3, minor=9, micro=8, releaselevel='final', serial=0)