-
-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add
test_develop
and check_wheel_files
testing for `--with-…
…debuginfo`
- Loading branch information
Showing
15 changed files
with
400 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.py[cdo] | ||
*.pdb |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "pyo3-mixed" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[[bin]] | ||
name = "pyo3-bin" # keep the name with a dash to test `.pdb` file name | ||
path = "src/main.rs" |
31 changes: 31 additions & 0 deletions
31
test-crates/pyo3-bin-msvc-debuginfo/check_installed/check_installed.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import sys | ||
import platform | ||
from pathlib import Path | ||
|
||
|
||
class MaturinTestError(Exception): | ||
pass | ||
|
||
|
||
def main(): | ||
# e.g. `venv\Scripts` | ||
scripts_dir = Path(sys.executable).parent | ||
|
||
# set by `bin.name = "pyo3-bin"` in `Cargo.toml` | ||
exe_binding_path = scripts_dir / "pyo3-bin.exe" | ||
if not exe_binding_path.exists(): | ||
raise MaturinTestError(f"{exe_binding_path} does not exist") | ||
|
||
# the pdb file of `foo-bar.exe` is `foo_bar.pdb` | ||
exe_binding_debuginfo_path = scripts_dir / "pyo3_bin.pdb" | ||
if not exe_binding_debuginfo_path.exists(): | ||
raise MaturinTestError(f"{exe_binding_debuginfo_path} does not exist") | ||
|
||
|
||
if __name__ == "__main__": | ||
if not platform.system() == "Windows": | ||
raise MaturinTestError("This test is only supported on MSVC") | ||
|
||
main() | ||
|
||
print("SUCCESS") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[build-system] | ||
requires = ["maturin>=1.7,<2.0"] | ||
build-backend = "maturin" | ||
|
||
[project] | ||
name = "pyo3-mixed" | ||
requires-python = ">=3.8" | ||
classifiers = [ | ||
"Programming Language :: Rust", | ||
"Programming Language :: Python :: Implementation :: CPython", | ||
"Programming Language :: Python :: Implementation :: PyPy", | ||
] | ||
dynamic = ["version"] | ||
|
||
[tool.maturin] | ||
bindings = "bin" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
println!("Hello, world!"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.py[cdo] | ||
*.pdb |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "pyo3-mixed" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
[lib] | ||
name = "pyo3_mixed" | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
pyo3 = "0.22.0" |
36 changes: 36 additions & 0 deletions
36
test-crates/pyo3-mixed-msvc-debuginfo/check_installed/check_installed.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import platform | ||
from pathlib import Path | ||
import sysconfig | ||
|
||
import pyo3_mixed | ||
|
||
|
||
class MaturinTestError(Exception): | ||
pass | ||
|
||
|
||
def main(): | ||
# e.g. `...\test-crates\pyo3-mixed-msvc-debuginfo\python\pyo3_mixed\__init__.py` | ||
init_py_path = Path(pyo3_mixed.__file__) | ||
|
||
ext_suffix = sysconfig.get_config_var("EXT_SUFFIX") | ||
|
||
# set by `module-name = "pyo3_mixed._pyo3_lib"` in `pyproject.toml` | ||
# e.g. `_pyo3_lib.cp310-win_amd64.pyd` | ||
lib_pyd_path = init_py_path.with_name(f"_pyo3_lib{ext_suffix}") | ||
if not lib_pyd_path.exists(): | ||
raise MaturinTestError(f"{lib_pyd_path} does not exist") | ||
|
||
# set by `lib.name = "pyo3_mixed"` in `Cargo.toml` | ||
lib_debuginfo_path = init_py_path.with_name("pyo3_mixed.pdb") | ||
if not lib_debuginfo_path.exists(): | ||
raise MaturinTestError(f"{lib_debuginfo_path} does not exist") | ||
|
||
|
||
if __name__ == "__main__": | ||
if not platform.system() == "Windows": | ||
raise MaturinTestError("This test is only supported on MSVC") | ||
|
||
main() | ||
|
||
print("SUCCESS") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[build-system] | ||
requires = ["maturin>=1.7,<2.0"] | ||
build-backend = "maturin" | ||
|
||
[project] | ||
name = "pyo3-mixed" | ||
requires-python = ">=3.8" | ||
classifiers = [ | ||
"Programming Language :: Rust", | ||
"Programming Language :: Python :: Implementation :: CPython", | ||
"Programming Language :: Python :: Implementation :: PyPy", | ||
] | ||
dynamic = ["version"] | ||
|
||
[tool.maturin] | ||
python-source = "python" | ||
# keep the pyd name different from the rust lib name to test `.pdb` file name | ||
module-name = "pyo3_mixed._pyo3_lib" | ||
features = ["pyo3/extension-module"] |
8 changes: 8 additions & 0 deletions
8
test-crates/pyo3-mixed-msvc-debuginfo/python/pyo3_mixed/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from ._pyo3_lib import sum_as_string | ||
from . import _pyo3_lib | ||
|
||
__all__ = ["sum_as_string"] | ||
|
||
__doc__ = _pyo3_lib.__doc__ | ||
if hasattr(_pyo3_lib, "__all__"): | ||
__all__ = _pyo3_lib.__all__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use pyo3::prelude::*; | ||
|
||
/// A Python module implemented in Rust. | ||
#[pymodule] | ||
// keep the name the same as `module-name = "pyo3_mixed._pyo3_lib"` in `pyproject.toml` | ||
#[pyo3(name = "_pyo3_lib")] | ||
mod pyo3_lib { | ||
use super::*; | ||
|
||
/// Formats the sum of two numbers as string. | ||
#[pyfunction] | ||
fn sum_as_string(a: usize, b: usize) -> PyResult<String> { | ||
Ok((a + b).to_string()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.