From 5f9f284988f6ebc58fad4d3574a172ff258fa10b Mon Sep 17 00:00:00 2001 From: MusicalNinjaDad <102677655+MusicalNinjaDad@users.noreply.github.com> Date: Mon, 13 May 2024 11:10:49 +0200 Subject: [PATCH] Fix python import error (#22) move python packages to dedicated python directory as per https://github.com/PyO3/maturin/pull/855 --- .devcontainer/devcontainer.json | 1 + .github/workflows/deploy-rust.yml | 1 + .github/workflows/python.yml | 2 +- pyproject.toml | 6 +++--- {fizzbuzz => python/fizzbuzz}/__init__.py | 0 {fizzbuzz => python/fizzbuzz}/fizzbuzzo3/__init__.pyi | 0 {fizzbuzz => python/fizzbuzz}/fizzbuzzo3/repl_notes.txt | 0 {fizzbuzz => python/fizzbuzz}/fizzbuzzpy/__init__.py | 0 {fizzbuzz => python/fizzbuzz}/fizzbuzzpy/fizzbuzzer.py | 0 tests/test_fizzbuzzo3.py | 1 - 10 files changed, 6 insertions(+), 5 deletions(-) rename {fizzbuzz => python/fizzbuzz}/__init__.py (100%) rename {fizzbuzz => python/fizzbuzz}/fizzbuzzo3/__init__.pyi (100%) rename {fizzbuzz => python/fizzbuzz}/fizzbuzzo3/repl_notes.txt (100%) rename {fizzbuzz => python/fizzbuzz}/fizzbuzzpy/__init__.py (100%) rename {fizzbuzz => python/fizzbuzz}/fizzbuzzpy/fizzbuzzer.py (100%) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 2056121..db953c1 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,4 +1,5 @@ { + // "image": "ghcr.io/musicalninjas/pyo3-devcontainer:latest", // untested with mac, expect issues due to x_64 rust installation "build": { "dockerfile": "Dockerfile", "args": { diff --git a/.github/workflows/deploy-rust.yml b/.github/workflows/deploy-rust.yml index 43cdcf2..2a1927b 100644 --- a/.github/workflows/deploy-rust.yml +++ b/.github/workflows/deploy-rust.yml @@ -1,3 +1,4 @@ +name: Deploy Rust concurrency: ADO-Cargo on: diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 5cce806..b72e4ee 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -39,7 +39,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install -e .[dev] + python -m pip install -e .[test] python -m pip install pytest-cov - name: Test with pytest run: | diff --git a/pyproject.toml b/pyproject.toml index e77e444..201c712 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,11 +30,11 @@ Issues = "https://github.com/MusicalNinjaDad/fizzbuzz/issues" version = { file = "__pyversion__" } [tool.setuptools.packages.find] -where = ["fizzbuzz"] +where = ["python"] [[tool.setuptools-rust.ext-modules]] # Private Rust extension module to be nested into the Python package -target = "fizzbuzzo3" # The last part of the name (e.g. "_lib") has to match lib.name in Cargo.toml, +target = "fizzbuzz.fizzbuzzo3" # The last part of the name (e.g. "_lib") has to match lib.name in Cargo.toml, # but you can add a prefix to nest it inside of a Python package. path = "fizzbuzzo3/Cargo.toml" binding = "PyO3" @@ -78,7 +78,7 @@ addopts = [ [tool.coverage.run] branch = true -omit = ["test_*"] +omit = ["test_*", "tests/*"] dynamic_context = "test_function" [tool.ruff] diff --git a/fizzbuzz/__init__.py b/python/fizzbuzz/__init__.py similarity index 100% rename from fizzbuzz/__init__.py rename to python/fizzbuzz/__init__.py diff --git a/fizzbuzz/fizzbuzzo3/__init__.pyi b/python/fizzbuzz/fizzbuzzo3/__init__.pyi similarity index 100% rename from fizzbuzz/fizzbuzzo3/__init__.pyi rename to python/fizzbuzz/fizzbuzzo3/__init__.pyi diff --git a/fizzbuzz/fizzbuzzo3/repl_notes.txt b/python/fizzbuzz/fizzbuzzo3/repl_notes.txt similarity index 100% rename from fizzbuzz/fizzbuzzo3/repl_notes.txt rename to python/fizzbuzz/fizzbuzzo3/repl_notes.txt diff --git a/fizzbuzz/fizzbuzzpy/__init__.py b/python/fizzbuzz/fizzbuzzpy/__init__.py similarity index 100% rename from fizzbuzz/fizzbuzzpy/__init__.py rename to python/fizzbuzz/fizzbuzzpy/__init__.py diff --git a/fizzbuzz/fizzbuzzpy/fizzbuzzer.py b/python/fizzbuzz/fizzbuzzpy/fizzbuzzer.py similarity index 100% rename from fizzbuzz/fizzbuzzpy/fizzbuzzer.py rename to python/fizzbuzz/fizzbuzzpy/fizzbuzzer.py diff --git a/tests/test_fizzbuzzo3.py b/tests/test_fizzbuzzo3.py index c981217..80c5572 100644 --- a/tests/test_fizzbuzzo3.py +++ b/tests/test_fizzbuzzo3.py @@ -1,5 +1,4 @@ import pytest - from fizzbuzz.fizzbuzzo3 import fizzbuzz