Skip to content

Commit 07546ce

Browse files
authored
[python-package] add py312 (#50) workaround
* [pyproject.toml] change dependency order s.t. legacy dep resolver installs mdtraj after bezier * [README and installation.rst] Add instructions/admonition for Python 3.12 users * [workflows] separate tests for py312 from the rest
1 parent b56e3b2 commit 07546ce

File tree

5 files changed

+71
-34
lines changed

5 files changed

+71
-34
lines changed

.github/workflows/python-package.macos.yml

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
33

4-
name: Python [3.7,3.8,3.9,3.10,3.11] MacOs
4+
name: Python [3.7,3.8,3.9,3.10,3.11,3.12] MacOs
55

66
on:
77
push:
@@ -23,7 +23,7 @@ jobs:
2323
fail-fast: false
2424
matrix:
2525
os: [macos-latest]
26-
python-version: [3.7, 3.8, 3.9, '3.10', '3.11']
26+
python-version: [3.7, 3.8, 3.9, '3.10', '3.11','3.12']
2727
# Proposed workaround for legacy versions, see
2828
# https://github.com/actions/setup-python/issues/856 and
2929
# https://github.com/actions/runner-images/issues/9770#issuecomment-2085623315
@@ -44,24 +44,22 @@ jobs:
4444
run: |
4545
python -m pip install --upgrade pip
4646
pip install flake8 pytest pytest-cov pytest-xdist
47-
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
48-
- name: Install package
47+
- name: Install package Python lt 3.12
48+
if: matrix.python-version != '3.12'
4949
run: |
5050
pip install --upgrade pip
5151
pip install --upgrade setuptools
5252
pip install -e .
5353
pip freeze
54-
#- name: Lint with flake8
55-
# run: |
56-
# # stop the build if there are Python syntax errors or undefined names
57-
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
58-
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
59-
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
60-
#- name: Test with pytest and coverage MacOs one single thread and ignoring calls to scripts (WIP)
61-
# if: runner.os == 'macOs'
62-
# run: |
63-
# pytest -vs --cov=./ --cov-report=xml --disable-warnings --ignore-glob="test_scripts.py"
64-
# if: runner.os == 'macOs'
54+
- name: Install package Python eq 3.12
55+
if: matrix.python-version == '3.12'
56+
run: |
57+
pip install --upgrade pip
58+
pip install --upgrade setuptools
59+
pip install bezier
60+
pip install mdtraj --use-deprecated=legacy-resolver
61+
pip install -e . --use-deprecated=legacy-resolver
62+
pip freeze
6563
- name: Test with pytest and coverage macos
6664
continue-on-error: true
6765
run: |

.github/workflows/python-package.yml

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
33

4-
name: Python [3.7,3.8,3.9,3.10,3.11] Linux
4+
name: Python [3.7,3.8,3.9,3.10,3.11,3.12] Linux
55

66
on:
77
push:
@@ -21,7 +21,7 @@ jobs:
2121
fail-fast: false
2222
matrix:
2323
os: [ubuntu-latest]
24-
python-version: [3.7, 3.8, 3.9, '3.10', '3.11']
24+
python-version: [3.7, 3.8, 3.9, '3.10', '3.11','3.12']
2525

2626
steps:
2727
- uses: actions/checkout@v4
@@ -32,25 +32,23 @@ jobs:
3232
- name: Install dependencies
3333
run: |
3434
python -m pip install --upgrade pip
35-
pip install flake8 pytest pytest-cov pytest-xdist
36-
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
37-
- name: Install package
35+
pip install pytest pytest-cov pytest-xdist
36+
- name: Install package Python lt 3.12
37+
if: matrix.python-version != '3.12'
3838
run: |
3939
pip install --upgrade pip
4040
pip install --upgrade setuptools
4141
pip install -e .
4242
pip freeze
43-
#- name: Lint with flake8
44-
# run: |
45-
# # stop the build if there are Python syntax errors or undefined names
46-
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
47-
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
48-
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
49-
#- name: Test with pytest and coverage MacOs one single thread and ignoring calls to scripts (WIP)
50-
# if: runner.os == 'macOs'
51-
# run: |
52-
# pytest -vs --cov=./ --cov-report=xml --disable-warnings --ignore-glob="test_scripts.py"
53-
# if: runner.os == 'macOs'
43+
- name: Install package Python eq 3.12
44+
if: matrix.python-version == '3.12'
45+
run: |
46+
pip install --upgrade pip
47+
pip install --upgrade setuptools
48+
pip install bezier
49+
pip install mdtraj --use-deprecated=legacy-resolver
50+
pip install -e . --use-deprecated=legacy-resolver
51+
pip freeze
5452
- name: Test with pytest and coverage Linux 8 threads
5553
run: |
5654
echo -e '[run]\nomit = *dihedrals.py,*contact_matrix.py' > .coveragerc

README.rst

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,35 @@ Currently, docs are hosted at `<http://proteinformatics.org/mdciao/>`_, but this
4242

4343
System Requirements
4444
===================
45-
``mdciao`` is developed in GNU/Linux, and CI-tested via `github actions <https://github.com/gph82/mdciao/actions?query=workflow%3A%22Python+package%22>`_ for GNU/Linux and MacOs. Tested python versions are:
45+
``mdciao`` is developed in GNU/Linux, and CI-tested via `github actions <https://github.com/gph82/mdciao/actions>`_ for GNU/Linux and MacOs. Tested Python versions are:
4646

4747
* GNU/Linux: 3.7, 3.8, 3.9, 3.10, 3.11
4848
* MacOs: 3.7, 3.8, 3.9, 3.10, 3.11. For Python 3.7, four CI-tests involving `mdtraj.compute_dssp <https://www.mdtraj.org/1.9.8.dev0/api/generated/mdtraj.compute_dssp.html?highlight=dssp#mdtraj.compute_dssp>`_ ,
4949
are skipped because of a hard to repdroduce, random segmentation fault, which apparently wont fix, see here `<https://github.com/mdtraj/mdtraj/issues/1574>`_ and `here <https://github.com/mdtraj/mdtraj/issues/1473>`_.
5050

5151
So everything should work *out of the box* in these conditions.
5252

53+
.. admonition:: Python 3.12 users
54+
55+
If you try to install on Python 3.12, you will get a dependency error, because
56+
57+
* the module ``bezier`` `requires Numpy >= 2.0 for Python 3.12 <https://github.com/dhermes/bezier/releases/tag/2024.6.20>`_, but
58+
* the module ``mdtraj`` `has pinned Numpy <= 2.0 <https://github.com/mdtraj/mdtraj/issues/1873/>`_.
59+
60+
Still, you can install mdciao in Python 3.12 **if you don't mind a somewhat inconsistent environment**:
61+
62+
>>> pip install bezier
63+
>>> pip install mdtraj --use-deprecated=legacy-resolver
64+
>>> pip install mdciao --use-deprecated=legacy-resolver
65+
66+
What we are doing is installing ``bezier`` normally (using ``numpy>=2.0``) and then installing ``mdtraj`` using ``pip``'s legacy resolver, which will install ``numpy-1.26.4`` even if that yields an inconsistent environment. You will get the notification:
67+
68+
>>> ERROR: pip's legacy dependency resolver does not consider dependency conflicts when selecting packages. This behaviour is the source of the following dependency conflicts.
69+
>>> mdtraj 1.10.0 requires numpy<2.0.0a0,>=1.23, but you'll have numpy 2.0.0 which is incompatible.
70+
71+
Since ``mdciao`` installs and passes the CI-tests for Python 3.12 in such an environment, you can use it **at your own risk**. Please report on any issues you might find. Please note that the ``--use-deprecated=legacy-resolver`` option `might not be available in the future <https://pip.pypa.io/en/stable/user_guide/#deprecation-timeline>`_.
72+
73+
5374
Authors
5475
=======
5576
``mdciao`` is written and maintained by Guillermo Pérez-Hernández (`ORCID <http://orcid.org/0000-0002-9287-8704>`_) currently at the `Institute of Medical Physics and Biophysics <https://biophysik.charite.de/ueber_das_institut/team/>`_ in the

doc/installation.rst

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,26 @@ We recommend you install ``mdciao`` via the `pip <https://pypi.org/project/pip/>
1919

2020
>>> pip install mdciao
2121

22+
.. admonition:: Python 3.12 users
23+
24+
If you try to install on Python 3.12, you will get a dependency error, because
25+
26+
* the module ``bezier`` `requires Numpy >= 2.0 for Python 3.12 <https://github.com/dhermes/bezier/releases/tag/2024.6.20>`_, but
27+
* the module ``mdtraj`` `has pinned Numpy <= 2.0 <https://github.com/mdtraj/mdtraj/issues/1873/>`_.
28+
29+
Still, you can install mdciao in Python 3.12 **if you don't mind a somewhat inconsistent environment**:
30+
31+
>>> pip install bezier
32+
>>> pip install mdtraj --use-deprecated=legacy-resolver
33+
>>> pip install mdciao --use-deprecated=legacy-resolver
34+
35+
What we are doing is installing ``bezier`` normally (using ``numpy>=2.0``) and then installing ``mdtraj`` using ``pip``'s legacy resolver, which will install ``numpy-1.26.4`` even if that yields an inconsistent environment. You will get the notification:
36+
37+
>>> ERROR: pip's legacy dependency resolver does not consider dependency conflicts when selecting packages. This behaviour is the source of the following dependency conflicts.
38+
>>> mdtraj 1.10.0 requires numpy<2.0.0a0,>=1.23, but you'll have numpy 2.0.0 which is incompatible.
39+
40+
Since ``mdciao`` installs and passes the CI-tests for Python 3.12 in such an environment, you can use it **at your own risk**. Please report on any issues you might find. Please note that the ``--use-deprecated=legacy-resolver`` option `might not be available in the future <https://pip.pypa.io/en/stable/user_guide/#deprecation-timeline>`_.
41+
2242
Getting started
2343
~~~~~~~~~~~~~~~
2444
For the impatient, you can directly issue afterwards::
@@ -98,7 +118,7 @@ Installation from source
98118

99119
Operating systems and Python versions
100120
-------------------------------------
101-
``mdciao`` is developed in GNU/Linux, and CI-tested via `github actions <https://github.com/gph82/mdciao/actions?query=workflow%3A%22Python+package%22>`_ for GNU/Linux and MacOs. Tested python versions are:
121+
``mdciao`` is developed in GNU/Linux, and CI-tested via `github actions <https://github.com/gph82/mdciao/actions>`_ for GNU/Linux and MacOs. Tested python versions are:
102122

103123
* GNU/Linux: 3.7, 3.8, 3.9, 3.10, 3.11
104124
* MacOs: 3.7, 3.8, 3.9, 3.10, 3.11. For Python 3.7, four CI-tests involving `mdtraj.compute_dssp <https://www.mdtraj.org/1.9.8.dev0/api/generated/mdtraj.compute_dssp.html?highlight=dssp#mdtraj.compute_dssp>`_ ,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ classifiers = [ "Development Status :: 4 - Beta",
1818
requires-python = ">=3.6"
1919
dependencies = [ "cython",
2020
"numpy>=1.18.1",
21+
"bezier",
2122
"mdtraj>=1.9.8",
2223
"astunparse; python_version!='3.8'",
2324
"astunparse<1.6.3; python_version=='3.8'",
@@ -36,7 +37,6 @@ dependencies = [ "cython",
3637
"tqdm",
3738
"ipywidgets",
3839
"natsort",
39-
"bezier",
4040
"mpl_chord_diagram>=0.3.2",
4141
"docstring_parser",
4242
]

0 commit comments

Comments
 (0)