Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pure python rewrite #70

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 40 additions & 60 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@ name: CI

on:
push:
tags: ["*"]
branches:
- master
- main
pull_request:
branches:
- master
- main
branches: [main]
tags: [v*]
pull_request: {}

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -24,48 +19,33 @@ jobs:
- name: Run pre-commit linting
run: pipx run pre-commit run --all-files

check-manifest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# this test ensures that the sdist contains all necessary files
# if it fails, you need to either update MANIFEST.in,
# or add an explicit "ignore" rule to pyproject.toml
- name: Run check-manifest
run: pipx run check-manifest

test:
runs-on: ${{ matrix.platform }}
defaults:
run:
shell: bash -el {0} # needed when using setup-miniconda
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
platform: [ubuntu-latest, windows-latest]
platform: [ubuntu-latest, windows-latest, macos-latest]
include:
- python-version: "3.9"
platform: ubuntu-latest
- python-version: "3.9"
platform: macos-13
- python-version: "3.13"
platform: ubuntu-latest
exclude:
# getting segfaults on _get_coefficients...
# probably related to the recursion limit
- python-version: "3.10"
platform: macos-latest
- python-version: "3.11"
platform: macos-latest

steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v4
with:
version: "0.5.10"
enable-cache: true
cache-dependency-glob: "pyproject.toml"
python-version: ${{ matrix.python-version }}
miniforge-version: latest
use-mamba: true
channels: conda-forge,gurobi,defaults
channel-priority: true

- name: install build deps
run: mamba install scip=9.1.0 gurobi gcovr

- name: add gurobi license
shell: bash
Expand All @@ -76,46 +56,46 @@ jobs:
echo "$LICENSE" > $PWD/gurobi.lic
echo "grb_license_file=$PWD/gurobi.lic" >> $GITHUB_OUTPUT

- name: install package
run: |
python -m pip install -U pip
python -m pip install -e .[dev]
python setup.py build_ext --inplace # required for C coverage
env:
CYTHON_TRACE: 1 # enable coverage of cython code
CFLAGS: "-coverage" # enable coverage of C code
- name: Set up Python
run: uv python install

- name: Install the project
run: uv sync --extra test

- name: run tests
run: |
pytest --color yes -v --cov ilpy --cov-report=xml
gcovr --xml coverage_cpp.xml # generate C coverage report
run: uv run pytest --color yes -v --cov ilpy --cov-report=xml
env:
GRB_LICENSE_FILE: ${{ steps.write-license.outputs.grb_license_file }}

- name: upload coverage
uses: codecov/codecov-action@v5
with:
files: ./coverage.xml,./coverage_cpp.xml

# we only deploy the sdist to PyPI, the wheel is still complicated
deploy-sdist:
# test-motile:
# uses: pyapp-kit/workflows/.github/workflows/test-dependents.yml@v2
# with:
# dependency-repo: funkelab/motile
# dependency-extras: "test"
# python-version: "3.11"

deploy:
needs: test
if: startsWith(github.ref, 'refs/tags')
needs: [test, check-manifest]
name: Build sdist, Publish to PyPI on tagged versions
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Build an sdist
run: |
python -m pip install build
python -m build --sdist
- name: Publish to PyPI
fetch-depth: 0

- name: 👷 Build
run: pipx run build

- name: 🚢 Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}

- uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: "./dist/*"
10 changes: 3 additions & 7 deletions .github/workflows/publish-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,13 @@ jobs:
shell: bash -l {0}
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
- uses: actions/setup-python@v2
with:
python-version: "3.11"
miniforge-version: latest
use-mamba: true
channels: conda-forge,gurobi,defaults
channel-priority: true
python-version: "3.12"

- name: Install package and dependencies
run: |
mamba install scip gurobi
python -m pip install --upgrade pip
python -m pip install -e .[docs]

- name: Build documentation
Expand Down
15 changes: 15 additions & 0 deletions .github2/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
* ilpy version:
* Python version:
* Operating System:

### Description

Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.

### What I Did

```
Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.
```
12 changes: 12 additions & 0 deletions .github2/TEST_FAIL_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: "{{ env.TITLE }}"
labels: [bug]
---
The {{ workflow }} workflow failed on {{ date | date("YYYY-MM-DD HH:mm") }} UTC

The most recent failing test was on {{ env.PLATFORM }} py{{ env.PYTHON }}
with commit: {{ sha }}

Full run: https://github.com/{{ repo }}/actions/runs/{{ env.RUN_ID }}

(This post will be updated if another test fails, as long as this issue remains open.)
10 changes: 10 additions & 0 deletions .github2/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "ci(dependabot):"
76 changes: 76 additions & 0 deletions .github2/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: CI

on:
push:
branches:
- main
tags:
- "v*"
pull_request:
workflow_dispatch:
schedule:
# run every week (for --pre release tests)
- cron: "0 0 * * 0"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
check-manifest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pipx run check-manifest

test:
uses: pyapp-kit/workflows/.github/workflows/test-pyrepo.yml@v2
with:
os: ${{ matrix.platform }}
python-version: ${{ matrix.python-version }}
coverage-upload: artifact
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
platform: [ubuntu-latest, macos-latest, windows-latest]

upload_coverage:
if: always()
needs: [test]
uses: pyapp-kit/workflows/.github/workflows/upload-coverage.yml@v2
secrets:
codecov_token: ${{ secrets.CODECOV_TOKEN }}

deploy:
name: Deploy
needs: test
if: success() && startsWith(github.ref, 'refs/tags/') && github.event_name != 'schedule'
runs-on: ubuntu-latest

permissions:
id-token: write
contents: write

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 🐍 Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: 👷 Build
run: |
python -m pip install build
python -m build

- name: 🚢 Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

- uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: './dist/*'
31 changes: 21 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
# enable pre-commit.ci at https://pre-commit.ci/
# it adds:
# 1. auto fixing pull requests
# 2. auto updating the pre-commit configuration
ci:
autoupdate_schedule: monthly
autofix_commit_msg: "style(pre-commit.ci): auto fixes [...]"
autoupdate_commit_msg: "ci(pre-commit.ci): autoupdate"

repos:
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.23
hooks:
- id: validate-pyproject

- repo: https://github.com/crate-ci/typos
rev: v1.28.4
hooks:
- id: typos
args: [--force-exclude] # omitting --write-changes

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.4
rev: v0.8.3
hooks:
- id: ruff
args: [--fix]
args: [--fix, --unsafe-fixes]
- id: ruff-format

- repo: https://github.com/MarcoGorelli/cython-lint
rev: v0.16.0
hooks:
- id: cython-lint
- id: double-quote-cython-strings

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.9.0
rev: v1.13.0
hooks:
- id: mypy
files: "^ilpy/"
files: "^src/"
additional_dependencies:
- gurobipy
9 changes: 1 addition & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@ ilpy welcomes contributions

## Local development

ilpy links against SCIP, so you must have SCIP installed in your environment.
(You can install via conda)

```bash
conda install scip
```

Then clone the repo and install in editable mode.
Clone the repo and install in editable mode.

```bash
git clone <your-fork>
Expand Down
11 changes: 0 additions & 11 deletions MANIFEST.in

This file was deleted.

22 changes: 0 additions & 22 deletions Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = "ilpy"
copyright = "2023, Jan Funke, Talley Lambert"
copyright = "2023, Jan Funke, Talley Lambert" # noqa
author = "Jan Funke, Talley Lambert"

# -- General configuration ---------------------------------------------------
Expand Down
Loading
Loading