From fb379958b17291b8119d69238eab158264ff1ca9 Mon Sep 17 00:00:00 2001 From: David Irvine Date: Fri, 29 Nov 2024 23:22:57 +0000 Subject: [PATCH] fix: use virtual environment for Alpine Linux tests - Added virtual environment creation in Alpine containers - Fixed externally managed environment errors - Updated pip installation steps - Added python3-dev package for venv support - Fixed pytest module not found error This fixes the externally managed environment error in Alpine Linux by using a virtual environment for package installation and testing. --- .github/workflows/python-publish.yml | 12 ++++++++---- Cargo.toml | 2 +- pyproject.toml | 2 +- src/python.rs | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 0f7242066..0a19b62ed 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -226,11 +226,15 @@ jobs: distro: alpine_latest githubToken: ${{ github.token }} install: | - apk add py3-pip - pip3 install -U pip pytest click>=8.0.0 + apk add py3-pip python3 python3-dev run: | - pip3 install --find-links dist/ ${{ env.PACKAGE_NAME }} - python3 -m pytest + # Create and activate a virtual environment + python3 -m venv /venv + . /venv/bin/activate + # Install dependencies in the virtual environment + pip install -U pip pytest click>=8.0.0 + pip install --find-links dist/ ${{ env.PACKAGE_NAME }} --force-reinstall + pytest -v - name: Upload wheels uses: actions/upload-artifact@v4 with: diff --git a/Cargo.toml b/Cargo.toml index 2d504090b..b5557513a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ num_cpus = "1.13.0" itertools = "~0.10.0" tempfile = "3.6.0" xor_name = "5.0.0" -pyo3 = { version = "0.20.3", features = ["extension-module", "abi3-py38"], optional = true } +pyo3 = { version = "0.20.3", features = ["extension-module", "abi3-py38", "multiple-pymethods"], optional = true } [dependencies.brotli] version = "~3.3.0" diff --git a/pyproject.toml b/pyproject.toml index 536caf951..fea5231b6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ python-packages = ["self_encryption"] include = ["self_encryption/**/*"] manifest-path = "Cargo.toml" abi3 = true -python-source = "python" +python-source = "." [project.scripts] self-encryption = "self_encryption.cli:cli" diff --git a/src/python.rs b/src/python.rs index 950a514f2..625611c95 100644 --- a/src/python.rs +++ b/src/python.rs @@ -13,7 +13,7 @@ pub struct PyDataMap { pub(crate) inner: crate::DataMap } -#[pyclass] +#[pymethods] impl PyDataMap { #[new] pub fn new() -> Self { @@ -40,7 +40,7 @@ pub struct PyXorName { pub(crate) inner: crate::XorName } -#[pyclass] +#[pymethods] impl PyXorName { #[new] pub fn new(bytes: &[u8]) -> PyResult {