Comments (7)
Looks like Python is not automatically searching $PATH from v3.8 onwards, it works if you use os.add_dll_directory()
. Should maturin/PyO3 handle this?
from maturin.
How should maturin
handle this? What's the right argument to pass to os.add_dll_directory()
?
from maturin.
Good queston. os.add_dll_directory()
needs to be called with each directory to look for DLLs in for. Could we maybe have an option to just add everything in PATH
to os.add_dll_directory()
when importing? The alternative is some form of bundling, but that can cause license issues.
I'm still not sure why it just works on MacOS.
for context: https://docs.python.org/3/whatsnew/3.8.html#bpo-36085-whatsnew
from maturin.
IMHO, for security it should be left for the library/user to call os.add_dll_directory()
, doing in in maturin
/pyo3
unconditionally seems worrisome.
from maturin.
What are the security implications you're worried about? IMHO this is the standard for system-wide dynamic DLLs and most Python modules that present bindings to C libs will search PATH
. I generally think that it's highly unintuitive to require a library user to call os.add_dll_directory()
before import
ing things. You can't even have your library handle this (by letting the user specify a search path), because linked libraries will always be loaded upon imports
(I think).
So there needs to be some sort of way to either tell maturin
or poy3
to add PATH
, or to inject custom python code before the module DLL is loaded. I'm not suggesting this should happen unconditionally for every module, but for some modules this will just be required.
from maturin.
What are the security implications you're worried about?
The doc says:
DLL dependencies for extension modules and DLLs loaded with ctypes on Windows are now resolved more securely.
If there isn't any security implication, you'd want python to handle it automatically, right?
Anyway, I suggest you use a mixed Python/Rust project layout and add os.add_dll_directory()
call before importing the Rust extension module.
from maturin.
Thats probbaly the way to go, thanks! Maybe worth documenting as the standard error when trying to import on Windows is not very helpful.
from maturin.
Related Issues (20)
- Improve error when cross compiling to windows without llvm-dlltool HOT 1
- Maturin Fails to x-compile for target `--target i686-pc-windows-msvc` HOT 2
- cross compile to x86_64-pc-windows-gnu from linux builds but not working HOT 1
- option to use uv HOT 4
- error: the configured Python interpreter version (3.13) is newer than PyO3's maximum supported HOT 14
- pytest-step in provided GitHub action prefers remote package over local HOT 1
- `maturin generate-ci github` still generates `upload-artifact@v3`, which is deprecated HOT 2
- build meta wheel does not respect `metadata_directory` per PEP-517 HOT 2
- idea: "import hook" automatically installed with editable builds HOT 1
- Make `--find-interpreter` require opt-in to prereleases HOT 2
- Cannot run maturin
- InvalidDistribution due ot `maturin 1.5`? HOT 2
- Fails to build on LoongArch due to rustix-0.38.30 bump HOT 2
- build-backend - build-wheel - interpreter path - when cross-compiling, got path to interpreter HOT 1
- Generated wheel try to load wrong lib name (using uniffi generated bindings) HOT 1
- maturin 1.5 as backend breaks poetry add HOT 2
- Switch to `Metadata-Version: 2.3` breaks wheel upload to Azure Artifacts HOT 2
- Add JSON schema generation for pyproject.toml with schemars for SchemaStore HOT 1
- maturin build & upload fails due to "malformed summary" HOT 20
- [Feature request] Add llvm tools in maturin image HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from maturin.