Comments (8)
I can not reproduce first problem. I could build wheel package and it contains .so
file.
try to unpack wheel package and check if it contains so file. build_rust
builds library inplace, it copies it to location you define in your setup.py
file.
I don't understand your second question. rust creates shared library, so it in target
directory or $CARGO_TARGET_DIR
(I will add support for it)
from setuptools-rust.
ping
from setuptools-rust.
Here is a more detailed way to reproduce. The exact commands are
mkdir /tmp/example
cd /tmp/example
python -m venv tempvenv
source tempvenv/bin/activate
git clone https://github.com/mckaymatt/rust_pypi_example
cd rust_pypi_example/
pip install -U pip
pip install -r requirements_dev.txt
python setup.py --verbose bdist_wheel
pip install dist/rust_pypi_example-*.whl
rust_pypi_example 13
cd dist/
unzip rust_pypi_example*.whl
find . -name '*.so' -type f
This is what the output looks like.
# with python 3
$ mkdir /tmp/example
$ cd /tmp/example
$ python -m venv tempvenv
$ source tempvenv/bin/activate
$ git clone https://github.com/mckaymatt/rust_pypi_example
$ cd rust_pypi_example/
$ pip install -U pip
$ pip install -r requirements_dev.txt
$ python setup.py --verbose bdist_wheel
running bdist_wheel
running build
running build_py
creating build
creating build/lib
creating build/lib/rust_pypi_example
copying rust_pypi_example/rust_pypi_example.py -> build/lib/rust_pypi_example
copying rust_pypi_example/cli.py -> build/lib/rust_pypi_example
copying rust_pypi_example/__init__.py -> build/lib/rust_pypi_example
running egg_info
creating rust_pypi_example.egg-info
writing rust_pypi_example.egg-info/PKG-INFO
writing dependency_links to rust_pypi_example.egg-info/dependency_links.txt
writing entry points to rust_pypi_example.egg-info/entry_points.txt
writing requirements to rust_pypi_example.egg-info/requires.txt
writing top-level names to rust_pypi_example.egg-info/top_level.txt
writing manifest file 'rust_pypi_example.egg-info/SOURCES.txt'
reading manifest file 'rust_pypi_example.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*.jpg' under directory 'docs'
warning: no files found matching '*.png' under directory 'docs'
warning: no files found matching '*.gif' under directory 'docs'
warning: no files found matching '*.so' under directory '*/rust/target/release'
warning: no files found matching '*.dylib' under directory '*/rust/target/release'
warning: no files found matching '*.dll' under directory '*/rust/target/release'
warning: no files found matching '*.lib' under directory '*/rust/target/release'
warning: no files found matching '*.c' under directory '*'
warning: no previously-included files matching '__pycache__' found under directory '*'
warning: no previously-included files matching '*.pyc' found under directory '*'
warning: no previously-included files matching '*.pyo' found under directory '*'
writing manifest file 'rust_pypi_example.egg-info/SOURCES.txt'
creating build/lib/rust_pypi_example/rust
copying rust_pypi_example/rust/Cargo.toml -> build/lib/rust_pypi_example/rust
creating build/lib/rust_pypi_example/rust/src
copying rust_pypi_example/rust/src/lib.rs -> build/lib/rust_pypi_example/rust/src
copying rust_pypi_example/rust/src/rust_pypi_example.h -> build/lib/rust_pypi_example/rust/src
running build_ext
running build_rust
cargo rustc --lib --manifest-path rust_pypi_example/rust/Cargo.toml --release -- --crate-type cdylib
Compiling rust_pypi_example v0.8.5 (file:///tmp/example/rust_pypi_example/rust_pypi_example/rust)
Finished release [optimized] target(s) in 0.38 secs
installing to build/bdist.linux-x86_64/wheel
running install
running install_lib
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/wheel
copying build/lib/rust_pypi_example.cpython-36m-x86_64-linux-gnu.so -> build/bdist.linux-x86_64/wheel
creating build/bdist.linux-x86_64/wheel/rust_pypi_example
copying build/lib/rust_pypi_example/rust_pypi_example.py -> build/bdist.linux-x86_64/wheel/rust_pypi_example
creating build/bdist.linux-x86_64/wheel/rust_pypi_example/rust
copying build/lib/rust_pypi_example/rust/Cargo.toml -> build/bdist.linux-x86_64/wheel/rust_pypi_example/rust
creating build/bdist.linux-x86_64/wheel/rust_pypi_example/rust/src
copying build/lib/rust_pypi_example/rust/src/rust_pypi_example.h -> build/bdist.linux-x86_64/wheel/rust_pypi_example/rust/src
copying build/lib/rust_pypi_example/rust/src/lib.rs -> build/bdist.linux-x86_64/wheel/rust_pypi_example/rust/src
copying build/lib/rust_pypi_example/cli.py -> build/bdist.linux-x86_64/wheel/rust_pypi_example
copying build/lib/rust_pypi_example/__init__.py -> build/bdist.linux-x86_64/wheel/rust_pypi_example
running install_egg_info
Copying rust_pypi_example.egg-info to build/bdist.linux-x86_64/wheel/rust_pypi_example-0.8.5-py3.6.egg-info
Copying dependency_links.txt to build/bdist.linux-x86_64/wheel/rust_pypi_example-0.8.5-py3.6.egg-info/dependency_links.txt
Copying SOURCES.txt to build/bdist.linux-x86_64/wheel/rust_pypi_example-0.8.5-py3.6.egg-info/SOURCES.txt
Copying top_level.txt to build/bdist.linux-x86_64/wheel/rust_pypi_example-0.8.5-py3.6.egg-info/top_level.txt
Copying requires.txt to build/bdist.linux-x86_64/wheel/rust_pypi_example-0.8.5-py3.6.egg-info/requires.txt
Copying not-zip-safe to build/bdist.linux-x86_64/wheel/rust_pypi_example-0.8.5-py3.6.egg-info/not-zip-safe
Copying PKG-INFO to build/bdist.linux-x86_64/wheel/rust_pypi_example-0.8.5-py3.6.egg-info/PKG-INFO
Copying entry_points.txt to build/bdist.linux-x86_64/wheel/rust_pypi_example-0.8.5-py3.6.egg-info/entry_points.txt
running install_scripts
creating build/bdist.linux-x86_64/wheel/rust_pypi_example-0.8.5.dist-info/WHEEL
$ pip install dist/rust_pypi_example-0.8.5-cp36-cp36m-linux_x86_64.whl
Processing ./dist/rust_pypi_example-0.8.5-cp36-cp36m-linux_x86_64.whl
Requirement already satisfied: Click>=6.0 in /tmp/example/tempvenv/lib/python3.6/site-packages (from rust-pypi-example==0.8.5)
Requirement already satisfied: cffi>=1.0.0 in /tmp/example/tempvenv/lib/python3.6/site-packages (from rust-pypi-example==0.8.5)
Requirement already satisfied: pycparser in /tmp/example/tempvenv/lib/python3.6/site-packages (from cffi>=1.0.0->rust-pypi-example==0.8.5)
Installing collected packages: rust-pypi-example
Successfully installed rust-pypi-example-0.8.5
$ rust_pypi_example 13
Traceback (most recent call last):
File "/tmp/example/tempvenv/bin/rust_pypi_example", line 7, in <module>
from rust_pypi_example.cli import main
File "/tmp/example/tempvenv/lib/python3.6/site-packages/rust_pypi_example/cli.py", line 4, in <module>
from .rust_pypi_example import rust_lib
File "/tmp/example/tempvenv/lib/python3.6/site-packages/rust_pypi_example/rust_pypi_example.py", line 35, in <module>
rust_lib = ffi.dlopen(DLPATH)
File "/tmp/example/tempvenv/lib/python3.6/site-packages/cffi/api.py", line 140, in dlopen
lib, function_cache = _make_ffi_library(self, name, flags)
File "/tmp/example/tempvenv/lib/python3.6/site-packages/cffi/api.py", line 786, in _make_ffi_library
backendlib = _load_backend_lib(backend, libname, flags)
File "/tmp/example/tempvenv/lib/python3.6/site-packages/cffi/api.py", line 781, in _load_backend_lib
raise OSError(msg)
OSError: cannot load library /tmp/example/tempvenv/lib/python3.6/site-packages/rust_pypi_example/rust/target/release/librust_pypi_example.so: /tmp/example/tempvenv/lib/python3.6/site-packages/rust_pypi_example/rust/target/release/librust_pypi_example.so: cannot open shared object file: No such file or directory. Additionally, ctypes.util.find_library() did not manage to locate a library called '/tmp/example/tempvenv/lib/python3.6/site-packages/rust_pypi_example/rust/target/release/librust_pypi_example.so'
(tempvenv) matt@mattymint /tmp/example/rust_pypi_example (master)
$ cd dist/
$ unzip rust_pypi_example-0.8.5-cp36-cp36m-linux_x86_64.whl
Archive: rust_pypi_example-0.8.5-cp36-cp36m-linux_x86_64.whl
inflating: rust_pypi_example.cpython-36m-x86_64-linux-gnu.so
inflating: rust_pypi_example/rust_pypi_example.py
inflating: rust_pypi_example/cli.py
inflating: rust_pypi_example/__init__.py
inflating: rust_pypi_example/rust/Cargo.toml
inflating: rust_pypi_example/rust/src/rust_pypi_example.h
inflating: rust_pypi_example/rust/src/lib.rs
inflating: rust_pypi_example-0.8.5.dist-info/DESCRIPTION.rst
inflating: rust_pypi_example-0.8.5.dist-info/entry_points.txt
inflating: rust_pypi_example-0.8.5.dist-info/metadata.json
inflating: rust_pypi_example-0.8.5.dist-info/top_level.txt
inflating: rust_pypi_example-0.8.5.dist-info/WHEEL
inflating: rust_pypi_example-0.8.5.dist-info/METADATA
inflating: rust_pypi_example-0.8.5.dist-info/RECORD
# .so is in package root but not in rust/target/release.
# If we ran build_ext before it would be in rust/target/release
$ find . -name '*.so' -type f
./rust_pypi_example.cpython-36m-x86_64-linux-gnu.so
If you repeat this again but you include build_ext
before bdist_wheel
it will work.
from setuptools-rust.
I don't understand your second question. rust creates shared library, so it in target directory or $CARGO_TARGET_DIR (I will add support for it)
Let me try using this new option and then I will get back to you if It doesn't help.
from setuptools-rust.
I see. You can not rely on target/release
directory, this is temp build directory.
you have to copy your .so
file into dist. which setuptools-rust does.
you should inspect setuptools-rust behavior with binding=Binding.NoBinding
parameter.
I am not sure when I will have time for this.
from setuptools-rust.
you should inspect setuptools-rust behavior with binding=Binding.NoBinding parameter.
That's what I'm using. But I think this answers my question. Yes, the shared lib should be located in the package root. That works for me.
from setuptools-rust.
Did you figured out what is the problem? Do I need to look into this problem?
from setuptools-rust.
I think I figured it out and I'd say you can close this. if there is an issue, it's with how I locate the .so, since it does look like setuptools-rust is putting in the right place. Thanks
from setuptools-rust.
Related Issues (20)
- 1.5.x sdist no longer contains examples, docs, and tests HOT 5
- build fails with "error: Rust build failed; unable to find any build artifacts" HOT 6
- Is there a way to trigger `release` target build for `build_ext --inplace` command? HOT 3
- setuptools-rust fails to cross-compile cryptography using crossenv HOT 10
- Failed to build on MacOs 13.0.1,setuptools_rust HOT 1
- can I build an `.so` without the target between the module name and the extension? HOT 2
- Setuptools deprecation warning with setuptools-rust HOT 4
- Facing an issue while trying to build setuptools-rust HOT 3
- Compilation in setuptools_rust fails with `1.70.0-nightly` toolchain HOT 3
- Python crashes on import when using pip editable install on M1 HOT 6
- Unable to control `--debug` / `--release` via PEP517 backend HOT 7
- No module named 'setuptools.command.build' HOT 2
- Document how to use setuptools-rust with a workspace HOT 2
- Scaling PyO3 down with single-file Python extensions HOT 7
- DeprecationWarning: pkg_resources is deprecated as an API
- Allow offline mode via environment variable HOT 7
- `install_extension` crashes due to attempt to mkdir an empty path (v1.8.0)
- With latest nightly rust, builds failing due to changes in cargo output HOT 6
- Trouble using pyproject.toml for limited api HOT 8
- Please update PyO3 to 0.20.3 HOT 2
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 setuptools-rust.