Skip to content

Commit

Permalink
Merge in sunpy package template
Browse files Browse the repository at this point in the history
  • Loading branch information
Cadair committed Feb 9, 2024
1 parent 4b77706 commit 82f84c7
Show file tree
Hide file tree
Showing 5 changed files with 327 additions and 17 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/sub_package_update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
"""
This template is taken from the cruft example code, for further information please see:
https://cruft.github.io/cruft/#automating-updates-with-github-actions
"""
name: Automatic Update from package template
permissions:
contents: write
pull-requests: write

on:
pull_request:
branches:
main
jobs:
update:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
include:
- add-paths: .
body: Use this to merge the changes to the repo
branch: cruft/update
commit-message: "Automate package template update"
title: Incoming updates from package template
- add-paths: .cruft.json
body: Use this to reject changes in the repo
branch: cruft/reject
commit-message: "Chore: reject this cruft update"
title: Reject new updates from package template

steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install Cruft
run: pip3 install cruft

- name: Check if update is available
continue-on-error: false
id: check
run: |
CHANGES=0
if [ -f .cruft.json ]; then
if ! cruft check; then
CHANGES=1
fi
else
echo "No .cruft.json file"
fi
echo "has_changes=$CHANGES" >> "$GITHUB_OUTPUT"
- name: Run update if available
if: steps.check.outputs.has_changes == '1'
run: |
git config --global user.email "[email protected]"
git config --global user.name "Gromit"
cruft update --skip-apply-ask --refresh-private-variables
git restore --staged
- name: Create pull request
if: steps.check.output.has_changes == '1'
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
add-paths: ${{ matrix.add-paths }}
commit-message: ${{ matrix.commit-message }}
branch: ${{ matrix.branch }}
delete-branch: true
branch-suffix: timestamp
title: ${{ matrix.title }}
body: |
This is an autogenerated PR. ${{ matrix.body }}
[Cruft](https://cruft.github.io/cruft/) has detected updates from the Package Template
155 changes: 147 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,156 @@
build/*
*.ipynb_checkpoints*
*.DS_Store
streamtracer.egg-info*
dist/*
*.pyc
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
.coverage
*.so
.asv/*
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

doc/_build/*
doc/api/*
# Cython debug symbols
cython_debug/

target/*
Cargo.lock
6 changes: 6 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Exclude specific files
# Prune folders
prune build
prune docs/_build
prune docs/api
global-exclude *.pyc *.o
37 changes: 28 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
[build-system]
requires = [
"setuptools>=45",
"setuptools_scm[toml]>=6.2",
"oldest-supported-numpy",
"maturin>=0.13,<0.14"
"maturin>=1.0,<2.0"
]
build-backend = "maturin"

[tool.maturin]
features = ["pyo3/extension-module"]
python-source = "python"

[tool.setuptools_scm]

[project]
name = "streamtracer"
version = "2.0.1"
description = "Python wrapped fortran to calculate streamlines"
authors = [
{name = "The SunPy Developers", email="[email protected]"}
{name = "David Stansby", email="[email protected]"},
{name = "Lars Mejnertsen"}
]
readme = "README.md"
requires-python = ">=3.7"
requires-python = ">=3.9"
license = {text = "GPL v3"}
classifiers = [
"Programming Language :: Python :: 3",
]
dependencies = ["numpy>=1.14.5",]
dependencies = [
"numpy>=1.14.5",
]

[project.urls]
homepage = "https://streamtracer.readthedocs.io/en/stable/"
documentation = "https://streamtracer.readthedocs.io/en/stable/"
repository = "https://github.com/dstansby/streamtracer"
repository = "https://github.com/sunpy/streamtracer"

[project.optional-dependencies]
tests = ["pytest", "pytest-cov"]
Expand All @@ -47,3 +46,23 @@ docs = [
[tool.pytest.ini_options]
addopts = "-ra"
testpaths = ["doc", "python"]
doctest_plus = "enabled"
text_file_format = "rst"
addopts = "--doctest-rst"

[tool.coverage.report]
exclude_lines = [
# Have to re-enable the standard pragma
"pragma: no cover",
# Don't complain about packages we have installed
"except ImportError",
# Don't complain if tests don't hit assertions
"raise AssertionError",
"raise NotImplementedError",
# Don't complain about script hooks
"def main(.*):",
# Ignore branches that don't pertain to this version of Python
"pragma: py{ignore_python_version}",
# Don't complain about IPython completion helper
"def _ipython_key_completions_",
]
67 changes: 67 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
[tox]
min_version = 4.0
requires =
tox-pypi-filter>=0.14
envlist =
py{39,310,311,312}{,-oldestdeps,-devdeps}
build_docs
codestyle

[testenv]
pypi_filter = https://raw.githubusercontent.com/sunpy/sunpy/main/.test_package_pins.txt
# Run the tests in a temporary directory to make sure that we don't import
# the package from the source tree
change_dir = .tmp/{envname}
description =
run tests
oldestdeps: with the oldest supported version of key dependencies
devdeps: with the latest developer version of key dependencies

set_env =
MPLBACKEND=agg
devdeps: PIP_EXTRA_INDEX_URL = https://pypi.anaconda.org/astropy/simple https://pypi.anaconda.org/scientific-python-nightly-wheels/simple
# Define the base test command here to allow us to add more flags for each tox factor
PYTEST_COMMAND = pytest -vvv -r fEs --pyargs streamtracer --cov-report=xml --cov=streamtracer --cov-config={toxinidir}/.coveragerc {toxinidir}/docs

deps =
# For packages which publish nightly wheels this will pull the latest nightly
devdeps: numpy>=0.0.dev0
# Packages without nightly wheels will be built from source like this
devdeps: git+https://github.com/sunpy/sunpy
oldestdeps: minimum_dependencies

# The following indicates which extras_require will be installed
extras =
test

commands_pre =
oldestdeps: minimum_dependencies packagename --filename requirements-min.txt
oldestdeps: pip install -r requirements-min.txt
pip freeze --all --no-input

commands =
# To run different commands for different factors exclude the factor from the default command like this
# !online: {env:PYTEST_COMMAND} {posargs}
# Then specify a specific one like this
# online: {env:PYTEST_COMMAND} --remote-data=any {posargs}
# If you have no factors which require different commands this is all you need:
{env:PYTEST_COMMAND} {posargs}

[testenv:codestyle]
pypi_filter =
skip_install = true
description = Run all style and file checks with pre-commit
deps =
pre-commit
commands =
pre-commit install-hooks
pre-commit run --color always --all-files --show-diff-on-failure

[testenv:build_docs]
description = invoke sphinx-build to build the HTML docs
change_dir =
docs
extras =
docs
commands =
sphinx-build -j auto --color -W --keep-going -b html -d _build/.doctrees . _build/html {posargs}

0 comments on commit 82f84c7

Please sign in to comment.