Skip to content

Commit 8f54d38

Browse files
authored
Merge pull request #18 from diffpy/migration
Migration
2 parents 6cf9af8 + 7bfbf6c commit 8f54d38

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2658
-1467
lines changed

.codecov.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
coverage:
2+
status:
3+
project: # more options at https://docs.codecov.com/docs/commit-status
4+
default:
5+
target: auto # use the coverage from the base commit, fail if coverage is lower
6+
threshold: 0% # allow the coverage to drop by
7+
8+
comment:
9+
layout: " diff, flags, files"
10+
behavior: default
11+
require_changes: false
12+
require_base: false # [true :: must have a base report to post]
13+
require_head: false # [true :: must have a head report to post]
14+
hide_project_coverage: false # [true :: only show coverage on the git diff aka patch coverage]

.codespell/ignore_lines.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
;; Please include filenames and explanations for each ignored line.
2+
;; See https://docs.openverse.org/meta/codespell.html for docs.

.codespell/ignore_words.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
;; Please include explanations for each ignored word (lowercase).
2+
;; See https://docs.openverse.org/meta/codespell.html for docs.
3+
4+
;; abbreviation for "materials" often used in a journal title
5+
mater
6+
7+
;; Frobenius norm used in np.linalg.norm
8+
fro

.flake8

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# As of now, flake8 does not natively support configuration via pyproject.toml
2+
# https://github.com/microsoft/vscode-flake8/issues/135
3+
[flake8]
4+
exclude =
5+
.git,
6+
__pycache__,
7+
build,
8+
dist,
9+
docs/source/conf.py
10+
max-line-length = 79
11+
# Ignore some style 'errors' produced while formatting by 'black'
12+
# https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#labels-why-pycodestyle-warnings
13+
extend-ignore = E203
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
name: Bug Report or Feature Request
3+
about: Report a bug or suggest a new feature!
4+
title: ""
5+
labels: ""
6+
assignees: ""
7+
---
8+
9+
### Problem
10+
11+
<!--
12+
For a bug report, please copy and paste any error messages from the application or command-line here.
13+
For a feature request, please state how the new functionality could benefit the community.
14+
-->
15+
16+
### Proposed solution
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
name: Release
3+
about: Checklist and communication channel for PyPI and GitHub release
4+
title: "Ready for <version-number> PyPI/GitHub release"
5+
labels: "release"
6+
assignees: ""
7+
---
8+
9+
### PyPI/GitHub rc-release preparation checklist:
10+
11+
- [ ] All PRs/issues attached to the release are merged.
12+
- [ ] All the badges on the README are passing.
13+
- [ ] License information is verified as correct. If you are unsure, please comment below.
14+
- [ ] Locally rendered documentation contains all appropriate pages, including API references (check no modules are
15+
missing), tutorials, and other human-written text is up-to-date with any changes in the code.
16+
- [ ] Installation instructions in the README, documentation, and the website are updated.
17+
- [ ] Successfully run any tutorial examples or do functional testing with the latest Python version.
18+
- [ ] Grammar and writing quality are checked (no typos).
19+
- [ ] Install `pip install build twine`, run `python -m build` and `twine check dist/*` to ensure that the package can be built and is correctly formatted for PyPI release.
20+
21+
Please tag the maintainer (e.g., @username) in the comment here when you are ready for the PyPI/GitHub release. Include any additional comments necessary, such as version information and details about the pre-release here:
22+
23+
### PyPI/GitHub full-release preparation checklist:
24+
25+
- [ ] Create a new conda environment and install the rc from PyPI (`pip install <package-name>==??`)
26+
- [ ] License information on PyPI is correct.
27+
- [ ] Docs are deployed successfully to `https://<github-username-or-orgname>/<package-name>`.
28+
- [ ] Successfully run all tests, tutorial examples or do functional testing.
29+
30+
Please let the maintainer know that all checks are done and the package is ready for full release.
31+
32+
### conda-forge release preparation checklist:
33+
34+
<!-- After the maintainer releases the PyPI package, please check the following when creating a PR for conda-forge release.-->
35+
36+
- [ ] Ensure that the full release has appeared on PyPI successfully.
37+
- [ ] New package dependencies listed in `conda.txt` and `tests.txt` are added to `meta.yaml` in the feedstock.
38+
- [ ] Close any open issues on the feedstock. Reach out to the maintainer if you have questions.
39+
- [ ] Tag the maintainer for conda-forge release.
40+
41+
### Post-release checklist
42+
43+
<!-- Before closing this issue, please complete the following: -->
44+
45+
- [ ] Run tutorial examples and conduct functional testing using the installation guide in the README. Attach screenshots/results as comments.
46+
- [ ] Documentation (README, tutorials, API references, and websites) is deployed without broken links or missing figures.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
### What problem does this PR address?
2+
3+
<!-- Provide a brief overview and link to the issue. Attach outputs, including screenshots (before/after), if helpful for the reviewer. -->
4+
5+
### What should the reviewer(s) do?
6+
7+
<!-- Merge the code, provide feedback, initiate a discussion, etc. -->
8+
9+
<!--
10+
Use the following checklist items when applicable (select only what applies):
11+
- [ ] This PR introduces a public-facing change (e.g., figures, CLI input/output, API).
12+
- [ ] Documentation (e.g., tutorials, examples, README) has been updated.
13+
- [ ] A tracking issue or plan to update documentation exists.
14+
- [ ] This PR affects internal functionality only (no user-facing change).
15+
-->
Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
name: Build Wheels and Release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- "*"
8+
9+
env:
10+
PYTHON_VERSIONS: '["3.11","3.12","3.13"]'
11+
12+
permissions:
13+
contents: write
14+
actions: read
15+
packages: write
16+
17+
concurrency:
18+
group: build-wheels-${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
defaults:
22+
run:
23+
shell: bash {0}
24+
25+
jobs:
26+
get-python-versions:
27+
runs-on: ubuntu-latest
28+
outputs:
29+
py_ver: ${{ steps.set.outputs.py_ver }}
30+
py_last: ${{ steps.set.outputs.py_last }}
31+
steps:
32+
- id: set
33+
run: |
34+
echo py_ver=$PYTHON_VERSIONS >> $GITHUB_OUTPUT
35+
echo "py_last=${{ fromJson(env.PYTHON_VERSIONS)[0] }}" >> $GITHUB_OUTPUT
36+
37+
check-tag-on-main:
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Checkout repository with full history
41+
uses: actions/checkout@v4
42+
with:
43+
token: ${{ secrets.PAT_TOKEN }}
44+
fetch-depth: 0
45+
46+
- name: Verify tag
47+
run: |
48+
git fetch origin main
49+
TAG_COMMIT=$(git rev-parse ${{ github.ref_name }})
50+
if git merge-base --is-ancestor "$TAG_COMMIT" origin/main; then
51+
echo "Tag ${{ github.ref_name }} ($TAG_COMMIT) is contained in main"
52+
else
53+
echo "::error::Tag ${{ github.ref_name }} ($TAG_COMMIT) is not found in main. Please release from the main branch."
54+
exit 1
55+
fi
56+
57+
check-tag-privilege:
58+
# No third party actions used
59+
uses: scikit-package/release-scripts/.github/workflows/_check-tag-privilege.yml@v0
60+
with:
61+
maintainer_github_username: sbillinge
62+
63+
build-sdist:
64+
needs: [check-tag-privilege, get-python-versions, check-tag-on-main]
65+
runs-on: ubuntu-latest
66+
67+
steps:
68+
- name: Checkout
69+
# GitHub officially-maintained actions
70+
uses: actions/checkout@v4
71+
with:
72+
fetch-depth: 0
73+
74+
- name: Set up Python
75+
# GitHub officially-maintained actions
76+
uses: actions/setup-python@v5
77+
with:
78+
python-version: ${{ needs.get-python-versions.outputs.py_last }}
79+
80+
- name: Build docs and remove fonts that blow up the wheel size
81+
run: |
82+
python -m pip install Sphinx sphinx-rtd-theme sphinx-copybutton m2r
83+
cd docs
84+
make html
85+
cd build/html/_static/css/fonts
86+
find . -type f ! -name '*.ttf' -delete
87+
cd ../..
88+
rm -rf fonts
89+
cd ..
90+
rm -rf _sources
91+
cd ..
92+
rm -rf doctrees
93+
cd ../..
94+
95+
- name: Make sdist
96+
run: |
97+
python -m pip install --upgrade pip build cython setuptools setuptools-git-versioning
98+
python -m build --sdist --no-isolation
99+
100+
- name: Strip source codes
101+
run: |
102+
set -euo pipefail
103+
tar xf dist/diffpy_srxconfutils-*.tar.gz
104+
SRC_DIR=$(find . -maxdepth 1 -type d -name 'diffpy_srxconfutils-*' | head -n1)
105+
find "$SRC_DIR" -type f -name '*.c' -print0 \
106+
| xargs -0 perl -i.bak -0777 -pe 's{/\*.*?\*/}{}gs'
107+
find "$SRC_DIR" -type f -name '*.c.bak' -delete
108+
tar czf dist/"${SRC_DIR#./}".tar.gz "$SRC_DIR"
109+
rm -rf "$SRC_DIR"
110+
111+
- name: Upload sdist
112+
# GitHub officially-maintained actions
113+
uses: actions/upload-artifact@v4
114+
with:
115+
name: sdist
116+
path: dist/
117+
retention-days: 1
118+
119+
- name: Upload INSTRUCTIONS.txt
120+
uses: actions/upload-artifact@v4
121+
with:
122+
name: instructions
123+
path: INSTRUCTIONS.txt
124+
125+
build-wheels:
126+
needs: [build-sdist, get-python-versions]
127+
128+
name: Build wheels ${{ matrix.python }}-${{ matrix.buildplat }}
129+
runs-on: ${{ matrix.buildplat }}
130+
strategy:
131+
fail-fast: false
132+
matrix:
133+
buildplat:
134+
- ubuntu-latest
135+
- macos-14
136+
- windows-latest
137+
python: ${{ fromJSON(needs.get-python-versions.outputs.py_ver) }}
138+
steps:
139+
- name: Download sdist
140+
# GitHub officially-maintained actions
141+
uses: actions/download-artifact@v4
142+
with:
143+
name: sdist
144+
path: dist/
145+
146+
- name: Set up Python
147+
uses: actions/setup-python@v5
148+
with:
149+
python-version: ${{ matrix.python }}
150+
151+
- name: Build wheels
152+
run: |
153+
# setuptools-git-versioning only look into .git and PKG-INFO in the top directory
154+
which python; python --version
155+
which pip; pip --version
156+
python -m pip install --upgrade pip build cython setuptools setuptools-git-versioning
157+
tar xf dist/diffpy_srxconfutils-*.tar.gz
158+
cd diffpy_srxconfutils-*
159+
python -m pip wheel . --no-deps --no-build-isolation --wheel-dir ./../dist
160+
161+
- name: Upload wheels
162+
uses: actions/upload-artifact@v4
163+
with:
164+
name: wheels-${{ matrix.python }}-${{ matrix.buildplat }}
165+
path: dist/*.whl
166+
167+
test-wheels:
168+
needs: [build-wheels, get-python-versions]
169+
170+
name: Test wheels ${{ matrix.python }}-${{ matrix.buildplat }}
171+
runs-on: ${{ matrix.buildplat }}
172+
strategy:
173+
fail-fast: false
174+
matrix:
175+
buildplat:
176+
- ubuntu-latest
177+
- macos-14
178+
- windows-latest
179+
python: ${{ fromJson(needs.get-python-versions.outputs.py_ver) }}
180+
steps:
181+
- name: Checkout
182+
uses: actions/checkout@v4
183+
184+
- name: Download wheels
185+
uses: actions/download-artifact@v4
186+
with:
187+
name: wheels-${{ matrix.python }}-${{ matrix.buildplat }}
188+
path: dist/
189+
190+
- name: Set up Python
191+
uses: actions/setup-python@v5
192+
with:
193+
python-version: ${{ matrix.python }}
194+
195+
- name: Install wheels
196+
run: |
197+
python -m pip install --upgrade pip pytest setuptools-git-versioning
198+
python -m pip install dist/*.whl
199+
200+
- name: Assert no source files in installed package
201+
run: |
202+
# For debugging
203+
# touch $(python -c "import sysconfig, os; print(os.path.join(sysconfig.get_paths()['purelib'], 'diffpy/srxconfutils', 'fake.py'))")
204+
python - << 'EOF'
205+
import os, glob, sys, sysconfig
206+
sp = sysconfig.get_paths()['purelib']
207+
pkg = os.path.join(sp, 'diffpy', 'srxconfutils')
208+
patterns = [os.path.join(pkg, '*.py'),
209+
os.path.join(pkg, '*.c')]
210+
bad = []
211+
for p in patterns:
212+
bad.extend(glob.glob(p))
213+
214+
if bad:
215+
print("Found leftover source files in installed package:")
216+
for f in bad:
217+
print(" -", f)
218+
sys.exit(1)
219+
220+
print("No .py or .c files present in diffpy/srxconfutils/")
221+
EOF
222+
223+
- name: Run tests
224+
run: python -m pytest
225+
226+
release:
227+
needs: [test-wheels]
228+
uses: ./.github/workflows/release-github.yml
229+
secrets:
230+
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Check for News
2+
3+
on:
4+
pull_request_target:
5+
branches:
6+
- main
7+
8+
jobs:
9+
check-news-item:
10+
uses: scikit-package/release-scripts/.github/workflows/_check-news-item.yml@v0
11+
with:
12+
project: diffpy.srxconfutils
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
release:
8+
types:
9+
- prereleased
10+
- published
11+
workflow_dispatch:
12+
13+
jobs:
14+
matrix-coverage:
15+
uses: scikit-package/release-scripts/.github/workflows/_matrix-no-codecov-on-merge-to-main.yml@v0
16+
with:
17+
project: diffpy.srxconfutils
18+
c_extension: false
19+
headless: false

0 commit comments

Comments
 (0)