Skip to content

Commit bd83a1b

Browse files
authored
Merge pull request #137 from dwhswenson/fix-pkg-resources
Get tests passing again
2 parents 9fac9fa + c2e4097 commit bd83a1b

7 files changed

Lines changed: 80 additions & 43 deletions

File tree

.github/workflows/autorelease-default-env.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
INSTALL_AUTORELEASE="python -m pip install autorelease==0.2.6"
1+
# Vendored from Autorelease 0.7.0
2+
# Update by updating Autorelease and running `autorelease vendor actions`
3+
INSTALL_AUTORELEASE="python -m pip install autorelease==0.7.0"
24
if [ -f autorelease-env.sh ]; then
35
source autorelease-env.sh
46
fi
Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,29 @@
1-
name: Autorelease
1+
# Vendored from Autorelease 0.7.0
2+
# Update by updating Autorelease and running `autorelease vendor actions`
3+
name: "Autorelease Deploy"
24
on:
35
release:
46
types: [published]
57

68
jobs:
79
deploy_pypi:
10+
if: ${{ github.repository == 'dwhswenson/contact_map' }}
811
runs-on: ubuntu-latest
912
name: "Deploy to PyPI"
13+
permissions:
14+
id-token: write
1015
steps:
11-
- uses: actions/checkout@v2
12-
- uses: actions/setup-python@v2
16+
- uses: actions/checkout@v5
17+
- uses: actions/setup-python@v5
1318
with:
1419
python-version: "3.x"
15-
- run: | # TODO: move this to an action
16-
source ./.github/workflows/autorelease-default-env.sh
17-
if [ -f "autorelease-env.sh" ]; then
18-
cat autorelease-env.sh >> $GITHUB_ENV
19-
fi
20-
eval $INSTALL_AUTORELEASE
21-
name: "Install autorelease"
2220
- run: |
23-
python -m pip install twine wheel
21+
python -m pip install twine wheel build
2422
name: "Install release tools"
2523
- run: |
26-
python setup.py sdist bdist_wheel
24+
python -m build --sdist --wheel
2725
twine check dist/*
2826
name: "Build and check package"
29-
- uses: pypa/gh-action-pypi-publish@master
30-
with:
31-
password: ${{ secrets.pypi_password }}
27+
- uses: pypa/gh-action-pypi-publish@release/v1
3228
name: "Deploy to pypi"
3329

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
1-
name: Autorelease
1+
# Vendored from Autorelease 0.7.0
2+
# Update by updating Autorelease and running `autorelease vendor actions`
3+
name: "Autorelease Release"
24
on:
35
push:
46
branches:
7+
# TODO: this should come from yaml conf
58
- stable
69

710
jobs:
811
release-gh:
12+
if: ${{ github.repository == 'dwhswenson/contact_map' }}
913
runs-on: ubuntu-latest
1014
name: "Cut release"
1115
steps:
12-
- uses: actions/checkout@v2
13-
- uses: actions/setup-python@v2
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-python@v5
1418
with:
15-
python-version: "3.7"
19+
python-version: "3.x"
1620
- run: | # TODO: move this to an action
1721
source ./.github/workflows/autorelease-default-env.sh
1822
if [ -f "autorelease-env.sh" ]; then
1923
cat autorelease-env.sh >> $GITHUB_ENV
2024
fi
21-
eval $INSTALL_AUTORELEASE
25+
if [ -f "./.autorelease/install-autorelease" ]; then
26+
source ./.autorelease/install-autorelease
27+
else
28+
eval $INSTALL_AUTORELEASE
29+
fi
2230
name: "Install autorelease"
2331
- run: |
2432
VERSION=`python setup.py --version`
@@ -27,3 +35,4 @@ jobs:
2735
autorelease-release --project $PROJECT --version $VERSION --token $AUTORELEASE_TOKEN
2836
env:
2937
AUTORELEASE_TOKEN: ${{ secrets.AUTORELEASE_TOKEN }}
38+
name: "Cut release"
Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
name: "Autorelease"
1+
# Vendored from Autorelease 0.7.0
2+
# Update by updating Autorelease and running `autorelease vendor actions`
3+
name: "Autorelease testpypi"
24
on:
35
pull_request:
46
branches:
7+
# TODO: this should come from yaml conf
58
- stable
69

710
defaults:
@@ -10,19 +13,26 @@ defaults:
1013

1114
jobs:
1215
deploy_testpypi:
16+
permissions:
17+
id-token: write
18+
if: ${{ github.repository == 'dwhswenson/contact_map' }}
1319
runs-on: ubuntu-latest
1420
name: "Deployment test"
1521
steps:
16-
- uses: actions/checkout@v2
17-
- uses: actions/setup-python@v2
22+
- uses: actions/checkout@v4
23+
- uses: actions/setup-python@v5
1824
with:
1925
python-version: "3.x"
2026
- run: | # TODO: move this to an action
2127
source ./.github/workflows/autorelease-default-env.sh
2228
if [ -f "autorelease-env.sh" ]; then
2329
cat autorelease-env.sh >> $GITHUB_ENV
2430
fi
25-
eval $INSTALL_AUTORELEASE
31+
if [ -f "./.autorelease/install-autorelease" ]; then
32+
source ./.autorelease/install-autorelease
33+
else
34+
eval $INSTALL_AUTORELEASE
35+
fi
2636
name: "Install autorelease"
2737
- run: |
2838
python -m pip install twine wheel
@@ -35,26 +45,36 @@ jobs:
3545
python setup.py sdist bdist_wheel
3646
twine check dist/*
3747
name: "Build and check package"
38-
- uses: pypa/gh-action-pypi-publish@master
48+
- uses: pypa/gh-action-pypi-publish@release/v1
3949
with:
40-
password: ${{ secrets.testpypi_password }}
4150
repository_url: https://test.pypi.org/legacy/
4251
name: "Deploy to testpypi"
4352
test_testpypi:
53+
if: ${{ github.repository == 'dwhswenson/contact_map' }}
4454
runs-on: ubuntu-latest
4555
name: "Test deployed"
4656
needs: deploy_testpypi
4757
steps:
48-
- uses: actions/checkout@v2
49-
- uses: actions/setup-python@v2
58+
- uses: actions/checkout@v4
59+
- uses: actions/setup-python@v5
5060
with:
5161
python-version: "3.x"
5262
- run: | # TODO: move this to an action
5363
source ./.github/workflows/autorelease-default-env.sh
5464
if [ -f "autorelease-env.sh" ]; then
5565
cat autorelease-env.sh >> $GITHUB_ENV
5666
fi
57-
eval $INSTALL_AUTORELEASE
67+
if [ -f "./.autorelease/install-autorelease" ]; then
68+
source ./.autorelease/install-autorelease
69+
else
70+
eval $INSTALL_AUTORELEASE
71+
fi
5872
name: "Install autorelease"
59-
- run: test-testpypi
60-
73+
- name: "Install testpypi version"
74+
run: install-testpypi
75+
- name: "Test testpypi version"
76+
run: |
77+
if [ -f "autorelease-env.sh" ]; then
78+
cat autorelease-env.sh >> $GITHUB_ENV
79+
fi
80+
test-testpypi

.github/workflows/unit-tests.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,31 +23,30 @@ jobs:
2323
strategy:
2424
matrix:
2525
CONDA_PY:
26-
- "3.13"
2726
- "3.12"
28-
- "3.11"
27+
- "3.13"
28+
- "3.14"
2929
OS: ["ubuntu"]
3030
MDTRAJ: ["mdtraj-release"]
3131
INSTALL_WITH: ["pip"]
3232
include:
33-
- CONDA_PY: "3.13"
33+
- CONDA_PY: "3.14"
3434
OS: "ubuntu"
3535
MDTRAJ: "mdtraj-dev"
3636
INSTALL_WITH: "pip"
37-
- CONDA_PY: "3.13"
37+
- CONDA_PY: "3.14"
3838
OS: "windows"
3939
MDTRAJ: "mdtraj-release"
4040
INSTALL_WITH: "conda"
41-
- CONDA_PY: "3.11"
41+
- CONDA_PY: "3.12"
4242
OS: "windows"
4343
MDTRAJ: "mdtraj-release"
4444
INSTALL_WITH: "conda"
4545

4646
steps:
47-
- uses: actions/checkout@v2
47+
- uses: actions/checkout@v4
4848
with:
4949
fetch-depth: 2
50-
- uses: actions/setup-python@v2
5150
- uses: conda-incubator/setup-miniconda@v2
5251
with:
5352
auto-update-conda: true

contact_map/tests/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import os
2-
from pkg_resources import resource_filename
2+
from importlib.resources import files
33

44
# pylint: disable=unused-import
55

@@ -8,7 +8,7 @@
88
import pytest
99

1010
def find_testfile(fname):
11-
return resource_filename('contact_map', os.path.join('tests', fname))
11+
return os.fspath(files(__package__).joinpath(fname))
1212

1313
def zero_to_nan(input_arr):
1414
arr = input_arr.copy()

docs/conf.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
import os
2020
import sys
2121
import shutil
22+
from configparser import ConfigParser
23+
from importlib.metadata import PackageNotFoundError, version as package_version
24+
2225
import sphinx_rtd_theme
23-
import pkg_resources
2426
import packaging.version
2527
# sys.path.insert(0, os.path.abspath('.'))
2628
#sys.path.insert(0, os.path.abspath('../contact_map/'))
@@ -41,7 +43,16 @@
4143
# |version| and |release|, also used in various other places throughout the
4244
# built documents.
4345
#
44-
release = pkg_resources.get_distribution('contact_map').version
46+
def get_release():
47+
try:
48+
return package_version('contact_map')
49+
except PackageNotFoundError:
50+
conf = ConfigParser()
51+
conf.read(os.path.abspath('../setup.cfg'))
52+
return conf.get('metadata', 'version')
53+
54+
55+
release = get_release()
4556
version = packaging.version.Version(release).base_version
4657

4758
# The short X.Y version.

0 commit comments

Comments
 (0)