Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time to release a new version? #98

Closed
bnavigator opened this issue Apr 5, 2020 · 108 comments
Closed

Time to release a new version? #98

bnavigator opened this issue Apr 5, 2020 · 108 comments
Assignees

Comments

@bnavigator
Copy link
Collaborator

Hi,

with all the merged and pending PRs that would be ready to merge, I think it is warranted to take Slycot to the next release. For example, further development of python-control/python-control#376 would need Slycot's support of complex matrices.

@roryyorke are you still around? Any other maintainer? I am also willing to help.

@murrayrm
Copy link
Member

murrayrm commented Apr 6, 2020

I can do the merges and release if needed, but it would be much better for @roryyorke and/or @repagh to take a look since they are the people maintaining slycot (and figuring out how to make sure it builds in conda-forge, which seems to be quite non-trivial).

@roryyorke
Copy link
Collaborator

roryyorke commented Apr 10, 2020

There are a number of outstanding PRs. I'd ask for @bnavigator's help to review them, but they're almost all his :).

I see #73 has a number of unaddressed remarks - shall we defer this? I don't know if python-control needs mb03rd. @repagh , do you want to take a look at this?

#80 looks experimental, and related to CI; I think we can defer this too.

If the above is right, the PRs to merge are:

It looks like #79 is pretty much good to go, I'll start with a quick review there, and merge it in,~~

@bnavigator , do you know if all of these work together? Do you have a branch where they're all merged in?

We can review the issues (most look like the usual build-difficulty) after we merge these.

@roryyorke
Copy link
Collaborator

So, somewhat embarrasingly, I can't build slycot. This is my build script:

#!/bin/sh
set -ex
export PAGER=

(cd slycot && git log -1)
(cd slycot && git status)

conda --version
conda build --version

conda build -c conda-forge --python=3.8 slycot/conda-recipe-openblas

CMake doesn't find BLAS:

  CMake Error at /home/rory/.miniconda3/conda-bld/slycot_1586503830485/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:164 (message):
    Could NOT find BLAS (missing: BLAS_LIBRARIES)

I see this line in .travis.yml:

      export LIBRARY_PATH="$HOME/miniconda/envs/test-environment/lib"

which I'll try to add now.

While looking at that, I see we install scipy and matplotlib for slycot CI:

      conda create -q -n test-environment \
            python="$SLYCOT_PYTHON_VERSION" \
            pip coverage pytest-cov \
            numpy scipy matplotlib \
            $conda_blas

Do we need them?

rory@rory-latitude:~/src/slycot/slycot$ grep -r scipy *
examples.py:    from scipy.linalg import eigvals
tests/test_sg02ad.py:        # https://github.com/scipy/scipy/issues/2251
rory@rory-latitude:~/src/slycot/slycot$ grep -r matplotlib *

That example needs generalized eigenvalues, so numpy.linalg.eigvals isn't good enough.

It doesn't look like we need matplotlib (which, at least on Linux, depends on Qt), though.

@roryyorke
Copy link
Collaborator

This script suceeds:

#!/bin/sh
set -ex
export PAGER=

(cd slycot && git log -1)
(cd slycot && git status)

python3 -m venv --clear venv-build-slycot
source venv-build-slycot/bin/activate
pip install -U pip
pip install scikit-build cmake numpy
(cd slycot && python setup.py install)
python -c "import slycot; print(slycot._wrapper)"

Replacing python setup.py install with pip install . fails, apparently here:

  CMake Error: The source "/tmp/pip-req-build-dmsubg0d/CMakeLists.txt" does not match the source "/home/rory/src/slycot/CMakeLists.txt" used to generate cache.  Re-run cmake with a different source directory.
    File "/tmp/pip-build-env-w1oj5yw4/overlay/lib/python3.6/site-packages/skbuild/setuptools_wrap.py", line 574, in setup
      languages=cmake_languages
    File "/tmp/pip-build-env-w1oj5yw4/overlay/lib/python3.6/site-packages/skbuild/cmaker.py", line 232, in configure
      os.path.abspath(CMAKE_BUILD_DIR())))

We don't currently give pip install . as an installation method in README.rst, though it would be nice if it was supported (that's why we have pyproject.toml, right?). Anyway, for now I can at least do a basic build.

@roryyorke
Copy link
Collaborator

a git clean -fxd removed setup.cfg and _skbuild (and other odds and ends) and now pip install . works; conda build still fails with the same error.

@bnavigator
Copy link
Collaborator Author

conda build -c conda-forge --python=3.8 slycot/conda-recipe-openblas

CMake doesn't find BLAS:

  CMake Error at /home/rory/.miniconda3/conda-bld/slycot_1586503830485/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:164 (message):
    Could NOT find BLAS (missing: BLAS_LIBRARIES)

Hm, setting the BLA_VENDOR="OpenBLAS" in the build.sh should take care of that. In Travis, openblas and other build dependencies are installed explicitly before running conda build. Maybe something wrong with the dependency declaration in meta.yaml?

@bnavigator
Copy link
Collaborator Author

@bnavigator , do you know if all of these work together? Do you have a branch where they're all merged in?

They are all based on master. Some might create minor merge conflicts, because they have the same change like removing the suite() lines in test files and removing mathematical.pyf from CMakeLists.txt. Should be easy to resolve if git does not resolve the conflicts automatically.

@bnavigator
Copy link
Collaborator Author

While looking at that, I see we install scipy and matplotlib for slycot CI:

[...]

Do we need them?

Scipy wasn't needed by Slycot's own unit tests until now. The current 0.3.5 OpenSUSE package builds without it. However, #96 introduces the use of scipy.linalg.eig, too. The python-control tests that we run in Travis CI definitely need it. Matplotlib (probably) too.

@roryyorke
Copy link
Collaborator

Ah, I forgot about running the python-control test suite as part of the slycot tests, thanks.

@bnavigator
Copy link
Collaborator Author

bnavigator commented Apr 10, 2020

In https://github.com/roryyorke/Slycot/tree/rory/rebase-merge, the commits 0ded75f and 46769a9 are duplicates of f6494b8 and 91596c1. They belong to #88. but come between #96 and #97.

And f4c4277 belongs to #96 but comes after the commit 158c772 for #97

@bnavigator
Copy link
Collaborator Author

Please use the branches bnavigator/pr* for the rebase and merge as discussed in #84 (comment)

@bnavigator
Copy link
Collaborator Author

Another update: Because of the changes (and possibly more to come) in #88, The branches for #96 (not lytex/master but bnavigator/pr96-lytex-comples) and #97 (both bnavigator/travis-to-control-pytest and bnavigator/py97-pytest-travis-coveralls) are based on current master again. They should apply cleanly with or without #88.

@roryyorke
Copy link
Collaborator

I'm checking README.rst; it's mostly still OK.

From the Travis build matrix, Slycot is still passing tests on Python 2.7, so it's probably fine to leave it in for this release (I don't think 2.7 support is adding much burden to us?). Python 3.5 is EOL September 2020, (https://devguide.python.org/#status-of-python-branches), though I don't know if we've tested on that.

I don't know about minimum versions for other packages (numpy, scikit-build, cmake). We now need scipy, but only for a test, as I understand; I'll add that.

This needs updating:

You can also use conda to build and install Slycot from source.  ::

    conda build conda-recipe
    conda install --use-local slycot

conda-recipe doesn't exist anymore. I don't know which of the three recipes to recommend, though;

  1. Presumably conda-recipe-apple is only for macOS -- is it the preferred or only option there?
  2. For Windows are both MKL and OpenBLAS working?
  3. For Linux the MKL / OpenBLAS choice is up to the user (both pass on Travis)

At the end we say you can install "plain old" LAPACK from conda; do we have a conda recipe supporting that? If not, should we just drop that paragraph, or is it intended for "python setup.py install" run inside a conda environment with LAPACK installed---in which case, perhaps its worth stating that in full.

@bnavigator
Copy link
Collaborator Author

On Python2: I'd say we leave it in as long as the CI builds it fine.

@bnavigator
Copy link
Collaborator Author

Travis CI configuration in #97 builds both 2.7 and 3.5 versions.

On the conda-recipes @repagh should have a word, as he knows what is going on in conda-forge feedstock.

MKL is conda only.

IIRC, "Generic" i.e. "plain old" LAPACK did not work in conda at all when I made the reorganization in #90 and #93. So unless this is different now, we should remove that paragraph at the end.

conda-recipe-apple is the only configuration we got working for Mac OS X on conda. Travis also builds a version from source, also with BLA_VENDOR="Apple". I don't have a Mac. No idea how hard it is to install MKL (possibly from conda) or OpenBLAS. Homebrew or other tools.

@roryyorke
Copy link
Collaborator

roryyorke commented Apr 11, 2020

New features

Added periodic Schur decomposition functions mb03vd, mb03vy, and mb03wd

Contributed by @bnavigator via pull request #88.

Added ab08nz, allowing one to find zeros of complex-valued state-space models

Contributed by @lytex and @bnavigator via pull request #96.

Added mb03rd, Schur to block-diagonal transform

Contributed by @bnavigator and @repagh via pull request #116.

Added sb01fd H-infinity solver

Contributed by @repagh via #118. Already present sb10ad searches for a minimum gamma value for a given H-infinity problem; sb10fd, by contrast, only attempts to solve for a given gamma value. This can be used to test for admissible gamma values, which could be useful for problems like python-control/python-control#367.

New Slycot exception hierarchy

@bnavigator, with support from @repagh, greatly improved Slycot error handling.
Slycot routines now raise SlycotValueError where they would previously have raised ValueError, and SlycotArithmeticError where they would have raised ArithmeticError.
These changes are backwardly compatible: SlycotValueError is a subclasss of ValueError, and SlycotArithmeticError is a subclass of ArithmeticError.
As part of this, many of the Slycot function docstrings were changed to conform to numpydoc conventions.

This supersedes an earlier fix for python-control#347 made during 0.4.0 development.

Override XERBLA

In #128, with extra testing in #130, @bnavigator overrode the BLAS error function XERBLA that SLICOT routines use to report errors; the BLAS-provided XERBLA can terminate the whole Python process.

Fixes

Correct application of DGEBAL in TB01TD and TB05AD

@repagh fixed long-standing #11 with PR #122.

Fixed ab01nd for jobz='N' case

@bnavigator contributed this fix in #129.

Build

Contributed by @bnavigator, @repagh, and @rabraker:

  • conda build recipes no longer use pip
  • added conda recipes for MKL and Apple
  • removed conda recipes for Windows; no developer is using them, and they weren't working
  • general simplifications and improvements of build
  • the signature files (.pyf files) are now a dependency of wrapper generation

Testing

Contributed by @bnavigator and @lytex:

  • Tests added for mb05nd, mc01td, ab08nd, ab08nz, mb03vd, mb03vy, mb03wd.
  • Tests fixed or expanded for mb05md, sg03ad, td04ad.
  • Switched to pytest; Slycot CI now uses pytest for both the Slycot and python-control test suites.
  • CI now builds and tests for Linux and macOS. The Linux builds include OpenBLAS and MKL variants.
  • Examples are run as part of tests. Outputs are not checked, but errors and warnings are.
  • CI coveralls.io integration fixed.
  • General test clean-up.
  • Test files are no longer executable.

Other changes

@bnavigator contributed many other code improvements:

  • Fix for mb05nd.
  • Lots of clean-up: removal of unused mathematical.pyf, many docstring fixes, and some PEP 8 conformance changes to Python code.
  • Fix for Fortran-compiler dependence on machine value used to represent logical values .TRUE. and .FALSE.

@repagh fired up his time machine and ensured punch-card compatibility of the SLICOT Fortran code by limiting line lengths to 72 characters.

Pull requests and issues associated with the release

PRs merged: #71, #72, #75, #78, #91, #93, #79, #82, #83, #84, #87, #88, #96, #97, #101 , #103, #104, #105, #110, #114, #115, #116, #117, #118, #120, #121, #122, #124, #125, #128, #129, #130, #132, #133
Issues fixed: #11, #76, #86, #44, #102, #106, #119, #126
Issues closed ("wont-fix"): #46, #94, #99, #111

@bnavigator
Copy link
Collaborator Author

I would also use 0.4.0. We added some functionality, not only bug-fixes. https://semver.org/

@murrayrm
Copy link
Member

Just catching up on this.

Bumping the version number to 0.4.0 sounds fine.

I checked out the branch for PR #101 and tried on my Mac. Building (and installing) via setup.py worked fine, following the list of dependences in PR #101. However, when I tried to run python setup.py test I get a segmentation fault (?). This does not happen with version 0.3.3 of slycot, so seems like something is broken.

This could be something on my end, so let me do some work to make sure that this is reproducible.

@bnavigator
Copy link
Collaborator Author

However, when I tried to run python setup.py test I get a segmentation fault (?). This does not happen with version 0.3.3 of slycot, so seems like something is broken.

I guess it is during a unit test? Can you tell which one? Also, what about version 0.3.5?

@murrayrm
Copy link
Member

murrayrm commented Apr 12, 2020

Confirming that I am able to successfully compile and run tests for slycot-0.3.5 but not for the master branch on MacOS 10.15.4 running Python 3.7 with gcc, openblas, and scikit-build from conda-forge.

The core dump happens if I just run import slycot in Python, so it is not associated with the unit tests directly.

I'm also going to try using the conda build recipe and see if that does anything different.

@bnavigator
Copy link
Collaborator Author

I checked out the branch for PR #101 and tried on my Mac

#91, #92, #93 also have some back and forth discussion about getting Mac to build. Turns out it is crucial, that the correct MacOSX SDK is used. Maybe we should also add this to the README.rst in #101.

@murrayrm
Copy link
Member

I also tried using conda-recipe-apple and got an error about not being able to find scikit-build. That can be fixed using conda build -c conda-forge condo-recipe-apple, but I still get lots of errors:

conda build -c conda-forge conda-recipe-apple
No numpy version specified in conda_build_config.yaml.  Falling back to default numpy value of 1.11
WARNING:conda_build.metadata:No numpy version specified in conda_build_config.yaml.  Falling back to default numpy value of 1.11
remote: Enumerating objects: 2, done.
remote: Counting objects: 100% (2/2), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 2 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (2/2), done.
From /Users/murray/Dropbox/macosx/src/slycot/murrayrm
 * [new ref]                    -> _conda_cache_origin_head
 * [new tag]         v0.3.4     -> v0.3.4
 * [new tag]         v0.3.5     -> v0.3.5
Cloning into '/Users/murray/anaconda3/conda-bld/slycot_1586708649371/work'...
done.
checkout: 'HEAD'
Your branch is up to date with 'origin/_conda_cache_origin_head'.
==> git log -n1 <==

commit ac53a0a744a73450daa23ef7bf8cfae5bcb01e5d
Author: bnavigator <[email protected]>
Date:   Fri Apr 3 19:25:07 2020 +0200

    switch to pytest for python-control on travis, combine coverage for coveralls

==> git describe --tags --dirty <==

v0.3.5-68-gac53a0a

==> git status <==

On branch _conda_cache_origin_head
Your branch is up to date with 'origin/_conda_cache_origin_head'.

nothing to commit, working tree clean

Adding in variants from internal_defaults
INFO:conda_build.variants:Adding in variants from internal_defaults
Adding in variants from /Users/murray/Dropbox/macosx/src/slycot/murrayrm/conda-recipe-apple/conda_build_config.yaml
INFO:conda_build.variants:Adding in variants from /Users/murray/Dropbox/macosx/src/slycot/murrayrm/conda-recipe-apple/conda_build_config.yaml
Attempting to finalize metadata for slycot
INFO:conda_build.metadata:Attempting to finalize metadata for slycot
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... done
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... done
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... done
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... done
BUILD START: ['slycot-0.3.5-py37gac53a0a_mkl_68.tar.bz2']
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... done

## Package Plan ##

  environment location: /Users/murray/anaconda3/conda-bld/slycot_1586708649371/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pla


The following NEW packages will be INSTALLED:

    bzip2:           1.0.8-h0b31af3_2           conda-forge
    ca-certificates: 2020.4.5.1-hecc5488_0      conda-forge
    certifi:         2020.4.5.1-py37hc8dfbb8_0  conda-forge
    cmake:           3.17.0-hd28f656_0          conda-forge
    distro:          1.4.0-py_0                 conda-forge
    expat:           2.2.9-h4a8c4bd_2           conda-forge
    krb5:            1.17.1-h1752a42_0          conda-forge
    libblas:         3.8.0-16_openblas          conda-forge
    libcblas:        3.8.0-16_openblas          conda-forge
    libcurl:         7.69.1-hc0b9707_0          conda-forge
    libcxx:          10.0.0-0                   conda-forge
    libedit:         3.1.20170329-hcfe32e1_1001 conda-forge
    libffi:          3.2.1-h4a8c4bd_1007        conda-forge
    libgfortran:     4.0.0-2                    conda-forge
    liblapack:       3.8.0-16_openblas          conda-forge
    libopenblas:     0.3.9-h3d69b6c_0           conda-forge
    libssh2:         1.8.2-hcdc9a53_2           conda-forge
    libuv:           1.34.0-h0b31af3_0          conda-forge
    llvm-openmp:     10.0.0-h28b9765_0          conda-forge
    ncurses:         6.1-h0a44026_1002          conda-forge
    ninja:           1.10.0-ha1b3eb9_0          conda-forge
    numpy:           1.11.3-py37hdf140aa_1207   conda-forge
    openssl:         1.1.1f-h0b31af3_0          conda-forge
    packaging:       20.1-py_0                  conda-forge
    pip:             20.0.2-py_2                conda-forge
    pyparsing:       2.4.7-pyh9f0ad1d_0         conda-forge
    python:          3.7.6-h90870a6_5_cpython   conda-forge
    python_abi:      3.7-1_cp37m                conda-forge
    readline:        8.0-hcfe32e1_0             conda-forge
    rhash:           1.3.6-h1de35cc_1001        conda-forge
    scikit-build:    0.10.0-py37h4a8c4bd_0      conda-forge
    setuptools:      46.1.3-py37hc8dfbb8_0      conda-forge
    six:             1.14.0-py_1                conda-forge
    sqlite:          3.30.1-h93121df_0          conda-forge
    tk:              8.6.10-hbbe82c9_0          conda-forge
    wheel:           0.34.2-py_1                conda-forge
    xz:              5.2.5-h0b31af3_0           conda-forge
    zlib:            1.2.11-h0b31af3_1006       conda-forge

Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... done
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... done

## Package Plan ##

  environment location: /Users/murray/anaconda3/conda-bld/slycot_1586708649371/_build_env


The following NEW packages will be INSTALLED:

    cctools:              927.0.2-h5ba7a2e_4       conda-forge
    clang:                9.0.1-default_hf57f61e_0 conda-forge
    clang_osx-64:         9.0.1-h05bbb7f_0         conda-forge
    clangxx:              9.0.1-default_hf57f61e_0 conda-forge
    compiler-rt:          9.0.1-h6a512c6_3         conda-forge
    compiler-rt_osx-64:   9.0.1-h99342c6_3         conda-forge
    gfortran_impl_osx-64: 7.3.0-hf4212f2_2         conda-forge
    gfortran_osx-64:      7.3.0-h22b1bf0_9         conda-forge
    gmp:                  6.2.0-h4a8c4bd_2         conda-forge
    isl:                  0.19-0                   conda-forge
    ld64:                 450.3-h3c32e8a_4         conda-forge
    libcxx:               10.0.0-0                 conda-forge
    libgfortran:          4.0.0-2                  conda-forge
    libiconv:             1.15-h0b31af3_1006       conda-forge
    libllvm9:             9.0.1-ha1b3eb9_0         conda-forge
    llvm-openmp:          10.0.0-h28b9765_0        conda-forge
    mpc:                  1.1.0-h4160ff4_1007      conda-forge
    mpfr:                 4.0.2-h65ac59c_1         conda-forge
    tapi:                 1000.10.8-ha1b3eb9_4     conda-forge
    zlib:                 1.2.11-h0b31af3_1006     conda-forge

Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
source tree in: /Users/murray/anaconda3/conda-bld/slycot_1586708649371/work
export PREFIX=/Users/murray/anaconda3/conda-bld/slycot_1586708649371/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pla
export BUILD_PREFIX=/Users/murray/anaconda3/conda-bld/slycot_1586708649371/_build_env
export SRC_DIR=/Users/murray/anaconda3/conda-bld/slycot_1586708649371/work
INFO: activate-gfortran_osx-64.sh made the following environmental changes:
+DEBUG_FFLAGS=-march=nocona -mtune=core2 -ftree-vectorize -fPIC -fstack-protector -O2 -pipe -isystem $PREFIX/include -fdebug-prefix-map=$SRC_DIR=/usr/local/src/conda/slycot-0.3.5 -fdebug-prefix-map=$PREFIX=/usr/local/src/conda-prefix -march=nocona -mtune=core2 -ftree-vectorize -fPIC -fstack-protector -O2 -pipe -Og -g -Wall -Wextra -fcheck=all -fbacktrace -fimplicit-none -fvar-tracking-assignments
+DEBUG_FORTRANFLAGS=-march=nocona -mtune=core2 -ftree-vectorize -fPIC -fstack-protector -O2 -pipe -isystem $PREFIX/include -fdebug-prefix-map=$SRC_DIR=/usr/local/src/conda/slycot-0.3.5 -fdebug-prefix-map=$PREFIX=/usr/local/src/conda-prefix -march=nocona -mtune=core2 -ftree-vectorize -fPIC -fstack-protector -O2 -pipe -Og -g -Wall -Wextra -fcheck=all -fbacktrace -fimplicit-none -fvar-tracking-assignments
+F77=$BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-gfortran
+F90=$BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-gfortran
+F95=$BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-gfortran
+FC=$BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-gfortran
+FFLAGS=-march=nocona -mtune=core2 -ftree-vectorize -fPIC -fstack-protector -O2 -pipe -isystem $PREFIX/include -fdebug-prefix-map=$SRC_DIR=/usr/local/src/conda/slycot-0.3.5 -fdebug-prefix-map=$PREFIX=/usr/local/src/conda-prefix
+FORTRANFLAGS=-march=nocona -mtune=core2 -ftree-vectorize -fPIC -fstack-protector -O2 -pipe -isystem $PREFIX/include -fdebug-prefix-map=$SRC_DIR=/usr/local/src/conda/slycot-0.3.5 -fdebug-prefix-map=$PREFIX=/usr/local/src/conda-prefix
+GFORTRAN=$BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-gfortran
+HOST=x86_64-apple-darwin13.4.0
+LDFLAGS= -Wl,-rpath,$PREFIX/lib -L$PREFIX/lib
INFO: activate_clang_osx-64.sh made the following environmental changes:
+AR=$BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-ar
+AS=$BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-as
+CC=x86_64-apple-darwin13.4.0-clang
+CFLAGS=-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isystem $PREFIX/include -fdebug-prefix-map=$SRC_DIR=/usr/local/src/conda/slycot-0.3.5 -fdebug-prefix-map=$PREFIX=/usr/local/src/conda-prefix
+CHECKSYMS=$BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-checksyms
+CLANG=$BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-clang
+CMAKE_PREFIX_PATH=:$PREFIX
+CODESIGN_ALLOCATE=$BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-codesign_allocate
+CPPFLAGS=-D_FORTIFY_SOURCE=2 -mmacosx-version-min=10.9 -isystem $PREFIX/include
+DEBUG_CFLAGS=-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -Og -g -Wall -Wextra -isystem $PREFIX/include -fdebug-prefix-map=$SRC_DIR=/usr/local/src/conda/slycot-0.3.5 -fdebug-prefix-map=$PREFIX=/usr/local/src/conda-prefix
+INDR=$BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-indr
+INSTALL_NAME_TOOL=$BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-install_name_tool
+LD=$BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-ld
+LDFLAGS_LD=-pie -headerpad_max_install_names -dead_strip_dylibs -rpath $PREFIX/lib -L$PREFIX/lib
+LIBTOOL=$BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-libtool
+LIPO=$BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-lipo
+NM=$BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-nm
+NMEDIT=$BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-nmedit
+OTOOL=$BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-otool
+PAGESTUFF=$BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-pagestuff
+RANLIB=$BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-ranlib
+REDO_PREBINDING=$BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-redo_prebinding
+SEGEDIT=$BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-segedit
+SEG_ADDR_TABLE=$BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-seg_addr_table
+SEG_HACK=$BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-seg_hack
+SIZE=$BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-size
+STRINGS=$BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-strings
+STRIP=$BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-strip
+_CONDA_PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_x86_64_apple_darwin13_4_0
Not searching for unused variables given on the command line.
CMake Warning at /Users/murray/anaconda3/conda-bld/slycot_1586708649371/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pla/share/cmake-3.17/Modules/Platform/Darwin-Initialize.cmake:221 (message):
  Ignoring CMAKE_OSX_SYSROOT value:

   /opt/MacOSX10.9.sdk

  because the directory does not exist.
Call Stack (most recent call first):
  /Users/murray/anaconda3/conda-bld/slycot_1586708649371/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pla/share/cmake-3.17/Modules/CMakeSystemSpecificInitialize.cmake:21 (include)
  CMakeLists.txt:2 (PROJECT)


-- The C compiler identification is Clang 9.0.1
-- Check for working C compiler: $BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-clang
-- Check for working C compiler: $BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-clang - broken
CMake Error at /Users/murray/anaconda3/conda-bld/slycot_1586708649371/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pla/share/cmake-3.17/Modules/CMakeTestCCompiler.cmake:60 (message):
  The C compiler

    "/Users/murray/anaconda3/conda-bld/slycot_1586708649371/_build_env/bin/x86_64-apple-darwin13.4.0-clang"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /Users/murray/anaconda3/conda-bld/slycot_1586708649371/work/_cmake_test_compile/build/CMakeFiles/CMakeTmp
    
    Run Build Command(s):/usr/bin/make cmTC_23574/fast && /Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_23574.dir/build.make CMakeFiles/cmTC_23574.dir/build
    Building C object CMakeFiles/cmTC_23574.dir/testCCompiler.c.o
    /Users/murray/anaconda3/conda-bld/slycot_1586708649371/_build_env/bin/x86_64-apple-darwin13.4.0-clang   -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isystem /Users/murray/anaconda3/conda-bld/slycot_1586708649371/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pla/include -fdebug-prefix-map=/Users/murray/anaconda3/conda-bld/slycot_1586708649371/work=/usr/local/src/conda/slycot-0.3.5 -fdebug-prefix-map=/Users/murray/anaconda3/conda-bld/slycot_1586708649371/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pla=/usr/local/src/conda-prefix -isysroot /opt/MacOSX10.9.sdk  -arch x86_64 -mmacosx-version-min=10.9   -o CMakeFiles/cmTC_23574.dir/testCCompiler.c.o   -c /Users/murray/anaconda3/conda-bld/slycot_1586708649371/work/_cmake_test_compile/build/CMakeFiles/CMakeTmp/testCCompiler.c
    clang-9: warning: no such sysroot directory: '/opt/MacOSX10.9.sdk' [-Wmissing-sysroot]
    Linking C executable cmTC_23574
    /Users/murray/anaconda3/conda-bld/slycot_1586708649371/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pla/bin/cmake -E cmake_link_script CMakeFiles/cmTC_23574.dir/link.txt --verbose=1
    /Users/murray/anaconda3/conda-bld/slycot_1586708649371/_build_env/bin/x86_64-apple-darwin13.4.0-clang -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isystem /Users/murray/anaconda3/conda-bld/slycot_1586708649371/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pla/include -fdebug-prefix-map=/Users/murray/anaconda3/conda-bld/slycot_1586708649371/work=/usr/local/src/conda/slycot-0.3.5 -fdebug-prefix-map=/Users/murray/anaconda3/conda-bld/slycot_1586708649371/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pla=/usr/local/src/conda-prefix -isysroot /opt/MacOSX10.9.sdk  -arch x86_64 -mmacosx-version-min=10.9 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Wl,-rpath,/Users/murray/anaconda3/conda-bld/slycot_1586708649371/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pla/lib -L/Users/murray/anaconda3/conda-bld/slycot_1586708649371/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pla/lib -v -isysroot /opt/MacOSX10.9.sdk  CMakeFiles/cmTC_23574.dir/testCCompiler.c.o  -o cmTC_23574 
    clang version 9.0.1 
    Target: x86_64-apple-darwin13.4.0
    Thread model: posix
    InstalledDir: /Users/murray/anaconda3/conda-bld/slycot_1586708649371/_build_env/bin
    clang-9: warning: no such sysroot directory: '/opt/MacOSX10.9.sdk' [-Wmissing-sysroot]
     "/Users/murray/anaconda3/conda-bld/slycot_1586708649371/_build_env/bin/x86_64-apple-darwin13.4.0-ld" -demangle -lto_library /Users/murray/anaconda3/conda-bld/slycot_1586708649371/_build_env/lib/libLTO.9.dylib -dynamic -arch x86_64 -macosx_version_min 10.9.0 -pie -syslibroot /opt/MacOSX10.9.sdk -o cmTC_23574 -L/Users/murray/anaconda3/conda-bld/slycot_1586708649371/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pla/lib -search_paths_first -headerpad_max_install_names -rpath /Users/murray/anaconda3/conda-bld/slycot_1586708649371/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pla/lib CMakeFiles/cmTC_23574.dir/testCCompiler.c.o -lSystem /Users/murray/anaconda3/conda-bld/slycot_1586708649371/_build_env/lib/clang/9.0.1/lib/darwin/libclang_rt.osx.a
    ld: library not found for -lSystem
    clang-9: error: linker command failed with exit code 1 (use -v to see invocation)
    make[1]: *** [cmTC_23574] Error 1
    make: *** [cmTC_23574/fast] Error 2
    
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:3 (ENABLE_LANGUAGE)


-- Configuring incomplete, errors occurred!
See also "$SRC_DIR/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
See also "$SRC_DIR/_cmake_test_compile/build/CMakeFiles/CMakeError.log".
********************************************************************************
scikit-build could not get a working generator for your system. Aborting build.

Building MacOSX wheels for Python 3.7 requires XCode.
Get it here:

  https://developer.apple.com/xcode/

********************************************************************************


--------------------------------------------------------------------------------
-- Trying "Unix Makefiles" generator
--------------------------------
---------------------------
----------------------
-----------------
------------
-------
--
--
-------
------------
-----------------
----------------------
---------------------------
--------------------------------
-- Trying "Unix Makefiles" generator - failure
--------------------------------------------------------------------------------

Traceback (most recent call last):
  File "/Users/murray/anaconda3/bin/conda-build", line 11, in <module>
    sys.exit(main())
  File "/Users/murray/anaconda3/lib/python3.7/site-packages/conda_build/cli/main_build.py", line 469, in main
    execute(sys.argv[1:])
  File "/Users/murray/anaconda3/lib/python3.7/site-packages/conda_build/cli/main_build.py", line 460, in execute
    verify=args.verify, variants=args.variants)
  File "/Users/murray/anaconda3/lib/python3.7/site-packages/conda_build/api.py", line 209, in build
    notest=notest, need_source_download=need_source_download, variants=variants)
  File "/Users/murray/anaconda3/lib/python3.7/site-packages/conda_build/build.py", line 2344, in build_tree
    notest=notest,
  File "/Users/murray/anaconda3/lib/python3.7/site-packages/conda_build/build.py", line 1492, in build
    cwd=src_dir, stats=build_stats)
  File "/Users/murray/anaconda3/lib/python3.7/site-packages/conda_build/utils.py", line 398, in check_call_env
    return _func_defaulting_env_to_os_environ('call', *popenargs, **kwargs)
  File "/Users/murray/anaconda3/lib/python3.7/site-packages/conda_build/utils.py", line 378, in _func_defaulting_env_to_os_environ
    raise subprocess.CalledProcessError(proc.returncode, _args)
subprocess.CalledProcessError: Command '['/bin/bash', '-o', 'errexit', '/Users/murray/anaconda3/conda-bld/slycot_1586708649371/work/conda_build.sh']' returned non-zero exit status 1.

@bnavigator
Copy link
Collaborator Author

Yep, looks like it doesn't find the MacOSX SDK. Did you check the travis configuration how it is handled there?

@murrayrm
Copy link
Member

Normally (and for the case of v0.3.5), I can just use the standard build process (via setup.py) and things work just like on linux. At the least I think we should get that working properly.

Let me do some debugging and see if I can find out what is causing the core dump. I've never seen that happen before, so may take a while.

I'll also test on MacOS 10.14 (Mojave) and make sure it isn't something having to do with 10.15 (Catalina).

@bnavigator
Copy link
Collaborator Author

Just as a hint for your debugging: I have seen coredumps building Slycot on Linux and the reason was often, that the wrong LAPACK/BLAS implementation was used. I think it has to be the same as Numpy is linked to on the system.

@roryyorke
Copy link
Collaborator

@repagh added an update to #98 (comment) saying he could build, if I read correctly. I'll wait for him to respond.

@murrayrm
Copy link
Member

I tried the following:

conda create -n slycot-test2 python=3.7 numpy
conda activate slycot-test2
conda install -c conda-forge scikit-build gfortran_osx-64 pytest scipy
python setup.py install -- -DBLA_VENDOR=Apple

When I run python setup.py test, python setup.py install -- -DBLA_VENDOR=Apple or just python -c "import slycot" I still get a segfault.

Output from otools:

/Users/murray/anaconda3/envs/slycot-test2/lib/python3.7/site-packages/slycot-0.3.5.175-py3.7-macosx-10.15-x86_64.egg/slycot/_wrapper.cpython-37m-darwin.so:
	_wrapper.cpython-37m-darwin.so (compatibility version 0.0.0, current version 0.0.0)
	/System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate (compatibility version 1.0.0, current version 4.0.0)
	@rpath/libpython3.7m.dylib (compatibility version 3.7.0, current version 3.7.0)
	@rpath/libgfortran.3.dylib (compatibility version 4.0.0, current version 4.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
	/Users/murray/anaconda3/envs/python3.7-slycot/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
	@rpath/libquadmath.0.dylib (compatibility version 1.0.0, current version 1.0.0)

I suspect the problem is that I am not getting a compatible version of compiler and math libraries? Here is the output of conda list:

# packages in environment at /Users/murray/anaconda3/envs/slycot-test2:
#
# Name                    Version                   Build  Channel
attrs                     19.3.0                     py_0    conda-forge
blas                      1.0                         mkl  
bzip2                     1.0.8                h0b31af3_2    conda-forge
ca-certificates           2020.4.5.1           hecc5488_0    conda-forge
certifi                   2020.4.5.1       py37hc8dfbb8_0    conda-forge
cmake                     3.14.0               haff7e42_0  
distro                    1.4.0                      py_0    conda-forge
expat                     2.2.9                h4a8c4bd_2    conda-forge
gfortran_osx-64           4.8.5                h22b1bf0_8    conda-forge
importlib-metadata        1.6.0            py37hc8dfbb8_0    conda-forge
importlib_metadata        1.6.0                         0    conda-forge
intel-openmp              2019.4                      233  
krb5                      1.17.1               hddcf347_0  
libblas                   3.8.0                    14_mkl    conda-forge
libcblas                  3.8.0                    14_mkl    conda-forge
libcurl                   7.69.1               hc0b9707_0    conda-forge
libcxx                    10.0.0                        1  
libedit                   3.1.20181209         hb402a30_0  
libffi                    3.3                  h0a44026_1  
libgfortran               3.0.1                h93005f0_2  
liblapack                 3.8.0                    14_mkl    conda-forge
libssh2                   1.9.0                h39bdce6_2    conda-forge
mkl                       2019.4                      233  
mkl-service               2.3.0            py37hfbe908c_0  
mkl_fft                   1.0.15           py37h5e564d8_0  
mkl_random                1.1.0            py37ha771720_0  
more-itertools            8.3.0                      py_0    conda-forge
ncurses                   6.2                  h0a44026_1  
ninja                     1.10.0               ha1b3eb9_0    conda-forge
numpy                     1.18.1           py37h7241aed_0  
numpy-base                1.18.1           py37h3304bdc_1  
openssl                   1.1.1g               h0b31af3_0    conda-forge
packaging                 20.4               pyh9f0ad1d_0    conda-forge
pip                       20.0.2                   py37_3  
pluggy                    0.13.1           py37hc8dfbb8_1    conda-forge
py                        1.8.1                      py_0    conda-forge
pyparsing                 2.4.7              pyh9f0ad1d_0    conda-forge
pytest                    5.4.2            py37hc8dfbb8_0    conda-forge
python                    3.7.7                hf48f09d_4  
python_abi                3.7                     1_cp37m    conda-forge
readline                  8.0                  h1de35cc_0  
rhash                     1.3.8                ha12b0ac_0  
scikit-build              0.11.1           py37h570ac47_0    conda-forge
scipy                     1.2.1            py37hbd7caa9_1    conda-forge
setuptools                46.4.0                   py37_0  
six                       1.14.0                   py37_0  
slycot                    0.3.5.175                 dev_0    <develop>
sqlite                    3.31.1               h5c1f38d_1  
tk                        8.6.8                ha441bb4_0  
wcwidth                   0.1.9              pyh9f0ad1d_0    conda-forge
wheel                     0.34.2                   py37_0  
xz                        5.2.5                h1de35cc_0  
zipp                      3.1.0                      py_0    conda-forge
zlib                      1.2.11               h1de35cc_3  

As before, I don't think this is a blocker for releasing v0.4.0 and worst case I can always do a conda install of the conda-forge version. It's still odd, though.

@moorepants
Copy link
Contributor

One thing is that you are installing a mix of conda packages from defaults and conda forge. I think its best to configure conda to install everything from conda forge. See this: https://conda-forge.org/docs/user/tipsandtricks.html#how-to-fix-it and https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-channels.html.

@moorepants
Copy link
Contributor

Maybe using conda create -c conda-forge -n slycot-test2 python=3.7 numpy would do it.

@murrayrm
Copy link
Member

Loading everything from condo-forge seems to work. I now get things to compile (!).

Running python setup.py test gives 4 errors. The last of them (pretty much same as the rest) says

ERROR: slycot.tests.test_mc (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: slycot.tests.test_mc
Traceback (most recent call last):
  File "/Users/murray/anaconda3/envs/slycot-test2/lib/python3.7/unittest/loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "/Users/murray/anaconda3/envs/slycot-test2/lib/python3.7/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "/Users/murray/Dropbox/macosx/src/slycot/murrayrm/slycot/tests/test_mc.py", line 8, in <module>
    from slycot import mc01td
ImportError: cannot import name 'mc01td' from 'slycot' (/Users/murray/Dropbox/macosx/src/slycot/murrayrm/slycot/__init__.py)

Running pytest --pyargs slycot gives 1 failure:

_________________________ test_example[ab13fd_example] _________________________

examplefun = <function ab13fd_example at 0x116ab9ef0>
capsys = <_pytest.capture.CaptureFixture object at 0x116b951d0>
recwarn = WarningsRecorder(record=True)

    @pytest.mark.parametrize('examplefun', examplefunctions)
    def test_example(examplefun, capsys, recwarn):
        """
        Test the examples.
    
        Test that all the examples work, produce some (unchecked) output but no
        exceptions or warnings.
        """
        examplefun()
        captured = capsys.readouterr()
        assert len(captured.out) > 0
        assert not captured.err
>       assert not recwarn
E       assert not WarningsRecorder(record=True)

/Users/murray/anaconda3/envs/slycot-test2/lib/python3.7/site-packages/slycot-0.3.5.175-py3.7-macosx-10.15-x86_64.egg/slycot/tests/test_examples.py:29: AssertionError

@roryyorke
Copy link
Collaborator

This diff turns warnings into errors, and lets one see the warning (see pytest docs)

diff --git a/slycot/tests/test_examples.py b/slycot/tests/test_examples.py
index b926e2e..bb9cdae 100644
--- a/slycot/tests/test_examples.py
+++ b/slycot/tests/test_examples.py
@@ -13,9 +13,10 @@ from slycot import examples
 examplefunctions = [fun for (fname, fun) in getmembers(examples)
                     if isfunction(fun) and "_example" in fname]
 
+pytestmark = pytest.mark.filterwarnings("error")
 
 @pytest.mark.parametrize('examplefun', examplefunctions)
-def test_example(examplefun, capsys, recwarn):
+def test_example(examplefun, capsys):
     """
     Test the examples.
 
@@ -26,4 +27,3 @@ def test_example(examplefun, capsys, recwarn):
     captured = capsys.readouterr()
     assert len(captured.out) > 0
     assert not captured.err
-    assert not recwarn

I tested this in an editable install (pip install -e .), and noticed two things of interest:

  1. pytest --pyargs slycot.tests.test_examples would run the whole suite; I couldn't figure out why until I remembered the addopts = --pyargs slycot line in setup.cfg
  2. When I removed that line, and tried pytest -Werror --pyargs slycot.tests.test_examples, I got this:
slycot/tests/test_examples.py:26: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
slycot/examples.py:52: in ab08nd_example
    from scipy.linalg import eigvals
../venv-dev-slycot/lib/python3.6/site-packages/scipy/linalg/__init__.py:196: in <module>
    from .basic import *
../venv-dev-slycot/lib/python3.6/site-packages/scipy/linalg/basic.py:17: in <module>
    from ._solve_toeplitz import levinson
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

>   ???
E   RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility. Expected 192 from C header, got 216 from PyObject

__init__.pxd:918: RuntimeWarning
=============================================== short test summary info ===============================================
FAILED slycot/tests/test_examples.py::test_example[ab08nd_example] - RuntimeWarning: numpy.ufunc size changed, may i...
============================================ 1 failed, 12 passed in 0.34s =============================================

So, if I read that right, it's not only on macOS that Slycot gets its numpy libraries mixed up.

This doesn't happen with pytest --pyargs slycot.tests or pytest --pyargs slycot, which I don't understand.

Finally, if I run pytest -Werror --pyargs slycot, I get:

>               warn(globals()[warning](fmessage, iwarn, info))
E               slycot.exceptions.SlycotResultWarning: 
E               Entry ``P(x)`` is the zero polynomial.

slycot/exceptions.py:241: SlycotResultWarning
=============================================== short test summary info ===============================================
FAILED slycot/tests/test_mc.py::test_mc::test_mc01td_warnings - slycot.exceptions.SlycotResultWarning: 
============================================ 1 failed, 107 passed in 3.73s ============================================

@roryyorke
Copy link
Collaborator

That ufunc size warning is triggered by the from scipy.linalg import eigvals in ab08nd_example. General advice seems to be to ignore it; see [1], [2].

In our case, we can work around it by importing scipy.linalg at module level in test_examples.py (I don't know why this works; perhaps it is pytest resetting import filters, as suggest in a comment in [2].)

[1] numpy/numpy@170ed4e
[2] numpy/numpy#14920

@repagh
Copy link
Member

repagh commented May 24, 2020

I tried the following:

conda create -n slycot-test2 python=3.7 numpy
conda activate slycot-test2
conda install -c conda-forge scikit-build gfortran_osx-64 pytest scipy
python setup.py install -- -DBLA_VENDOR=Apple

When I run python setup.py test, python setup.py install -- -DBLA_VENDOR=Apple or just python -c "import slycot" I still get a segfault.

Output from otools:

/Users/murray/anaconda3/envs/slycot-test2/lib/python3.7/site-packages/slycot-0.3.5.175-py3.7-macosx-10.15-x86_64.egg/slycot/_wrapper.cpython-37m-darwin.so:
	_wrapper.cpython-37m-darwin.so (compatibility version 0.0.0, current version 0.0.0)
	/System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate (compatibility version 1.0.0, current version 4.0.0)
	@rpath/libpython3.7m.dylib (compatibility version 3.7.0, current version 3.7.0)
	@rpath/libgfortran.3.dylib (compatibility version 4.0.0, current version 4.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
	/Users/murray/anaconda3/envs/python3.7-slycot/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
	@rpath/libquadmath.0.dylib (compatibility version 1.0.0, current version 1.0.0)

That is just maddening.

I got gfortran_osx-64 version 7.3.0 installed with those same instructions. That links to @rpath/libgfortran4.dylib, and does not link to libquadmath, and everything then simply works.

@bnavigator
Copy link
Collaborator Author

bnavigator commented May 24, 2020

Running python setup.py test gives 4 errors.

Deprecated command, wich does not use pytest. Error looks like an old slycot wrapper without mc01td got imported from a src dir outside of the venv.

@bnavigator
Copy link
Collaborator Author

Running pytest --pyargs slycot gives 1 failure:

@murrayrm, could you please check with #133, which failure in the examples that would be? ab13fd_example is different from @roryyorke's failure in ab08nd_example

@murrayrm
Copy link
Member

Ran #133 and got the following output from pytest --pyargs slycot

_________________________ test_example[ab13fd_example] _________________________

examplefun = <function ab13fd_example at 0x118cf8290>
capsys = <_pytest.capture.CaptureFixture object at 0x118e1e990>
recwarn = WarningsRecorder(record=True)

    @pytest.mark.parametrize('examplefun', examplefunctions)
    @pytest.mark.filterwarnings("ignore:numpy.dtype size changed")
    @pytest.mark.filterwarnings("ignore:numpy.ufunc size changed")
    def test_example(examplefun, capsys, recwarn):
        """
        Test the examples.
    
        Test that all the examples work, produce some (unchecked) output but no
        exceptions or warnings.
        """
        examplefun()
        captured = capsys.readouterr()
    
        # fail for first in order
        failconditions = [
            ((not len(captured.out) > 0), "Example {} did not print any results\n"),
            (captured.err, "Example {} wrote to stderr\n"),
            (recwarn,  "Example {} produced a warning.\n")]
        for failed, msgfmt  in failconditions:
            if failed:
                pytest.fail(msgfmt.format(examplefun.__name__) +
                            "Captured output:\n{}\n"
                            "Captured stderr:\n{}\n"
                            "Captured warnings:\n{}\n"
                            "".format(captured.out,
                                      captured.err,
>                                     [w.message for w in recwarn]))
E               Failed: Example ab13fd_example produced a warning.
E               Captured output:
E               The stability radius is
E               0.003919647231698771
E               The minimizing omega is
E               0.9896652038894939
E               
E               Captured stderr:
E               
E               Captured warnings:
E               [SlycotResultWarning('\nFailed to compute beta(A) within the specified tolerance.\nNevertheless, the returned value is an upper bound on beta(A);')]

../anaconda3/envs/slycot-test2/lib/python3.7/site-packages/slycot-0.3.5.179-py3.7-macosx-10.15-x86_64.egg/slycot/tests/test_examples.py:44: Failed

@bnavigator
Copy link
Collaborator Author

Interesting. Should we increase the default tolerance in the example or introduce an option to ignore specific warnings in examples?

@bnavigator
Copy link
Collaborator Author

bnavigator commented May 24, 2020

E               Failed: Example ab13fd_example produced a warning.
E               Captured output:
E               The stability radius is
E               0.003919647231698771
E               The minimizing omega is
E               0.9896652038894939
E               
E               Captured stderr:
E               
E               Captured warnings:
E               [SlycotResultWarning('\nFailed to compute beta(A) within the specified tolerance.\nNevertheless, the returned value is an upper bound on beta(A);')]

Allowing it in af98e9f

@roryyorke
Copy link
Collaborator

I've at last released v0.4.0.

@moorepants are you (still?) a maintainer for slycot on PyPI? If so, could you please upload it?

@murrayrm I've at last created a PyPI account, my username is roryyorke.

@roryyorke
Copy link
Collaborator

  • upload to PyPI
  • file PR with conda-forge feedstock

@moorepants
Copy link
Contributor

It looks like I do have permission to upload. I assume you want me to:

git checkout v0.4.0
python setup.py sdist
twine upload dist/slycot-0.4.0.0.tar.gz

@moorepants
Copy link
Contributor

Note too that the conda forge pot will create a PR once PyPi is updated.

@murrayrm
Copy link
Member

@roryyorke: Added you as a maintainer on PyPi.

@roryyorke
Copy link
Collaborator

@moorepants yes please.

@moorepants
Copy link
Contributor

I pushed it up.

@bnavigator
Copy link
Collaborator Author

bnavigator commented May 30, 2020

🎉 yay!

For the next update (probably 0.4.1), could we please drop the fourth digit in the PyPI version? The git tag, the report during the CMake build and the .egg-info all report 0.4.0, but PyPI has 0.4.0.0.

@moorepants
Copy link
Contributor

Conda forge package is in.

@bnavigator
Copy link
Collaborator Author

Conda forge package is in.

The tests will need a rework, though. On Linux and OS X the new test requirements for pytest and scipy are not being found. On Windows no tests are discovered.

@moorepants
Copy link
Contributor

I suggest submitting a PR to the feedstock then. I am not familiar with the details of how the tests have changed.

This is the command that runs on the feedstock:

python -c "from slycot import test; test()"

If that doesn't run anymore, that seems like a backwards incompatibility.

@bnavigator
Copy link
Collaborator Author

python -c "from slycot import test; test()"

If that doesn't run anymore, that seems like a backwards incompatibility.

#134, addressed in #136

@roryyorke
Copy link
Collaborator

I've sent a release notice to python-control-announce, so I think this is all done.

Thanks everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants