Skip to content

Commit bee2d41

Browse files
authored
Syw UID2 6085 improve python dependency (#66)
1. Python Version & Dependency Updates Minimum Python Version Raised: The required Python version was updated from >=3.6 to >=3.10. This change was necessary because the code uses importlib.metadata, which was introduced in Python 3.8, fixing import errors on older versions. Version Support Modified: Classifiers were updated to remove support for end-of-life Python 3.6-3.9, while explicitly adding support for Python 3.10+ Dependency Constraint Relaxed: The version constraint for setuptools was relaxed from a fixed version (== 68.2.2) to a broader range (< 81), increasing flexibility while maintaining compatibility. 2. Modernizing Package Configuration Removed Legacy Files: The legacy Python packaging files, setup.py and setup.cfg, were removed. Adopted pyproject.toml: The pyproject.toml file was updated to configure proper package discovery, marking a shift to a modern Python packaging standard. Build Fixes: Fixed a Docker build error caused by multiple top-level packages and updated Dockerfile.dev to use a Python 3.10 base image. Excluded Directories: Directories like node_modules, tests, examples, and venv are now explicitly excluded from package discovery. 3. CI and Testing Enhancements Unit Tests Added to CI: A new unit-tests job was added to the Continuous Integration workflow (build-and-test.yaml). Pre-Publish Test Gate: A dependency was added to the build-and-publish workflow to ensure unit tests pass before publishing to PyPI, preventing broken code from being released. Development Dependencies Updated: Development dependencies (e.g., pytest, pytest-cov, unittest-xml-reporting) were added to pyproject.toml. Test Confirmation: The developer confirmed locally that 287 tests pass successfully with these changes.
1 parent d2437be commit bee2d41

File tree

12 files changed

+71
-57
lines changed

12 files changed

+71
-57
lines changed

.github/workflows/build-and-publish.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,32 @@ on:
1919
default: 'CRITICAL,HIGH'
2020

2121
jobs:
22+
unit-tests:
23+
runs-on: ubuntu-latest
24+
strategy:
25+
matrix:
26+
python-version: ["3.10","3.11","3.12","3.13"]
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- name: Set up Python ${{ matrix.python-version }}
32+
uses: actions/setup-python@v4
33+
with:
34+
python-version: ${{ matrix.python-version }}
35+
36+
- name: Install dependencies
37+
run: |
38+
python -m pip install --upgrade pip
39+
pip install -e .[dev]
40+
41+
- name: Run unit tests
42+
run: |
43+
python -m unittest tests/*.py
44+
2245
build-and-pubish:
2346
name: Build and publish Python packages to PyPi
47+
needs: unit-tests
2448
uses: IABTechLab/uid2-shared-actions/.github/workflows/shared-publish-to-pypi-versioned.yaml@v3
2549
with:
2650
release_type: ${{ inputs.release_type }}

.github/workflows/build-and-test.yaml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,31 @@ name: Build and Test
22
on: [pull_request, push, workflow_dispatch]
33

44
jobs:
5-
build:
5+
vulnerability-scan:
66
uses: IABTechLab/uid2-shared-actions/.github/workflows/shared-build-and-test.yaml@v3
77
secrets: inherit
88
with:
99
vulnerability_scan_only: true
10+
11+
unit-tests:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: ["3.10","3.11","3.12","3.13"]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install -e .[dev]
29+
30+
- name: Run unit tests
31+
run: |
32+
python -m unittest tests/*.py

Dockerfile.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
FROM python:3.8
1+
FROM python:3.10
22
COPY . /build
33
RUN pip install --no-cache-dir -e /build[dev]

pyproject.toml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
[build-system]
22
requires = [
3-
"setuptools == 68.2.2",
3+
"setuptools < 81",
44
"wheel",
55
]
66
build-backend = "setuptools.build_meta"
77

8+
[tool.setuptools.packages.find]
9+
include = ["uid2_client*"]
10+
exclude = ["tests*", "examples*"]
11+
812
[project]
913
name = "uid2_client"
1014
version = "2.7.0"
@@ -18,13 +22,19 @@ classifiers = [
1822
"License :: OSI Approved :: MIT License",
1923
"Operating System :: OS Independent",
2024
]
21-
requires-python = ">=3.6"
25+
requires-python = ">=3.8"
2226
dependencies = [
23-
"setuptools",
2427
"pycryptodome",
2528
"bitarray"
2629
]
27-
keywords = ["uid2"]
30+
31+
[project.optional-dependencies]
32+
dev = [
33+
"pytest",
34+
"pytest-cov",
35+
"unittest-xml-reporting"
36+
]
37+
keywords = ["uid2","euid"]
2838
[project.license]
2939
file="LICENSE"
3040
[project.urls]

setup.cfg

Lines changed: 0 additions & 39 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/test_bidstream_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import unittest
33
from unittest.mock import patch
44

5-
from test_utils import *
5+
from .test_utils import *
66
from uid2_client import BidstreamClient, Uid2Base64UrlCoder, DecryptionStatus, Uid2ClientFactory
77
from uid2_client.refresh_response import RefreshResponse
88

tests/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import unittest
22
from unittest.mock import patch
33

4-
from test_utils import *
4+
from .test_utils import *
55
from uid2_client import *
66
from uid2_client.euid_client_factory import EuidClientFactory
77
from uid2_client.refresh_response import RefreshResponse

tests/test_encryption.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import unittest
22

3-
from test_utils import *
3+
from .test_utils import *
44
from uid2_client import *
55

66
_master_secret = bytes([139, 37, 241, 173, 18, 92, 36, 232, 165, 168, 23, 18, 38, 195, 123, 92, 160, 136, 185, 40, 91, 173, 165, 221, 168, 16, 169, 164, 38, 139, 8, 155])

tests/test_refresh_keys_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from unittest.mock import patch, MagicMock
44

55
from uid2_client import refresh_keys_util, Uid2Response
6-
from test_utils import *
6+
from .test_utils import *
77
from uid2_client.encryption import _encrypt_gcm, _decrypt_gcm
88

99

0 commit comments

Comments
 (0)