Skip to content

Commit

Permalink
Swap to pdm
Browse files Browse the repository at this point in the history
  • Loading branch information
moeyensj committed Oct 29, 2024
1 parent b1d497c commit 40cfd8d
Show file tree
Hide file tree
Showing 34 changed files with 117 additions and 220 deletions.
16 changes: 7 additions & 9 deletions .github/workflows/conda-build-lint-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: conda - Build, Lint, and Test
name: conda - Build Lint and Test

on:
push:
Expand All @@ -12,27 +12,25 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ["3.10"]
defaults:
run:
shell: bash -l {0}

steps:
- name: Checkout git repo
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Get git tags
run: git fetch --prune --unshallow --tags
- name: Set up miniconda
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: "difi"
auto-update-conda: true
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: conda install -c defaults -c conda-forge --file requirements.txt --yes
- name: Build and install
run: pip install . --no-deps
run: pip install .[dev]
- name: Lint
run: pre-commit run --all-files
run: pdm lint
- name: Test
run: pytest . --cov
run: pdm test
33 changes: 0 additions & 33 deletions .github/workflows/conda-publish.yml

This file was deleted.

19 changes: 8 additions & 11 deletions .github/workflows/docker-build-lint-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: docker - Build, Lint, and Test
name: docker - Build Lint and Test

on:
push:
Expand All @@ -11,20 +11,17 @@ jobs:
runs-on: ubuntu-latest
env:
IMAGE_TAG: ${{ github.sha }}

steps:
- name: Checkout git repo
uses: actions/checkout@v3
- uses: jpribyl/[email protected]
# Ignore the failure of a step and avoid terminating the job.
continue-on-error: true
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
with:
install: true
- name: Build and install
run: docker build --load -t precovery:$IMAGE_TAG .
- name: Build
run: docker build --load -t difi:$IMAGE_TAG .
- name: Lint
run: docker run -i precovery:$IMAGE_TAG pre-commit run --all-files
run: docker run -i difi:$IMAGE_TAG pdm lint
- name: Test
run: docker run -i precovery:$IMAGE_TAG pytest . --cov
run: docker run -i difi:$IMAGE_TAG pdm test
30 changes: 16 additions & 14 deletions .github/workflows/pip-build-lint-test-coverage.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: pip - Build, Lint, Test, and Coverage
name: pip - Build Lint Test and Coverage

on:
push:
Expand All @@ -12,30 +12,32 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ["3.10"]
defaults:
run:
shell: bash -l {0}

steps:
- name: Checkout git repo
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Get git tags
run: git fetch --prune --unshallow --tags
- name: Set up miniconda
uses: conda-incubator/setup-miniconda@v2
- uses: actions/setup-python@v5
with:
activate-environment: "difi"
auto-update-conda: true
python-version: ${{ matrix.python-version }}
- name: Build and install
run: pip install .[tests]
cache: 'pip' # caching pip dependencies
- name: Install Dependencies
run: |
pip install pip --upgrade
pip install ".[dev]"
- name: Lint
run: pre-commit run --all-files
- name: Test
run: pytest . --cov --cov-report xml
- name: Coverage
run: pdm run lint
# - name: Type check
# run: pdm run typecheck
- name: Test with coverage
run: pdm run coverage
- name: Coverage Report
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.COVERALLS_TOKEN }}
path-to-lcov: coverage.xml
path-to-lcov: coverage.xml
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,8 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# pdm virtual environments
.pdm-python
pdm.lock
_version.py
31 changes: 0 additions & 31 deletions .pre-commit-config.yaml

This file was deleted.

29 changes: 10 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
FROM ubuntu:latest
FROM python:3.11

# Set shell to bash
SHELL ["/bin/bash", "-c"]
CMD ["/bin/bash"]

# Update system dependencies
RUN apt-get update \
&& apt-get upgrade -y

# Install system dependencies
RUN apt-get install -y git python3 python3-pip python3-dev

# Upgrade pip to the latest version and install pre-commit
RUN pip install --upgrade pip pre-commit

# Install pre-commit hooks (before difi is installed to cache this step)
# Remove the .git directory after pre-commit is installed as difi's .git
# will be added to the container
RUN mkdir /code/
COPY .pre-commit-config.yaml /code/
WORKDIR /code/
RUN git init . \
&& pre-commit install-hooks \
&& rm -rf .git
&& apt-get upgrade -y \
&& apt-get install -y pip git

# Install difi
RUN mkdir -p /code/
WORKDIR /code/
ADD . /code/
RUN pip install -e .[tests]
RUN pip install -e .[dev]
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2018-2023, Joachim Moeyens
Copyright (c) 2018-2024, Joachim Moeyens
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include difi/*.py
include src/*.py
include *.md
include *.toml
exclude Dockerfile
Expand Down
1 change: 0 additions & 1 deletion additional_requirements.txt

This file was deleted.

102 changes: 63 additions & 39 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "difi/version.py"
write_to_template = "__version__ = '{version}'"

[project]
name = "difi"
dynamic = ["version"]
authors = [
{name = "Joachim Moeyens", email = "[email protected]"},
]
Expand All @@ -17,62 +10,93 @@ maintainers = [
description = "Did I Find It?"
readme = "README.md"
license = {file = "LICENSE.md"}
keywords = [
"astronomy",
"astrophysics",
"space",
"science",
"asteroids",
"comets",
"solar system"
]
requires-python = ">=3.10"
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"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",
"Topic :: Scientific/Engineering :: Astronomy",
"Topic :: Scientific/Engineering :: Physics",
]
requires-python = ">=3.8"
keywords = [
"astronomy",
"astrophysics",
"space",
"science",
"asteroids",
"comets",
"solar system"
]

dependencies = [
"numba",
"numpy",
"pandas",
]
dynamic = ["version"]

[project.urls]
homepage = "https://github.com/moeyensj/difi"
repository = "https://github.com/moeyensj/difi"
[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"
[tool.pdm.build]
includes = ["src/difi/"]

[project.optional-dependencies]
tests = [
"pytest",
"pytest-cov",
"pytest-benchmark",
"pre-commit",
]
[tool.pdm.version]
source = "scm"
write_to = "src/difi/_version.py"
write_template = "__version__ = '{}'"

[tool.pytest.ini_options]
addopts = ["--benchmark-skip"]
[tool.pdm.scripts]
check = { composite = ["lint", "typecheck", "test"] }
format = { composite = ["black ./src/difi", "isort ./src/difi"] }
lint = { composite = [
"ruff check ./src/difi",
"black --check ./src/difi",
"isort --check-only ./src/difi",
] }
fix = "ruff ./src/difi --fix"
typecheck = "mypy --strict ./src/difi"

[tool.setuptools]
include-package-data = true
test = "pytest --benchmark-disable {args}"
doctest = "pytest --doctest-plus --doctest-only"
benchmark = "pytest --benchmark-only"
coverage = "pytest --cov=difi --cov-report=xml"

[tool.setuptools.packages.find]
include = ['difi*']
[project.urls]
"Documentation" = "https://github.com/moeyensj/difi#README.md"
"Issues" = "https://github.com/moeyensj/difi/issues"
"Source" = "https://github.com/moeyensj/difi"

[tool.setuptools.package-data]
difi = ["tests/*.txt"]
[project.optional-dependencies]
dev = [
"black",
"ipython",
"isort",
"mypy",
"pdm",
"pytest-benchmark",
"pytest-cov",
"pytest-doctestplus",
"pytest-mock",
"pytest",
"ruff",
]

[tool.black]
line-length = 110

[tool.isort]
profile = "black"

[tool.ruff]
line-length = 110
target-version = "py311"
lint.ignore = []
exclude = ["build"]

[tool.mypy]
ignore_missing_imports = true
Loading

0 comments on commit 40cfd8d

Please sign in to comment.