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

Separate security scanned lockfile #159

Merged
merged 36 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
bde3f95
Add tox env to compile lockfile
miikkako Dec 18, 2024
32ae34a
Compile first lockfile
miikkako Dec 18, 2024
c3ea0b6
Update readme
miikkako Dec 18, 2024
c2f8006
Add ci job to verify the lockfile is up to date
miikkako Dec 18, 2024
a94bbdd
Use '--generate-hashes'
miikkako Dec 18, 2024
1b60b60
Use pyproject.toml file with all extras for separate lockfile
miikkako Jan 7, 2025
ee4a524
Rename scanned lockfile
miikkako Jan 7, 2025
471a185
Add note to readme about requirements.txt
miikkako Jan 7, 2025
a9a5464
Adjust lockfile ci test
miikkako Jan 8, 2025
d996a18
Transform tox.ini envs into simple files with commands
miikkako Jan 9, 2025
15e372a
Remove tox from deps
miikkako Jan 9, 2025
6b5fc01
Print useful notes in script
miikkako Jan 9, 2025
539617a
Remove tox.ini
miikkako Jan 9, 2025
db23442
Update github ci
miikkako Jan 9, 2025
9d5d4c6
Lock build deps
miikkako Jan 9, 2025
93b686f
Add missing cicd to script
miikkako Jan 9, 2025
16a7b33
Update lockfile
miikkako Jan 9, 2025
9604fa6
Include duplicated build-system reqs in pyproject file
miikkako Jan 10, 2025
0b3e185
Fix error msg in update-requirements script
miikkako Jan 10, 2025
e5309f3
Have proper ranges for all requirements
miikkako Jan 10, 2025
8eb9001
Invoke test and format commands via default interpreter
miikkako Jan 10, 2025
a541243
Use explicit python platform for lockfile
miikkako Jan 10, 2025
f9fdfb7
Use cicd deps correctly in ci
miikkako Jan 10, 2025
a97b887
Define uv system python by a default env var instead of cli flag
miikkako Jan 10, 2025
2adeaa1
debug uv in 'test' ci job
miikkako Jan 10, 2025
106c727
Don't use system python with uv as 'astral-sh/setup-uv@v5' sets uv ve…
miikkako Jan 10, 2025
0d0ad6f
Fix yaml syntax
miikkako Jan 10, 2025
b2e0e11
Remove debug commands from 'test' ci job
miikkako Jan 10, 2025
187b94e
Remove build deps locking workaround
miikkako Jan 10, 2025
c9ef782
Fix typo in ci job deps install command
miikkako Jan 10, 2025
c994c0b
Do not run python 3.9 in ci
miikkako Jan 10, 2025
c9e7578
Update lockfile
miikkako Jan 10, 2025
4d48cf6
Add changelog for dropping python3.9
miikkako Jan 10, 2025
a43907b
Drop python 3.9 in pyproject.toml too
miikkako Jan 10, 2025
622cb56
Update README accordingly
miikkako Jan 10, 2025
ad9f839
Apply suggestions from code review
miikkako Jan 13, 2025
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
42 changes: 26 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,47 @@ on:
jobs:
test:
runs-on: ${{ matrix.platform }}

strategy:
matrix:
platform: [ ubuntu-latest, macos-latest, windows-latest ]
python-version: [ '3.9', '3.10', '3.11', '3.12' ]

python-version: [ "3.10", "3.11", "3.12" ]
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"
python -m pip install tox-gh-actions==2.12.0
run: uv pip install --constraint requirements.txt --editable .[cicd,testing]
- name: Run tests
run: tox
run: ./test

test_docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v5
with:
python-version: '3.12'
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e ".[dev, docs]"
uv pip install --constraint requirements.txt --editable .[cicd,docs]
sudo apt-get install graphviz
- name: Test if docs can be built
run: tox -e docs
run: ./docbuild

test_requirements_lock:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v5
with:
python-version: "3.12"
- name: Install dependencies
run: uv pip install --constraint requirements.txt --editable .[cicd]
- name: Regenerate requirements.txt
run: python update-requirements.py
- name: Check lockfile is up-to-date
run: git diff --exit-code HEAD requirements.txt
38 changes: 14 additions & 24 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,18 @@ on:
jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Fetch all history for all tags and branches
run: git fetch --prune --unshallow
- name: Setup Python
uses: actions/setup-python@v5
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v5
with:
python-version: '3.12'
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build==1.0.3
run: uv pip install --constraint requirements.txt --editable .[cicd]
- name: Build distribution
run: python -m build
run: uv build --no-build-isolation
- name: Store distribution packages
uses: actions/upload-artifact@v4
with:
Expand All @@ -39,7 +36,6 @@ jobs:
url: https://pypi.org/p/iqm-client
permissions:
id-token: write

steps:
- name: Download distribution packages
uses: actions/download-artifact@v4
Expand All @@ -50,26 +46,24 @@ jobs:

publish_docs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v5
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v5
with:
python-version: '3.12'
python-version: "3.12"
- name: Checkout latest tagged commit
run: |
git checkout $(git describe --tags --abbrev=0)
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
uv pip install --constraint requirements.txt --editable .[cicd,docs]
sudo apt-get install graphviz
- name: Build docs
run: |
tox -e docs
./docbuild
touch build/sphinx/html/.nojekyll # allow underscores in URL path
# remove unnecessary build files
sudo rm -rf build/sphinx/html/.doctrees
Expand All @@ -82,20 +76,16 @@ jobs:

gen_licenses_info:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v5
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v5
with:
python-version: '3.12'
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
pip install pip-licenses
run: uv pip install --constraint requirements.txt --editable .[cicd]
- name: Generate license information for dependencies
run: |
pip-licenses --format=confluence --with-urls > licenses.txt
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
Changelog
=========

Version 20.12
=============

* Drop support for Python 3.9. `#159 <https://github.com/iqm-finland/iqm-client/pull/159>`_
* Add optional security-scanned lockfile. `#159 <https://github.com/iqm-finland/iqm-client/pull/159>`_

Version 20.11
=============

Expand Down
50 changes: 43 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,70 @@ Installation
IQM client is not intended to be used directly by human users. For executing code on an IQM quantum computer,
you can use for example the `Qiskit on IQM <https://iqm-finland.github.io/qiskit-on-iqm/>`_ library.

If you want just this library, though, you can install it from the Python Package Index (PyPI):
If you want just this library, though, you can install it from the Python Package Index (PyPI), e.g.:

.. code-block:: bash

$ pip install iqm-client
$ uv pip install iqm-client

.. note::

`uv <https://docs.astral.sh/uv/>`_ is highly recommended for practical Python environment and package management.

Supplied within the Python package there is an additional `requirements.txt` file containing locked, security scanned
dependencies. The file can be used to constrain installed dependencies either directly from the repo or by
extracting it from the PyPI package.

.. code-block:: bash

$ uv pip install --constraint requirements.txt iqm-client

Contributing
============

Format your code:

.. code-block:: bash

$ ./format

Run the tests:

.. code-block:: bash

$ ./test

Update the requirements. This is necessary when you add a new dependency or update an existing one in `pyproject.toml`.
After this, any changes in the lockfile `requirements.txt` have to be committed.
The script upgrades locked dependencies defined in `pyproject.toml` within the given version ranges. However, transitive
dependencies are deliberately not upgraded automatically.

.. code-block:: bash

$ python update-requirements.py

Documentation
=============

Documentation for the latest version is `available online <https://iqm-finland.github.io/iqm-client/>`_.
You can build documentation for any older version locally by cloning the Git repository, checking out the
corresponding tag, and running the docs builder. For example, to build the documentation for version ``15.4``:
corresponding tag, and running the docs builder. For example, to build the documentation for version ``20.12``:

.. code-block:: bash

$ git clone git@github.com:iqm-finland/iqm-client.git
$ cd iqm-client
$ git checkout 15.4
$ tox run -e docs
$ git checkout 20.12
$ ./docbuild

(Unless you need to build documentation for multiple versions, consider passing ``git clone`` options to
only clone the commit for the specific version tag, e.g. ``--branch 15.4 --depth 1`` for version ``15.4``.
This will be much faster than cloning the full repository, because some large files have been stored
in the commit history.)

``tox run -e docs`` will build the documentation at ``./build/sphinx/html``. This command requires the ``tox,``, ``sphinx`` and
``./docbuild`` will build the documentation at ``./build/sphinx/html``. This command requires the ``sphinx`` and
``sphinx-book-theme`` Python packages (see the ``docs`` optional dependency in ``pyproject.toml``);
you can install the necessary packages with ``pip install -e ".[dev,docs]"``
you can install the necessary packages with e.g. ``uv pip install -e ".[dev,docs]"``

Copyright
=========
Expand Down
1 change: 1 addition & 0 deletions docbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sphinx-build -b html docs/ build/sphinx/html -W
2 changes: 2 additions & 0 deletions format
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
python -m black src tests
python -m isort src tests
24 changes: 15 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
[build-system]
requires = ["setuptools>=65.4.1", "setuptools_scm[toml]>=7"]
requires = [
# NOTE: including build deps in the lockfile not yet directly by uv. Working around this by duplicating build deps
# in project dependencies doesn't work either since using them via the lockfile requires
# `--no-build-isolation` while installing, which itself requires setuptools.
# See https://github.com/astral-sh/uv/issues/5190.
"setuptools>=65.4.1",
"setuptools_scm[toml]>=7",
]
build-backend = "setuptools.build_meta"

[project]
Expand All @@ -16,10 +23,10 @@ classifiers = [
"Intended Audience :: Science/Research",
"License :: OSI Approved :: Apache Software License",
]
requires-python = ">=3.9, <3.13"
requires-python = ">=3.10, <3.13"
dependencies = [
"numpy",
"packaging",
"numpy >= 2.2.1, < 3.0",
"packaging >= 24.2, < 25.0",
"requests >= 2.28.2, < 3.0",
"pydantic >= 2.4.2, < 3.0",
]
Expand All @@ -29,11 +36,6 @@ Homepage = "https://github.com/iqm-finland/iqm-client"
Documentation = "https://iqm-finland.github.io/iqm-client"

[project.optional-dependencies]
# Add here additional requirements for extra features, to install with:
# `pip install iqm-client[dev]`
dev = [
"tox == 4.11.3",
]
testing = [
"black == 23.11.0",
"isort == 5.12.0",
Expand All @@ -53,6 +55,10 @@ docs = [
"sphinx == 7.2.6",
"sphinx-book-theme == 1.1.2",
]
cicd = [
"build == 1.0.3",
"pip-licenses == 5.0.0",
]


[tool.setuptools_scm]
Expand Down
Loading
Loading