From ff7879417231718cb529cf0713e36014269e87e9 Mon Sep 17 00:00:00 2001 From: Thomas BAUDIER Date: Tue, 23 Jun 2026 09:04:57 +0200 Subject: [PATCH 1/4] update readme --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 31d330e..b553f2f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # JDEV 2026 Python Workshop -This project is a **Python workshop** designed to teach students how to create and publish a Python package on PyPI. The package is an educational demo of RSA encryption and breaking. +This project is a **Python workshop** designed to teach students how to create and publish a Python package on PyPI. The package is an educational demo of RSA encryption and breaking. + +We will use venv and setuptools, the standard and universal tools integrated in Python to learn the basics. Later you can use your favorite tools (poetry, uv, pixi, etc.) to create your own package. In the same way, you can use your favorite tools (Gitlab, Github, etc.) to automatize the build and publish process, and PyPI or your own repository to publish your package. The only need you have to know is a little bit of Python and Git and a working Github account. The rest will be explained in the workshop. # RSA Encryption & Breaking Demo (Educational) From cc9c6a5fe5f4c90ae8b8588e52de95843bb442d2 Mon Sep 17 00:00:00 2001 From: Thomas BAUDIER Date: Wed, 3 Jun 2026 09:48:23 +0200 Subject: [PATCH 2/4] Add starting point files for the workshop --- .github/workflows/create_wheel.yml | 58 +++++++++++++++++++++++++++++ .gitlab-ci.yml | 59 ++++++++++++++++++++++++++++++ decrypt_rsa.py | 2 +- pyproject.toml | 23 ++++++++++++ 4 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/create_wheel.yml create mode 100644 .gitlab-ci.yml create mode 100644 pyproject.toml diff --git a/.github/workflows/create_wheel.yml b/.github/workflows/create_wheel.yml new file mode 100644 index 0000000..376e48e --- /dev/null +++ b/.github/workflows/create_wheel.yml @@ -0,0 +1,58 @@ + +name: Publish package + +on: + push: + branches: [ master, working_example ] + tags: + - '*' + pull_request: + branches: + - '*' + + +jobs: + build-wheel: + runs-on: ubuntu-latest + + steps: + - name: Clone github repository + uses: actions/checkout@v6 + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: "3.14" + + # - run: pip install build + # - run: python -m build + + - name: Upload wheels to GH artifacts + uses: actions/upload-artifact@v7 + with: + name: wheel + path: dist/ + + upload-wheel: + runs-on: ubuntu-latest + needs: [build-wheel] + + steps: + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: "3.14" + + - uses: actions/download-artifact@v8 + with: + pattern: wheel* + path: dist/ + + # - name: Publish to test PyPI + # if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/') + # uses: pypa/gh-action-pypi-publish@release/v1 + # with: + # user: __token__ + # password: ${{ secrets.TEST_PYPI_API_TOKEN }} + # packages-dir: dist/ + # skip-existing: true + # repository-url: https://test.pypi.org/legacy/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..dab9c04 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,59 @@ + +stages: + - build + - publish + +variables: + PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" + +# ------------------------ +# BUILD WHEEL +# ------------------------ +build-wheel: + stage: build + image: python:3.14 + + rules: + - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' + - if: '$CI_COMMIT_BRANCH =~ /^(master|workshop_starting_point|working_example)$/' + - if: '$CI_COMMIT_TAG' + + before_script: + - python --version + - pip install --upgrade pip + - pip install build + + script: + - python -m build + + artifacts: + name: wheel + paths: + - dist/ + expire_in: 1 week + + cache: + paths: + - .cache/pip + + +# ------------------------ +# PUBLISH TO TEST PYPI +# ------------------------ +upload-wheel: + stage: publish + image: python:3.14 + needs: ["build-wheel"] + + rules: + # Only run on tag pushes + - if: '$CI_COMMIT_TAG' + + before_script: + - python --version + - pip install --upgrade pip + - pip install twine + + script: + - twine upload dist/* --repository-url https://test.pypi.org/legacy/ -u __token__ -p "$TEST_PYPI_API_TOKEN" --skip-existing + diff --git a/decrypt_rsa.py b/decrypt_rsa.py index 5fd1a52..c345ca3 100644 --- a/decrypt_rsa.py +++ b/decrypt_rsa.py @@ -1,6 +1,6 @@ import numpy as np -from helpers import ( +from .helpers import ( break_rsa_with_primes, display_gui, rsa_decrypt, diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..d1c4d89 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,23 @@ + +[project] +name = "jdev2026-python-wheel-XXXXXX" +version = "0.0.1" +description = "Demo package" +authors = [{name="Thomas"}] +readme = "README.md" +requires-python = ">=3.10" + +dependencies = [ + "XXXXXXX", +] + +[build-system] +requires = ["setuptools>=61.0", "wheel"] +build-backend = "setuptools.build_meta" + + +# [tool.setuptools.package-data] +# "jdev2026_python_wheel_XXXXXX" = ["data/*.npz"] + +# [project.scripts] +# decrypt-tool = "jdev2026_python_wheel_XXXXXX.decrypt_rsa:run_decrypt_rsa" From e8893d9e5fccacc21b2fa6925d6794eaebdab4ba Mon Sep 17 00:00:00 2001 From: Thomas BAUDIER Date: Mon, 18 May 2026 17:33:49 +0200 Subject: [PATCH 3/4] Create the folder jdev2026_python_wheel_thomas_baudier containing the code to create the wheel Add .github folder containg the automatization of the creation of the wheel --- .github/workflows/create_wheel.yml | 22 +++++++++--------- MANIFEST.in | 3 +++ .../__init__.py | 0 .../data/__init__.py | 0 .../data/primes.npz | Bin .../decrypt_rsa.py | 5 +++- .../helpers.py | 0 pyproject.toml | 15 ++++++------ 8 files changed, 25 insertions(+), 20 deletions(-) create mode 100644 MANIFEST.in create mode 100644 jdev2026_python_wheel_thomas_baudier/__init__.py create mode 100644 jdev2026_python_wheel_thomas_baudier/data/__init__.py rename primes.npz => jdev2026_python_wheel_thomas_baudier/data/primes.npz (100%) rename decrypt_rsa.py => jdev2026_python_wheel_thomas_baudier/decrypt_rsa.py (86%) rename helpers.py => jdev2026_python_wheel_thomas_baudier/helpers.py (100%) diff --git a/.github/workflows/create_wheel.yml b/.github/workflows/create_wheel.yml index 376e48e..89da9bc 100644 --- a/.github/workflows/create_wheel.yml +++ b/.github/workflows/create_wheel.yml @@ -23,8 +23,8 @@ jobs: with: python-version: "3.14" - # - run: pip install build - # - run: python -m build + - run: pip install build + - run: python -m build - name: Upload wheels to GH artifacts uses: actions/upload-artifact@v7 @@ -47,12 +47,12 @@ jobs: pattern: wheel* path: dist/ - # - name: Publish to test PyPI - # if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/') - # uses: pypa/gh-action-pypi-publish@release/v1 - # with: - # user: __token__ - # password: ${{ secrets.TEST_PYPI_API_TOKEN }} - # packages-dir: dist/ - # skip-existing: true - # repository-url: https://test.pypi.org/legacy/ + - name: Publish to test PyPI + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/') + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + packages-dir: dist/ + skip-existing: true + repository-url: https://test.pypi.org/legacy/ diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..0e4d1b1 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,3 @@ +include LICENSE +include README.md +include jdev2026_python_wheel_thomas_baudier/data/*.npz diff --git a/jdev2026_python_wheel_thomas_baudier/__init__.py b/jdev2026_python_wheel_thomas_baudier/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/jdev2026_python_wheel_thomas_baudier/data/__init__.py b/jdev2026_python_wheel_thomas_baudier/data/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/primes.npz b/jdev2026_python_wheel_thomas_baudier/data/primes.npz similarity index 100% rename from primes.npz rename to jdev2026_python_wheel_thomas_baudier/data/primes.npz diff --git a/decrypt_rsa.py b/jdev2026_python_wheel_thomas_baudier/decrypt_rsa.py similarity index 86% rename from decrypt_rsa.py rename to jdev2026_python_wheel_thomas_baudier/decrypt_rsa.py index c345ca3..76fc936 100644 --- a/decrypt_rsa.py +++ b/jdev2026_python_wheel_thomas_baudier/decrypt_rsa.py @@ -1,3 +1,5 @@ +from importlib.resources import files + import numpy as np from .helpers import ( @@ -31,7 +33,8 @@ def run_decrypt_rsa(): show_text_gui(str(c), title="Encrypted message", label="Encrypted message:") # Load the list of primes and break RSA to find d - primes = np.load("primes.npz").tolist() + data_path = files("jdev2026_python_wheel_thomas_baudier.data") / "primes.npz" + primes = np.load(data_path).tolist() d = break_rsa_with_primes(n, e, primes) # Decrypting the message diff --git a/helpers.py b/jdev2026_python_wheel_thomas_baudier/helpers.py similarity index 100% rename from helpers.py rename to jdev2026_python_wheel_thomas_baudier/helpers.py diff --git a/pyproject.toml b/pyproject.toml index d1c4d89..9bff37e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,23 +1,22 @@ [project] -name = "jdev2026-python-wheel-XXXXXX" -version = "0.0.1" +name = "jdev2026-python-wheel-thomas-baudier" +version = "0.1.0" description = "Demo package" authors = [{name="Thomas"}] readme = "README.md" requires-python = ">=3.10" dependencies = [ - "XXXXXXX", + "numpy", ] [build-system] requires = ["setuptools>=61.0", "wheel"] build-backend = "setuptools.build_meta" +[tool.setuptools.package-data] +"jdev2026_python_wheel_thomas_baudier" = ["data/*.npz"] -# [tool.setuptools.package-data] -# "jdev2026_python_wheel_XXXXXX" = ["data/*.npz"] - -# [project.scripts] -# decrypt-tool = "jdev2026_python_wheel_XXXXXX.decrypt_rsa:run_decrypt_rsa" +[project.scripts] +decrypt-tool = "jdev2026_python_wheel_thomas_baudier.decrypt_rsa:run_decrypt_rsa" From 3fe49351f27a0e474ed8273790567e78554926fa Mon Sep 17 00:00:00 2001 From: Thomas BAUDIER Date: Tue, 26 May 2026 17:08:49 +0200 Subject: [PATCH 4/4] version 0.1.1 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9bff37e..e65f66b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "jdev2026-python-wheel-thomas-baudier" -version = "0.1.0" +version = "0.1.1" description = "Demo package" authors = [{name="Thomas"}] readme = "README.md"