-
-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Importing mixed Rust/Python project fails when structured as recommended #490
Comments
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
armv7: Interesting. I think we are expecting I wonder what's is Rust target triple on these platforms. See also randombit/botan#1543 (comment) |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
I'm running into this same issue, but I might have a shorter path to reproducing it. I'm including as much detail as possible because I might be doing something weird in here. I'm not an experienced python dev and I'm kinda winging it as I go.
For some extra version info just in case it helps for reproducing the issue:
What is interesting is that if I run
So before I go further, I want to repeat, I'm not a python dev. So this might be missing the point of the initial bug or misunderstanding how modules work. But it looks to me that when |
It is needed to prevent import errors as the repo root sometimes gets into the PYTHONPATH, e.g. when python interactive is used. In that case the native extension may not be loadable. See also PyO3/maturin#490
It is needed to prevent import errors as the repo root sometimes gets into the PYTHONPATH, e.g. when python interactive is used. In that case the native extension may not be loadable. See also PyO3/maturin#490
It is needed to prevent import errors as the repo root sometimes gets into the PYTHONPATH, e.g. when python interactive is used. In that case the native extension may not be loadable. See also PyO3/maturin#490
It is needed to prevent import errors as the repo root sometimes gets into the PYTHONPATH, e.g. when python interactive is used. In that case the native extension may not be loadable. See also PyO3/maturin#490
It is needed to prevent import errors as the repo root sometimes gets into the PYTHONPATH, e.g. when python interactive is used. In that case the native extension may not be loadable. See also PyO3/maturin#490
It is needed to prevent import errors as the repo root sometimes gets into the PYTHONPATH, e.g. when python interactive is used. In that case the native extension may not be loadable. See also PyO3/maturin#490
- replace poetry by maturin - introduce Makefile for simplify life of devs - add a maturin action - refactor the project to the recommended structure - redefine dependencies as pure pyproject (see PyO3/maturin#490 for details) On branch 18-maturin_build Changes to be committed: new file: .github/workflows/release.yaml modified: .gitignore renamed: h2o-data-rust/Cargo.lock -> Cargo.lock renamed: h2o-data-rust/Cargo.toml -> Cargo.toml new file: Makefile deleted: h2o-data-rust/README.md modified: poetry.lock modified: pyproject.toml renamed: farsante/__init__.py -> python/farsante/__init__.py renamed: farsante/h2o_dataset_create.py -> python/farsante/h2o_dataset_create.py renamed: farsante/h2o_dataset_create_all.py -> python/farsante/h2o_dataset_create_all.py renamed: farsante/pandas_dfs.py -> python/farsante/pandas_dfs.py renamed: farsante/pandas_generators.py -> python/farsante/pandas_generators.py renamed: farsante/pyspark_dfs.py -> python/farsante/pyspark_dfs.py renamed: farsante/pyspark_generators.py -> python/farsante/pyspark_generators.py renamed: h2o-data-rust/src/generators.rs -> src/generators.rs renamed: h2o-data-rust/src/helpers.rs -> src/helpers.rs renamed: h2o-data-rust/src/lib.rs -> src/lib.rs renamed: h2o-data-rust/src/main.rs -> src/main.rs
* Building system of farsante - replace poetry by maturin - introduce Makefile for simplify life of devs - add a maturin action - refactor the project to the recommended structure - redefine dependencies as pure pyproject (see PyO3/maturin#490 for details) On branch 18-maturin_build Changes to be committed: new file: .github/workflows/release.yaml modified: .gitignore renamed: h2o-data-rust/Cargo.lock -> Cargo.lock renamed: h2o-data-rust/Cargo.toml -> Cargo.toml new file: Makefile deleted: h2o-data-rust/README.md modified: poetry.lock modified: pyproject.toml renamed: farsante/__init__.py -> python/farsante/__init__.py renamed: farsante/h2o_dataset_create.py -> python/farsante/h2o_dataset_create.py renamed: farsante/h2o_dataset_create_all.py -> python/farsante/h2o_dataset_create_all.py renamed: farsante/pandas_dfs.py -> python/farsante/pandas_dfs.py renamed: farsante/pandas_generators.py -> python/farsante/pandas_generators.py renamed: farsante/pyspark_dfs.py -> python/farsante/pyspark_dfs.py renamed: farsante/pyspark_generators.py -> python/farsante/pyspark_generators.py renamed: h2o-data-rust/src/generators.rs -> src/generators.rs renamed: h2o-data-rust/src/helpers.rs -> src/helpers.rs renamed: h2o-data-rust/src/lib.rs -> src/lib.rs renamed: h2o-data-rust/src/main.rs -> src/main.rs * Drop poetry.lock By switching to maturing-builds we do not need poetry.lock anymore On branch 18-maturin_build Your branch is up to date with 'origin/18-maturin_build'. Changes to be committed: deleted: poetry.lock
… projects The previous layout leads to an import error when installing with `maturin build` and `pip install .`. This error was common enough that `maturin` changed the recommended project layout to what this commit does. A prior PR attempted to solve this by altering `lib.name` in Cargo.toml, but that did not work for me. - [Prior PR](apache#694) - [maturin ImportError issue](PyO3/maturin#490) - [maturin changes recommended project structure](PyO3/maturin#855)
#695) * chore: update to maturin's recommended project layout for rust/python projects The previous layout leads to an import error when installing with `maturin build` and `pip install .`. This error was common enough that `maturin` changed the recommended project layout to what this commit does. A prior PR attempted to solve this by altering `lib.name` in Cargo.toml, but that did not work for me. - [Prior PR](#694) - [maturin ImportError issue](PyO3/maturin#490) - [maturin changes recommended project structure](PyO3/maturin#855) * ci: update `ruff check` for nested python directory
Per PyO3/maturin#490 and PyO3/maturin#855, this avoids problems when importing from the project dir.
Per PyO3/maturin#490 and PyO3/maturin#855, this avoids problems when importing from the project dir.
Per PyO3/maturin#490 and PyO3/maturin#855, this avoids problems when importing from the project dir.
Per PyO3/maturin#490 and PyO3/maturin#855, this avoids problems when importing from the project dir.
Per PyO3/maturin#490 and PyO3/maturin#855, this avoids problems when importing from the project dir.
Per PyO3/maturin#490 and PyO3/maturin#855, this avoids problems when importing from the project dir.
The README of this project says the following:
This is the structure I'm using for
python-adblock
. The project is written entirely in Rust, but I'm using a mixed Rust/Python project in order to include Python type stubs. I have an__init__.py
which imports the neccesary symbols from the native module.However, some of my users have reported that the imports inside
__init__.py
fail as follows:or
See ArniDagur/python-adblock#17. As you can see, the result is the same whether I use
from .adblock import ...
orfrom adblock.adblock import ...
. I have only managed to reproduce this when the package is installed system wide (pip3 install .
) and the current working directory is the root of my project (git repository).Does anyone know what is going on? Am I doing something different from what is described in the
README.md
, or is the advice in theREADME.md
wrong in some way?The text was updated successfully, but these errors were encountered: