Skip to content

Commit

Permalink
Support py3.12, move to rye (#45)
Browse files Browse the repository at this point in the history
* move to rye and increase testing to support py3.12

* fix test workflow

* add coverage workflow
  • Loading branch information
trappitsch authored Mar 25, 2024
1 parent 481381a commit 10eeeaa
Show file tree
Hide file tree
Showing 16 changed files with 148 additions and 180 deletions.
3 changes: 0 additions & 3 deletions .darglint

This file was deleted.

18 changes: 0 additions & 18 deletions .flake8

This file was deleted.

51 changes: 26 additions & 25 deletions .github/workflows/package_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,40 @@ on:
pull_request:
branches: [ main ]

env:
MAIN_PYTHON_VERSION: "3.12"

jobs:
# Build and test
build:
if: github.repository_owner == 'galactic-forensics'
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
- name: Checkout repo
uses: actions/checkout@v4
- name: Install the latest version of rye
uses: eifinger/setup-rye@v2
- name: Sync Rye
run: |
rye pin ${{ matrix.python-version }}
rye sync --all-features
- name: Run Tests and doctests
run: |
rye test
rye run test_docs
- name: Run Lint on one python
if: ${{ matrix.python-version == env.MAIN_PYTHON_VERSION }}
run: rye lint
- name: Run Pytest with coverage
if: ${{ matrix.python-version == env.MAIN_PYTHON_VERSION }}
run: |
python -m pip install --upgrade pip
pip install nox
pip install .[test]
- name: Run nox
run: nox --no-error-on-missing-interpreters
- name: Generate coverage report
run: pytest
- name: Upload coverage to Codecov
rye run test_cov
- name: Upload coverage reports to Codecov
if: ${{ matrix.python-version == env.MAIN_PYTHON_VERSION && github.repository_owner == 'galactic-forensics' }}
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./coverage/reports/
env_vars: OS,PYTHON
fail_ci_if_error: true
files: ./coverage.xml
flags: unittests
name: codecov-umbrella
path_to_write_report: ./coverage/codecov_report.txt
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
32 changes: 15 additions & 17 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,24 @@ on:
release:
types: [created]

env:
PYTHON_VERSION: "3.12"

jobs:
deploy:
if: github.repository_owner == 'galactic-forensics'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
pip install .
- name: Build and publish
env:
PYPI_USERNAME: '__token__'
PYPI_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python -m build
python -m twine upload dist/* -u $PYPI_USERNAME -p $PYPI_PASSWORD
- name: Checkout code
uses: actions/checkout@v4
- name: Install the latest version of rye
uses: eifinger/setup-rye@v2
- name: Sync Rye
run: |
rye pin ${{ env.PYTHON_VERSION }}
rye sync
- name: Build and release the controller
run: |
rye build
rye publish --token ${{ secrets.PYPI_TOKEN }} --yes
6 changes: 0 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ target/
profile_default/
ipython_config.py

# pyenv
.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
Expand Down Expand Up @@ -130,6 +127,3 @@ dmypy.json

# PyCharm
.idea/

# scm version
ceresfit/_version.py
16 changes: 10 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 24.3.0
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.2.2
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.1
hooks:
- id: pyupgrade
args: [ --py36-plus ]
args: [ --py38-plus ]
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Reto Trappitsch
Copyright (c) 2023-2024 Reto Trappitsch

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
32 changes: 21 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![codecov](https://codecov.io/gh/galactic-forensics/CEREsFit/branch/main/graph/badge.svg?token=C8KN5UE831)](https://codecov.io/gh/galactic-forensics/CEREsFit)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/galactic-forensics/CEREsFit/main.svg)](https://results.pre-commit.ci/latest/github/galactic-forensics/CEREsFit/main)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Rye](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/rye/main/artwork/badge.json)](https://rye-up.com)

The goal of CEREsFit (Correlated Errors Regression Estimate Fit)
is to provide a python package
Expand Down Expand Up @@ -63,24 +63,34 @@ can be found

## Development & Contributing

If you would like to contribute,
clone the GitHub repo and then install the package locally from within the folder via:
This project is developed using [Rye](https://rye-up.com/).
After cloning,
you can simply run

```rye sync```

in the project folder and you should be good to go.

Code auto formatting is implemented using
[`pre-commit`](https://pre-commit.com/) hooks.

For local formatting and linting,
please use

```
pip install -e .[dev]
rye fmt
rye lint
```

If you also want to install the full test environment,
run:
For running tests, use:

```
pip install -e .[dev,test]
rye test
rye run test_docs
```

Code auto formatting is implemented using
[`pre-commit`](https://pre-commit.com/) hooks.
Full testing of the package can be done with
[`nox`](https://nox.thea.codes/en/stable/index.html).
The first of these commands runs `pytest`,
the second checks the documentation tests using `xdoctest`.

Please feel free to raise issues on GitHub
and open pull requests if you have a feature to be added.
Expand Down
58 changes: 0 additions & 58 deletions noxfile.py

This file was deleted.

64 changes: 31 additions & 33 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,57 +1,55 @@
[build-system]
requires = ["flit_scm"]
build-backend = "flit_scm:buildapi"

[project]
authors = [{name = "Reto Trappitsch", email = "[email protected]"}]
name = "ceresfit"
version = "0.3.0"
description = "Linear Regression for data set with correlated or uncorrelated uncertainties in both axes."
authors = [
{ name = "Reto Trappitsch", email = "[email protected]" }
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Operating System :: OS Independent",
"License :: OSI Approved :: MIT License",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Physics",
]
dependencies = ["numpy", "scipy"]
dynamic = ["version", "description"]
license = {file = "LICENSE"}
name = "ceresfit"
dependencies = [
"numpy",
"scipy"
]
readme = "README.md"
requires-python=">=3.8"
requires-python = ">= 3.8"
license = { text = "MIT" }

[project.urls]
Source = "https://github.com/galactic-forensics/CEREsFit"

[project.optional-dependencies]
dev = [
"nox"
]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

test = [
"darglint>=1.5.1",
"flake8>=4,<5",
"flake8-bandit",
"flake8-black",
"flake8-bugbear",
"flake8-docstrings",
"flake8-import-order",
"bandit<=1.7.2",
"pytest>=6.0",
[tool.rye]
managed = true
dev-dependencies = [
"pytest>=8.0",
"pytest-cov",
"xdoctest>=1.1.3",
]

[tool.flit.sdist]
exclude = ["examples/", ".gitignore"]
[tool.rye.scripts]
test_cov = "pytest --cov --cov-report xml"
test_docs = "xdoctest ceresfit --all"

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.build.targets.wheel]
packages = ["src/ceresfit"]

[tool.pytest.ini_options]
minversion = "6.0"
minversion = "8.0"
addopts = "--cov=ceresfit --cov-report=xml"
testpaths = "tests"

[tool.setuptools_scm]
write_to = "ceresfit/_version.py"
Loading

0 comments on commit 10eeeaa

Please sign in to comment.