Skip to content

Commit 6836440

Browse files
authored
Fix version info and modernize some things (#562)
* drop python 3.10 from testing matrix since it is out of SPEC-0 * migrate to setuptools_scm and use a pyproject.toml file * Remove unused input for codcov * fix issue with metadata * ported entire setup.py * fix issue with metadata * switch over to pyproject.toml * License classifiers have been superseded by license expressions (see https://peps.python.org/pep-0639/) * Formatting fixes and use setuptools to find package * add a fallback version so install doesn't fail if git is not in path * Remove file that doesn't exit anymore from exclude * Add missing trailing comma * fix pymbar.__version__ * use better default shell to catch errors and also cancel jobs if a new commit is pushed
1 parent 94a9dcf commit 6836440

File tree

8 files changed

+77
-3037
lines changed

8 files changed

+77
-3037
lines changed

.github/workflows/CI.yaml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,23 @@ on:
1515
# Nightly Tests
1616
- cron: '0 0 * * *'
1717

18-
jobs:
1918

19+
defaults:
20+
run:
21+
shell: bash -leo pipefail {0}
22+
23+
concurrency:
24+
group: "${{ github.workflow }}-${{ github.ref }}"
25+
cancel-in-progress: true
26+
27+
jobs:
2028
test:
2129
runs-on: ${{ matrix.os }}
2230
strategy:
2331
fail-fast: false
2432
matrix:
2533
os: [macOS-latest, ubuntu-latest, windows-latest]
26-
python-version: ["3.10", "3.11", "3.12", "3.13"] # Check against oldest and newest versions
34+
python-version: ["3.11", "3.12", "3.13"] # Check against oldest and newest versions
2735
jax: ["", "_jax"]
2836
exclude: # Skip win + jax
2937
- jax: "_jax"
@@ -35,7 +43,7 @@ jobs:
3543

3644
steps:
3745
- name: Checkout the code
38-
uses: actions/checkout@v3
46+
uses: actions/checkout@v4
3947

4048
- name: Additional info about the build
4149
shell: bash
@@ -56,18 +64,15 @@ jobs:
5664
python=${{ matrix.python-version }}
5765
5866
- name: Install package
59-
shell: bash -l {0}
6067
run: |
6168
python -m pip install . --no-deps
6269
micromamba list
6370
6471
- name: Run tests (pytest)
65-
shell: bash -l {0}
6672
run: |
6773
pytest -v --cov=$PACKAGE --cov-report=xml --color=yes --doctest-modules $PACKAGE/
6874
6975
- name: Run examples
70-
shell: bash -l {0}
7176
run: |
7277
### constant-force-optical-trap
7378
cd examples/constant-force-optical-trap
@@ -93,14 +98,13 @@ jobs:
9398
token: ${{ secrets.CODECOV_TOKEN }}
9499
file: ./coverage.xml
95100
flags: unittests
96-
yml: ./.codecov.yml
97101

98102
lint-format:
99103
runs-on: ubuntu-latest
100104
strategy:
101105
fail-fast: false
102106
matrix:
103-
python-version: ["3.10"]
107+
python-version: ["3.11"]
104108
env:
105109
PACKAGE: "pymbar"
106110

@@ -119,19 +123,16 @@ jobs:
119123
create-args: >-
120124
python=${{ matrix.python-version }}
121125
- name: Install linter and formatter
122-
shell: bash -l {0}
123126
run: |
124127
micromamba install pylint black
125128
126129
- name: Run pylint
127-
shell: bash -l {0}
128130
run: |
129131
pylint $PACKAGE/
130132
131133
# Black has a default --exclude which reads .gitignore.
132134
# Black's --exclude and --extend-exclude are single specified RegEx patterns and overwrite if multi-marked.
133135
- name: Run black check
134-
shell: bash -l {0}
135136
if: always()
136137
run: |
137-
black --check -l 99 $PACKAGE/ examples/ --extend-exclude "$PACKAGE/_version.py"
138+
black --check -l 99 $PACKAGE/ examples/

pymbar/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
__maintainer__ = "Levi N. Naden, Jaime Rodríguez-Guerra, Michael R. Shirts and John D. Chodera"
2929
__email__ = "levi.naden@choderalab.org,jaime.rodriguez-guerra@choderalab.org,michael.shirts@colorado.edu,john.chodera@choderalab.org"
3030

31+
from importlib.metadata import version, PackageNotFoundError
32+
3133
from . import timeseries, testsystems, confidenceintervals
3234
from .mbar import MBAR
3335
from .other_estimators import bar, bar_overlap, bar_zero, exp, exp_gauss
@@ -48,6 +50,8 @@
4850
"FES",
4951
]
5052

51-
from . import _version
52-
53-
__version__ = _version.get_versions()["version"]
53+
try:
54+
__version__ = version("pymbar")
55+
except PackageNotFoundError:
56+
# package is not installed
57+
pass

0 commit comments

Comments
 (0)