Skip to content

Commit

Permalink
[tests.yml]: Install Cython and Numpy Before MDAnalysis
Browse files Browse the repository at this point in the history
MDAnalysis `<3.0` requires Cython `<3.0` for compilation (see
MDAnalysis/mdanalysis#4129 and
cython/cython#3690).  Otherwise, installing
MDAnalysis via pip throws the following error:

``` shell
Error compiling Cython file:
------------------------------------------------------------
...
    array_wrapper = ArrayWrapper()
    array_wrapper.set_data(<void*> data_ptr, <int*> &dim[0], dim.size, data_type)

    cdef np.ndarray ndarray = np.array(array_wrapper, copy=False)
    # Assign our object to the 'base' of the ndarray object
    ndarray.base = <PyObject*> array_wrapper
           ^
------------------------------------------------------------

MDAnalysis/lib/formats/cython_util.pyx:115:11: Assignment to a read-only property

Traceback (most recent call last):
  File "/home/runner/.local/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 351, in <module>
    main()
  File "/home/runner/.local/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 333, in main
    json_out['return_val'] = hook(**hook_input['kwargs'])
  File "/home/runner/.local/lib/python3.7/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 118, in get_requires_for_build_wheel
    return hook(config_settings)
  File "/tmp/pip-build-env-uemocs7v/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
    return self._get_build_requires(config_settings, requirements=['wheel'])
  File "/tmp/pip-build-env-uemocs7v/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
    self.run_setup()
  File "/tmp/pip-build-env-uemocs7v/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 488, in run_setup
    self).run_setup(setup_script=setup_script)
  File "/tmp/pip-build-env-uemocs7v/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 338, in run_setup
    exec(code, locals())
  File "<string>", line 590, in <module>
  File "<string>", line 453, in extensions
  File "/tmp/pip-build-env-uemocs7v/overlay/lib/python3.7/site-packages/Cython/Build/Dependencies.py", line 1134, in cythonize
    cythonize_one(*args)
  File "/tmp/pip-build-env-uemocs7v/overlay/lib/python3.7/site-packages/Cython/Build/Dependencies.py", line 1301, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: MDAnalysis/lib/formats/cython_util.pyx
```

Furthermore, MDAnalysis requires at leas NumPy `>=1.16.0`, but better
Numpy `>=1.19.2` (see
MDAnalysis/mdanalysis#3374 (comment)),
for setup:

``` shell
*** package "numpy" not found ***
MDAnalysis requires a version of NumPy (>=1.16.0), even for setup.
Please get it from http://numpy.scipy.org/ or install it through your package manager.
```
  • Loading branch information
andthum committed Aug 2, 2023
1 parent 2004672 commit 1aedfbb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,12 @@ jobs:
restore-keys: |
${{ runner.os }}-${{ matrix.python-version }}
${{ runner.os }}
- name: "Install/Upgrade setuptools, wheel and python-dev-tools"
- name: "Install/Upgrade setuptools and wheel"
# MDAnalysis requires NumPy (>=1.19.2) for setup (see also
# https://github.com/MDAnalysis/mdanalysis/issues/3374#issuecomment-889189979).
# MDAnalysis <3.0 requires Cython <3.0 (see
# https://github.com/MDAnalysis/mdanalysis/pull/4129 and
# https://github.com/cython/cython/issues/3690).
# Without `python-dev-tools` the installation of MDAnalysis
# fails on MacOS-latest with Python 3.9 while building the wheel
# for MDAnalysis. Strangely, the MDAnalysis wheel is only build
Expand All @@ -201,9 +206,11 @@ jobs:
run: |
python -m pip install --user --upgrade setuptools wheel
python -m pip install --user --upgrade python-dev-tools
python -m pip install --user "Cython <3.0"
python -m pip install --user "numpy >=1.19.2"
- name: "Test installation of MDTools"
run: |
python -m pip install --user --upgrade .
python -m pip install --user .
python -c "import mdtools"
# Test import of all modules that must be loaded explicitly.
python -c "import mdtools.plot"
Expand Down

0 comments on commit 1aedfbb

Please sign in to comment.