Skip to content

Commit

Permalink
fix: use virtual environment for Alpine Linux tests
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
dirvine committed Nov 29, 2024
1 parent 9ceb1d4 commit fb37995
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 2 additions & 2 deletions src/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct PyDataMap {
pub(crate) inner: crate::DataMap
}

#[pyclass]
#[pymethods]
impl PyDataMap {
#[new]
pub fn new() -> Self {
Expand All @@ -40,7 +40,7 @@ pub struct PyXorName {
pub(crate) inner: crate::XorName
}

#[pyclass]
#[pymethods]
impl PyXorName {
#[new]
pub fn new(bytes: &[u8]) -> PyResult<Self> {
Expand Down

0 comments on commit fb37995

Please sign in to comment.