Skip to content

Commit e108074

Browse files
authored
Make a package (#1)
- Rewrite everything, improve speed and memory usage, fix some bugs. - Create a package including documentation and tests (just started, needs work).
1 parent 0827c92 commit e108074

36 files changed

+1481
-1137
lines changed

.github/workflows/documentation.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: documentation
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
release:
9+
types:
10+
- published
11+
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
docs:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 100
23+
persist-credentials: false
24+
25+
- name: Setup Python
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: "3.11"
29+
30+
- name: Install dependencies
31+
shell: bash -l {0}
32+
run: |
33+
python -m pip install --upgrade pip
34+
python -m pip install -r requirements-dev.txt
35+
36+
- name: Create docs
37+
shell: bash -l {0}
38+
run: make html
39+
40+
- name: Deploy to GitHub Pages
41+
uses: peaceiris/actions-gh-pages@v4
42+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
43+
with:
44+
publish_branch: gh-pages
45+
github_token: ${{ secrets.GITHUB_TOKEN }}
46+
publish_dir: ./docs/_build/html/
47+
force_orphan: true

.github/workflows/linux.yml

+142
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: linux
2+
3+
# Only build PRs, the main branch, and releases.
4+
on:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
release:
10+
types:
11+
- published
12+
schedule:
13+
- cron: "14 14 20 * *"
14+
15+
# Use bash by default in all jobs
16+
defaults:
17+
run:
18+
# Using "-l {0}" is necessary for conda environments to be activated
19+
# But this breaks on MacOS if using actions/setup-python:
20+
# https://github.com/actions/setup-python/issues/132
21+
shell: bash
22+
23+
# Cancel any previous run of the test job.
24+
concurrency:
25+
group: ${{ github.workflow }}-${{ github.ref }}
26+
cancel-in-progress: true
27+
28+
jobs:
29+
test:
30+
31+
name: basic
32+
runs-on: ubuntu-latest
33+
34+
steps:
35+
36+
# Checks-out your repository under $GITHUB_WORKSPACE
37+
- name: Checkout
38+
uses: actions/checkout@v4
39+
with:
40+
# Need to fetch more than the last commit so that setuptools-scm can
41+
# create the correct version string. If the number of commits since
42+
# the last release is greater than this, the version still be wrong.
43+
# Increase if necessary.
44+
fetch-depth: 100
45+
# The GitHub token is preserved by default but this job doesn't need
46+
# to be able to push to GitHub.
47+
persist-credentials: false
48+
49+
# Need the tags so that setuptools-scm can form a valid version number
50+
- name: Fetch git tags
51+
run: git fetch origin 'refs/tags/*:refs/tags/*'
52+
53+
- name: Setup Python
54+
uses: actions/setup-python@v5
55+
with:
56+
python-version: "3.11"
57+
58+
- name: Install dependencies
59+
shell: bash -l {0}
60+
run: |
61+
python -m pip install --upgrade pip
62+
python -m pip install -r requirements-dev.txt
63+
64+
- name: Flake8
65+
shell: bash -l {0}
66+
run: flake8 docs/conf.py setup.py resmda/ tests/
67+
68+
- name: Test with pytest
69+
shell: bash -l {0}
70+
run: |
71+
python -m pip install .
72+
pytest --cov=resmda
73+
74+
deploy:
75+
needs: test
76+
name: Deploy to PyPI
77+
runs-on: ubuntu-latest
78+
# Only from the origin repository, not forks; only main and tags.
79+
if: github.repository_owner == 'tuda' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
80+
81+
steps:
82+
# Checks-out your repository under $GITHUB_WORKSPACE
83+
- name: Checkout
84+
uses: actions/checkout@v4
85+
with:
86+
# Need to fetch more than the last commit so that setuptools-scm can
87+
# create the correct version string. If the number of commits since
88+
# the last release is greater than this, the version will still be
89+
# wrong. Increase if necessary.
90+
fetch-depth: 100
91+
# The GitHub token is preserved by default but this job doesn't need
92+
# to be able to push to GitHub.
93+
persist-credentials: false
94+
95+
# Need the tags so that setuptools-scm can form a valid version number
96+
- name: Fetch git tags
97+
run: git fetch origin 'refs/tags/*:refs/tags/*'
98+
99+
- name: Setup Python
100+
uses: actions/setup-python@v5
101+
with:
102+
python-version: "3.11"
103+
104+
- name: Install dependencies
105+
run: |
106+
python -m pip install --upgrade pip
107+
python -m pip install build setuptools-scm
108+
109+
- name: Build source and wheel distributions
110+
if: github.ref == 'refs/heads/main'
111+
run: |
112+
# Change setuptools-scm local_scheme to "no-local-version" so the
113+
# local part of the version isn't included, making the version string
114+
# compatible with Test PyPI.
115+
sed --in-place 's/"root"/"local_scheme":"no-local-version","root"/g' setup.py
116+
117+
- name: Build source and wheel distributions
118+
run: |
119+
# Build source and wheel packages
120+
python -m build
121+
echo ""
122+
echo "Generated files:"
123+
ls -lh dist/
124+
125+
- name: Publish to Test PyPI
126+
if: success()
127+
uses: pypa/gh-action-pypi-publish@release/v1
128+
with:
129+
user: __token__
130+
password: ${{ secrets.TEST_PYPI_PASSWORD }}
131+
repository_url: https://test.pypi.org/legacy/
132+
# Allow existing releases on test PyPI without errors.
133+
# NOT TO BE USED in PyPI!
134+
skip_existing: true
135+
136+
- name: Publish to PyPI
137+
# Only for releases
138+
if: success() && github.event_name == 'release'
139+
uses: pypa/gh-action-pypi-publish@release/v1
140+
with:
141+
user: __token__
142+
password: ${{ secrets.PYPI_PASSWORD }}

.gitignore

+16-98
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,22 @@
1-
# Byte-compiled / optimized / DLL files
1+
# Directories and file types
22
__pycache__/
3-
*.py[cod]
43

5-
# C and Fortran extensions
6-
*.so
7-
*.dylib
8-
*.dll
9-
*.slo
10-
*.lo
11-
*.o
12-
*.obj
13-
*.mod
14-
*.smod
15-
*.lai
16-
*.la
17-
*.a
18-
*.lib
19-
*.exe
20-
*.out
21-
*.app
22-
23-
# Distribution / packaging
24-
.Python
25-
env/
26-
build/
27-
develop-eggs/
28-
dist/
29-
downloads/
30-
eggs/
31-
.eggs/
32-
lib/
33-
lib64/
34-
parts/
35-
sdist/
36-
var/
37-
*.egg-info/
38-
.installed.cfg
39-
*.egg
40-
41-
# PyInstaller
42-
# Usually these files are written by a python script from a template
43-
# before PyInstaller builds the exe, so as to inject date/other infos into it.
44-
*.manifest
45-
*.spec
46-
47-
# Installer logs
48-
pip-log.txt
49-
pip-delete-this-directory.txt
50-
51-
# Unit test / coverage reports
52-
htmlcov/
53-
.tox/
54-
.coverage
55-
.coverage.*
56-
.cache
57-
nosetests.xml
58-
coverage.xml
59-
*,cover
60-
61-
# Translations
62-
*.mo
63-
*.pot
64-
65-
# Django stuff:
66-
*.log
67-
68-
# Sphinx documentation
4+
# Sphinx
695
docs/_build/
6+
docs/api/resmda*
7+
docs/savefig/
8+
docs/gallery/*
709

71-
# PyBuilder
72-
target/
73-
74-
# DotEnv configuration
75-
.env
76-
77-
# Database
78-
*.db
79-
*.rdb
80-
81-
# Pycharm
82-
.idea
83-
84-
# TeX/LaTeX
85-
*.aux
86-
*.bbl
87-
*.blg
88-
*.synctex.gz
89-
*.xwm
90-
91-
# IPython NB Checkpoints
92-
.ipynb_checkpoints/
93-
94-
# exclude compiled binaries
95-
bin/
10+
# Pytest and coverage related
11+
htmlcov
12+
.coverage
13+
.pytest_cache/
9614

97-
# exclude data from source control by default
98-
/data/external
99-
/data/interim
100-
/data/processed
101-
/data/raw
15+
# setuptools_scm
16+
resmda/version.py
10217

103-
# exclude external models from source control
104-
/src/external/
18+
# Build related
19+
.eggs/
20+
build/
21+
dist/
22+
resmda.egg-info/

AUTHORS.md

-12
This file was deleted.

0 commit comments

Comments
 (0)