From 1aedfbb139d49a44846a5d2ed650f88a86275769 Mon Sep 17 00:00:00 2001 From: andthum <56444687+andthum@users.noreply.github.com> Date: Wed, 19 Jul 2023 10:27:26 +0200 Subject: [PATCH] [tests.yml]: Install Cython and Numpy Before MDAnalysis MDAnalysis `<3.0` requires Cython `<3.0` for compilation (see https://github.com/MDAnalysis/mdanalysis/pull/4129 and https://github.com/cython/cython/issues/3690). Otherwise, installing MDAnalysis via pip throws the following error: ``` shell Error compiling Cython file: ------------------------------------------------------------ ... array_wrapper = ArrayWrapper() array_wrapper.set_data( data_ptr, &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 = 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 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 "", line 590, in File "", 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 https://github.com/MDAnalysis/mdanalysis/issues/3374#issuecomment-889189979), 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. ``` --- .github/workflows/tests.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ed21a3ff..d9274e79 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 @@ -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"