Repository: python-control/Slycot (language: python)

Issue:
Cannot build or install slycot on Ubuntu
I'm not able to get slycot to install on Ubuntu 22.04. 

This can be reproduced in docker: from a vanilla ubuntu, I install all dependancies then try to perform a pip install:

```
docker container run -it ubuntu bash
```


```
apt update ; apt install python3 python3-dev gcc gfortran libopenblas-dev python3-pip cmake
pip install numpy scikit-build
pip install -v slycot
```

But I end up with the following error:

```
  Traceback (most recent call last):
    File "/usr/local/bin/f2py3", line 8, in <module>
      sys.exit(main())
    File "/tmp/pip-build-env-ve213n4q/overlay/local/lib/python3.10/dist-packages/numpy/f2py/f2py2e.py", line 704, in main
      run_main(sys.argv[1:])
    File "/tmp/pip-build-env-ve213n4q/overlay/local/lib/python3.10/dist-packages/numpy/f2py/f2py2e.py", line 441, in run_main
      postlist = callcrackfortran(files, options)
    File "/tmp/pip-build-env-ve213n4q/overlay/local/lib/python3.10/dist-packages/numpy/f2py/f2py2e.py", line 342, in callcrackfortran
      postlist = crackfortran.crackfortran(files)
    File "/tmp/pip-build-env-ve213n4q/overlay/local/lib/python3.10/dist-packages/numpy/f2py/crackfortran.py", line 3265, in crackfortran
      postlist = postcrack(grouplist[0])
    File "/tmp/pip-build-env-ve213n4q/overlay/local/lib/python3.10/dist-packages/numpy/f2py/crackfortran.py", line 1967, in postcrack
      g = postcrack(g, tab=tab + '\t')
    File "/tmp/pip-build-env-ve213n4q/overlay/local/lib/python3.10/dist-packages/numpy/f2py/crackfortran.py", line 1986, in postcrack
      block['body'] = analyzebody(block, args, tab=tab)
    File "/tmp/pip-build-env-ve213n4q/overlay/local/lib/python3.10/dist-packages/numpy/f2py/crackfortran.py", line 2150, in analyzebody
      not b['body'] and not b['implementedby']:
  KeyError: 'implementedby'
  gmake[2]: *** [slycot/CMakeFiles/_wrapper.dir/build.make:79: slycot/_wrappermodule.c] Error 1
  gmake[1]: *** [CMakeFiles/Makefile2:170: slycot/CMakeFiles/_wrapper.dir/all] Error 2
  gmake: *** [Makefile:136: all] Error 2
    File "/tmp/pip-build-env-ve213n4q/overlay/local/lib/python3.10/dist-packages/skbuild/setuptools_wrap.py", line 645, in setup
      cmkr.make(make_args, install_target=cmake_install_target, env=env)
    File "/tmp/pip-build-env-ve213n4q/overlay/local/lib/python3.10/dist-packages/skbuild/cmaker.py", line 680, in make
      self.make_impl(clargs=clargs, config=config, source_dir=source_dir, install_target=install_target, env=env)
    File "/tmp/pip-build-env-ve213n4q/overlay/local/lib/python3.10/dist-packages/skbuild/cmaker.py", line 704, in make_impl
      raise SKBuildError(
```

Note that I get the same error when trying to build master from source directly.


Discussion / hints:
- What comes after the `SKBuildError(` ?
- Have you tried using the `python3-numpy-dev` package from Ubuntu instead of pip?

> ```
> apt update ; apt install python3 python3-dev gcc gfortran libopenblas-dev python3-pip cmake
> pip install numpy scikit-build
> pip install -v slycot
> ```

I can reproduce the error with the exact same commands in a docker container, but it built successfully if I installed python3-numpy with apt first and don't get any intermediate pip installations of numpy or scikit-build.

Strangely enough:

```
root@baaf58a31626:/# apt update ; apt install python3 python3-dev gcc gfortran libopenblas-dev python3-pip cmake python3-numpy
...
Get:155 http://archive.ubuntu.com/ubuntu jammy/main amd64 python3-numpy amd64 1:1.21.5-1build2 [3464 kB]
...
root@baaf58a31626:/# pip install -v slycot
...
  Collecting numpy
    Downloading numpy-1.23.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.0 MB)
...
Successfully installed cmake-3.22.5 distro-1.7.0 numpy-1.23.0 packaging-21.3 pyparsing-3.0.9 scikit-build-0.15.0 setuptools-62.6.0 wheel-0.37.1
...
  -- Found NumPy: /usr/lib/python3/dist-packages/numpy/core/include (found version "1.21.5")
...
Successfully installed slycot-0.4.0
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
```

So maybe you found an incompatibility with NumPy 1.23.0


Fix patch:
diff --git a/.github/conda-env/build-env.yml b/.github/conda-env/build-env.yml
index f747a77e..64ef8932 100644
--- a/.github/conda-env/build-env.yml
+++ b/.github/conda-env/build-env.yml
@@ -1,4 +1,4 @@
 name: build-env
 dependencies:
   - boa
-  - numpy
+  - numpy!=1.23.0
diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml
index 55314c06..b3e846db 100644
--- a/conda-recipe/meta.yaml
+++ b/conda-recipe/meta.yaml
@@ -27,7 +27,7 @@ requirements:
     - libcblas * *netlib
     - liblapack * *netlib
     - python
-    - numpy
+    - numpy!=1.23.0
     - pip
     - scikit-build >=0.14.1
 
diff --git a/pyproject.toml b/pyproject.toml
index 206a1e60..e55372af 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,5 +4,5 @@ requires = [
     "wheel",
     "scikit-build>=0.14.1",
     "cmake",
-    "numpy"]
+    "numpy!=1.23.0"]
 build-backend = "setuptools.build_meta"


Test patch:
diff --git a/.github/workflows/slycot-build-and-test.yml b/.github/workflows/slycot-build-and-test.yml
index 54367ed2..b8f84ade 100644
--- a/.github/workflows/slycot-build-and-test.yml
+++ b/.github/workflows/slycot-build-and-test.yml
@@ -167,7 +167,6 @@ jobs:
         shell: bash -l {0}
         run: |
           set -e
-          mamba install boa numpy
           numpyversion=$(python -c 'import numpy; print(numpy.version.version)')
           conda mambabuild --python "${{ matrix.python }}" --numpy $numpyversion conda-recipe
           # preserve directory structure for custom conda channel