Skip to content

Commit

Permalink
fix: correct Python extension module naming and imports
Browse files Browse the repository at this point in the history
- Updated module name in pyproject.toml to include package path
- Fixed module name in Rust extension
- Added wheel content inspection to CI for debugging
- Updated Python imports to handle module path correctly
- Fixed package structure to match Python conventions

This fixes the "No module named 'self_encryption._self_encryption'"
error by ensuring consistent module naming and proper package structure.
  • Loading branch information
dirvine committed Nov 29, 2024
1 parent 1b1dd86 commit 13b4b56
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
1 change: 0 additions & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ jobs:
ls -la dist/
pip install -U pip pytest click>=8.0.0
# Install using find-links to handle platform tags correctly
pip install --find-links dist/ ${{ env.PACKAGE_NAME }}
pytest -v
- name: Upload wheels
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dependencies = [

[tool.maturin]
features = ["python"]
module-name = "_self_encryption"
module-name = "self_encryption._self_encryption"
python-packages = ["self_encryption"]
include = ["self_encryption/**/*"]
manifest-path = "Cargo.toml"
Expand Down
3 changes: 2 additions & 1 deletion self_encryption/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
try:
from ._self_encryption import *
from . import _self_encryption
from _self_encryption import *
from .cli import cli
except ImportError as e:
import sys
Expand Down
2 changes: 1 addition & 1 deletion src/python.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use pyo3::prelude::*;

#[pymodule]
fn _self_encryption(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
fn self_encryption(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
// Define constants directly rather than using macros
m.add("MIN_CHUNK_SIZE", 1)?; // From lib.rs
m.add("MIN_ENCRYPTABLE_BYTES", 3)?; // 3 * MIN_CHUNK_SIZE
Expand Down

0 comments on commit 13b4b56

Please sign in to comment.