Skip to content

Commit 882eebf

Browse files
authored
UV (#208)
1 parent d915eb6 commit 882eebf

File tree

9 files changed

+213
-114
lines changed

9 files changed

+213
-114
lines changed

.github/workflows/CI.yml

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,13 @@ jobs:
1616
python-version: ['3.9', '3.10', '3.11']
1717
steps:
1818
- uses: actions/checkout@v4
19-
- uses: actions/setup-python@v4
19+
- name: Set up uv
20+
run: curl -LsSf https://astral.sh/uv/0.3.2/install.sh | sh
21+
- uses: actions/setup-python@v5
2022
with:
2123
python-version: ${{ matrix.python-version }}
22-
- name: Update pip and poetry
23-
run: |
24-
python -m pip install --upgrade pip
25-
pip install poetry
26-
- name: Cache Python dependencies
27-
uses: actions/cache@v3
28-
id: cache-python
29-
with:
30-
path: ~/.cache/pypoetry
31-
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}
32-
- name: Install Python dependencies
33-
if: steps.cache-python.outputs.cache-hit != 'true'
34-
run: poetry install --all-extras
24+
- name: Install the project
25+
run: uv sync --all-extras --dev
3526
- name: Cache pre-commit
3627
uses: actions/cache@v3
3728
id: cache-pre-commit
@@ -40,11 +31,12 @@ jobs:
4031
key: pre-commit-${{ env.pythonLocation }}-${{ hashFiles('.pre-commit-config.yaml') }}
4132
- name: Install pre-commit
4233
if: steps.cache-pre-commit.outputs.cache-hit != 'true'
43-
run: poetry run pre-commit install --install-hooks
34+
run: uv run pre-commit install --install-hooks
4435
- name: Run pre-commit
45-
run: poetry run pre-commit run --all-files
36+
run: uv run pre-commit run --all-files
4637
- name: Run tests
47-
run: poetry run pytest --solvers ortools cpoptimizer
38+
run: |
39+
uv run pytest --solvers ortools cpoptimizer
4840
- name: Upload coverage reports to Codecov
4941
uses: codecov/codecov-action@v3
5042
env:

.github/workflows/publish.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [ created ]
6+
push:
7+
branches: [ main ]
8+
9+
10+
jobs:
11+
build:
12+
name: Build distribution 📦
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.11"
21+
- name: Install pypa/build
22+
run: >-
23+
python3 -m
24+
pip install
25+
build
26+
--user
27+
- name: Build a binary wheel and a source tarball
28+
run: python3 -m build
29+
- name: Store the distribution packages
30+
uses: actions/upload-artifact@v3
31+
with:
32+
name: python-package-distributions
33+
path: dist/
34+
35+
publish-to-pypi:
36+
name: >-
37+
Publish Python 🐍 distribution 📦 to PyPI
38+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
39+
needs:
40+
- build
41+
runs-on: ubuntu-latest
42+
environment:
43+
name: pypi
44+
url: https://pypi.org/p/pyjobshop
45+
permissions:
46+
id-token: write # IMPORTANT: mandatory for trusted publishing
47+
48+
steps:
49+
- name: Download all the dists
50+
uses: actions/download-artifact@v3
51+
with:
52+
name: python-package-distributions
53+
path: dist/
54+
- name: Publish distribution 📦 to PyPI
55+
uses: pypa/gh-action-pypi-publish@release/v1
56+
57+
github-release:
58+
name: >-
59+
Sign the Python 🐍 distribution 📦 with Sigstore
60+
and upload them to GitHub Release
61+
needs:
62+
- publish-to-pypi
63+
runs-on: ubuntu-latest
64+
65+
permissions:
66+
contents: write # IMPORTANT: mandatory for making GitHub Releases
67+
id-token: write # IMPORTANT: mandatory for sigstore
68+
69+
steps:
70+
- name: Download all the dists
71+
uses: actions/download-artifact@v3
72+
with:
73+
name: python-package-distributions
74+
path: dist/
75+
- name: Sign the dists with Sigstore
76+
uses: sigstore/gh-action-sigstore-python@v2.1.1
77+
with:
78+
inputs: >-
79+
./dist/*.tar.gz
80+
./dist/*.whl
81+
- name: Create GitHub Release
82+
env:
83+
GITHUB_TOKEN: ${{ github.token }}
84+
run: >-
85+
gh release create
86+
'${{ github.ref_name }}'
87+
--repo '${{ github.repository }}'
88+
--notes ""
89+
- name: Upload artifact signatures to GitHub Release
90+
env:
91+
GITHUB_TOKEN: ${{ github.token }}
92+
# Upload to GitHub Release using the `gh` CLI.
93+
# `dist/` contains the built packages, and the
94+
# sigstore-produced signatures and certificates.
95+
run: >-
96+
gh release upload
97+
'${{ github.ref_name }}' dist/**
98+
--repo '${{ github.repository }}'

.readthedocs.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
version: 2
22

33
build:
4-
os: ubuntu-22.04
4+
os: "ubuntu-22.04"
55
tools:
66
python: "3.10"
7-
jobs:
8-
post_create_environment:
9-
- pip install poetry
10-
- poetry config virtualenvs.create false
11-
post_install:
12-
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH python -m poetry install --with docs,examples --all-extras
7+
commands:
8+
- asdf plugin add uv
9+
- asdf install uv latest
10+
- asdf global uv latest
11+
- uv sync --all-extras --dev
12+
- .venv/bin/python -m sphinx -T -b html -d docs/_build/doctrees -D language=en docs/source $READTHEDOCS_OUTPUT/html
1313
sphinx:
1414
configuration: docs/source/conf.py

README.md

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,7 @@ The documentation is available [here](https://pyjobshop.readthedocs.io/).
3030
3131
## Constraint programming solvers
3232
PyJobShop uses [OR-Tools'](https://github.com/google/or-tools) CP-SAT solver as its default constraint programming solver.
33-
CP-SAT is an open-source constraint programming solver and encompasses other technologies such as satisfiability and mixed-integer linear programming solvers.
34-
CP-SAT has consistently won the annual [MiniZinc Challenge](https://www.minizinc.org/challenge/), demonstrating its superior performance on constraint programming models.
35-
36-
Besides OR-Tools' CP-SAT solver, PyJobShop also implements the IBM ILOG CP Optimizer, which is a commercial constraint programming solver.
37-
To try out CP Optimizer, you can install PyJobShop with the optional `cpoptimizer` dependency as follows:
38-
39-
``` shell
40-
pip install pyjobshop[cpoptimizer]
41-
```
42-
43-
This installation comes with the free community edition of CP Optimizer, which only solves models with up to 1000 variables and 1000 constraints.
44-
Models beyond that size require the paid version or academic version. See [our documentation](https://pyjobshop.readthedocs.io/en/stable/setup/installation.html) for instructions on how to obtain the academic version of CP Optimizer.
33+
We also support CP Optimizer - see [our documentation](https://pyjobshop.readthedocs.io/en/stable/setup/installation.html) for instructions on how to install PyJobShop with CP Optimizer.
4534

4635
## Examples
4736
We provide example notebooks that show how PyJobShop may be used to solve scheduling problems.

docs/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
This directory hosts the documentation.
44
We use Sphinx for this.
5-
If you want to build the documentation, you need to install a few unique dependencies that are listed in the optional `docs` and `examples` groups in the top-level `pyproject.toml`.
6-
You can install those groups using `poetry install --with docs,examples`.
5+
If you want to build the documentation, you need to install a few unique dependencies that are listed in the development dependencies group in the top-level `pyproject.toml`.
6+
You can install those dependencies using `uv sync --dev`.
77

88
The Makefile in this directory can be used to build the documentation.
9-
Running the command `poetry run make help` from this directory provides an overview of the available options.
10-
In particular `poetry run make html` is useful, as that will build the documentation in the exact same way as it will be displayed on the website later.
9+
10+
Running the command `uv run make help` from this directory provides an overview of the available options.
11+
In particular `uv run make html` is useful, as that will build the documentation in the exact same way as it will be displayed on the website later.
1112

1213
> Alternatively, one can run `poetry run make html --directory=docs` from the project root as well.
1314

docs/source/api/pyjobshop.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ PyJobShop
3636

3737
.. autoclass:: TaskData
3838

39-
.. automodule:: pyjobshop.Results
39+
.. automodule:: pyjobshop.Result
4040

4141
.. autoclass:: Result
4242

docs/source/setup/installation.rst

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,52 @@ To install it, simply run:
88
pip install pyjobshop
99
1010
11-
Installing from source
11+
Installing from source
1212
----------------------
1313
To install the latest version of ``pyjobshop`` directly from the GitHub repository, run the following:
1414

1515
.. code-block:: shell
1616
17-
pip install 'pyjobshop @ git+https://github.com/PyJobShop/PyJobShop
17+
pip install 'pyjobshop @ git+https://github.com/PyJobShop/PyJobShop'
1818
1919
This can be useful to get features that have not yet made it to the Python package index.
2020

2121

2222
Installing CP Optimizer
2323
-----------------------
24-
By default, PyJobShop comes with OR-Tools' CP-SAT solver, which is an open-source constraint programming solver.
25-
PyJobShop also implements the IBM ILOG CP Optimizer, which is a commercial constraint programming solver.
26-
To use PyJobShop with CP Optimizer, you can install PyJobShop with the optional `cpoptimizer` dependency as follows:
24+
PyJobShop includes OR-Tools' CP-SAT solver by default, an open-source constraint programming solver.
25+
Additionally, PyJobShop can be integrated with IBM ILOG CP Optimizer, a commercial constraint programming solver.
2726

28-
.. code-block:: shell
27+
.. note::
28+
29+
CP Optimizer only works with Python versions 3.9, 3.10, and 3.11.
30+
31+
To use PyJobShop with CP Optimizer, follow one of the following two steps based on whether you already have CP Optimizer installed:
32+
33+
1. **If you already have CP Optimizer installed:**
34+
35+
Install the additional ``docplex`` dependency together with PyJobShop as follows:
36+
37+
.. code-block:: shell
38+
39+
pip install pyjobshop[docplex]
40+
41+
42+
``docplex`` is the Python modeling interface for CPLEX and CP Optimizer. It allows users to model constraint programming problems in Python. It looks for a local installation of CP Optimizer to solve these models.
43+
44+
2. **If you don't have CP Optimizer installed:**
45+
46+
You can install PyJobShop with the free community edition of CP Optimizer by including the ``cplex`` dependency.
47+
48+
.. code-block:: shell
2949
30-
pip install pyjobshop[cpoptimizer]
50+
pip install pyjobshop[docplex,cplex]
3151
32-
This installation comes with the free community edition of CP Optimizer, which solves models with up to 1000 variables and 1000 constraints.
33-
Models beyond that size require a paid version or academic version of CP Optimizer.
52+
The ``cplex`` library installs a free edition of CP Optimizer that is capable of solving models with up to 1000 variables and 1000 constraints. For larger models, you need a paid or academic version of CP Optimizer.
3453

35-
If you are a student or researcher, you can get a free academic version of CP Optimizer for non-commercial purposes.
36-
The steps below describe how you can install CP Optimizer through their academic program.
54+
If you are a student or researcher, you can get a free academic version of CP Optimizer for non-commercial purposes by following these steps:
3755

38-
- Register at [ibm.com/academic](https://ibm.com/academic) and log in.
39-
- Go to [academic.ibm.com/a2mt/downloads/data_science](https://academic.ibm.com/a2mt/downloads/data_science) and download ILOG CPLEX Optimization Studio, which comes with CP Optimizer.
40-
- Follow the installation instructions and make sure to follow the Python installation instructions at the end.
41-
- Ensure that the path to `cpoptimizer(.exe)` is accessible and properly set in your system path.
56+
- Register at `ibm.com/academic <https://ibm.com/academic>`_ and log in.
57+
- Go to `academic.ibm.com/a2mt/downloads/data_science <https://academic.ibm.com/a2mt/downloads/data_science>`_ and download ILOG CPLEX Optimization Studio, which includes CP Optimizer.
58+
- Follow the installation instructions, making sure to complete the Python installation steps at the end.
59+
- Ensure that the path to ``cpoptimizer(.exe)`` is accessible and properly set in your system path.

0 commit comments

Comments
 (0)