Commit Graph

5418 Commits

Author SHA1 Message Date
Adam Reichold 7b99af9b34 Execute the example for intern macro to ensure it is correct. 2022-04-04 20:25:47 +02:00
Adam Reichold 30d414fd49 Add intern macro to hygiene tests and ensure it can handle stringified identifiers. 2022-04-04 18:53:31 +02:00
David Hewitt 9f3ccff8c9 guide: improve documentation for `#[pyclass(mapping)]` 2022-04-04 15:51:01 +01:00
David Hewitt 4e5c874dba
Merge pull request #2272 from ravenexp/cross-python-implementation
pyo3-build-config: Add `PYO3_CROSS_PYTHON_IMPLEMENTATION` env var
2022-04-04 15:27:31 +01:00
Sergey Kvachonok 80675361f4 pyo3-build-config: Add `PYO3_CROSS_PYTHON_IMPLEMENTATION` env var
Adds a new cross-compile target interpreter configuration
environment variable.

This feature allows PyO3 to target PyPy on both Windows and Unix
cross compile targets.
2022-04-04 15:23:11 +03:00
Adam Reichold f777372eed Limit the intern! macro to strings and intern the string contents in addition to the reference. 2022-04-04 10:11:52 +02:00
Adam Reichold 125bf416a2 Separate the fast and slow path of GILOnceCell::get_or_init. 2022-04-03 21:18:09 +02:00
Adam Reichold db109867d3 Add intern! macro which can be used to amortize the cost of creating Python objects by storing them inside a GILOnceCell. 2022-04-03 21:16:42 +02:00
Adam Reichold d3dcbd72ba
Add PyString::intern to enable access to Python's built-in string interning. (#2268) 2022-04-03 21:07:58 +02:00
David Hewitt 040ce8616b
Merge pull request #2241 from ravenexp/cross-compile
pyo3-build-config: Make `PYO3_CROSS_LIB_DIR` optional
2022-04-02 20:59:08 +01:00
David Hewitt c16cc35b30 pyclass: mapping flag 2022-04-02 16:15:44 +01:00
mejrs 086424b88c Merge branch 'main' of https://github.com/mejrs/pyo3 into immutable 2022-04-01 23:11:02 +02:00
mejrs 9ab1e6927a Merge branch 'immutable' of https://github.com/mejrs/pyo3 into immutable 2022-04-01 22:59:59 +02:00
Sergey Kvachonok 2d2b9f5c33 Update the user guide and add a ChangeLog entry
Update Architecture.md to reflect the current cross compilation
support state.
2022-04-01 11:32:46 +03:00
Sergey Kvachonok ccda497e04 pyo3-build-config: Create per-target cross config files
Rename `$OUT_DIR/pyo3-cross-compile-config.txt` to
`$OUT_DIR/<triple>/pyo3-build-config.txt` to exclude the possibility
of using stale build configuration data when the build target changes.

Use the presence of the corresponding build configuration file
in the `pyo3-build-config` build script output directory
to detect whether we are cross compiling or not.

This patch enables cross compilation without using
any of `PYO3_CROSS_*` env variables in many cases.
2022-04-01 11:32:46 +03:00
Sergey Kvachonok 328e7d69f6 pyo3-build-config: Try "default" cross-compilation
Try to generalize `windows_hardcoded_cross_compile()`
to all supported target platforms (when possible).
Rename it to `default_cross_compile()` and add some unit tests.

Rewrite `load_cross_compile_config()` to fall back to
the default interpreter configuration when no other config
information sources are available.
2022-04-01 11:32:46 +03:00
Sergey Kvachonok 54ae025722 pyo3-build-config: Make `lib_dir` optional in `CrossCompileConfig`
Change the `CrossCompileConfig` structure definition and make
the public `lib_dir` field optional to support more flexible
cross-compilation configuration in the future.

FIXME: This change breaks the public `pyo3-build-config` crate API.

Update the sysconfigdata extraction functions to fall through
when `lib_dir` field is not set.

WIP: Add `unwrap()` stubs to the main cross compile switch.
2022-04-01 11:32:46 +03:00
Adam Reichold 601e3d6517
Merge pull request #2253 from ravenexp/target-lexicon
pyo3-build-config: Replace `TargetInfo` with `target_lexicon::Triple`
2022-04-01 10:16:35 +02:00
Sergey Kvachonok 9b45a19161 pyo3-build-config: Replace `TargetInfo` with `target_lexicon::Triple`
Add a new public crate function `cross_compile_from_to()` using
`target_lexicon::Triple` arguments instead of plain strings
used in `cross_compile()`.

Deprecate `pyo3_build_config::cross_compile()` since v0.17.

Attempt to extract common code patterns into methods and standalone
helper functions. Add docstrings to the new private items.
Make some of the new helper functions public within the PyO3 crate
and reuse them in the build scripts.

Add PYO3_CROSS_PYTHON_VERSION parsing unit test.

Add a ChangeLog entry mentioning the new `pyo3-build-config` API.
2022-04-01 09:36:49 +03:00
Bruno Kolenbrander 78efebd993
Expand some documentation (#2256)
* use `is` where appropriate

* Rework safety docs
2022-03-30 12:56:14 +02:00
messense 0f49bedf67
Merge pull request #2258 from messense/black-22.3.0
Update black to 22.3.0
2022-03-30 12:02:55 +08:00
messense 8febab1fe9
Update black to 22.3.0 2022-03-30 11:22:26 +08:00
David Hewitt 9b92d98414
Merge pull request #2252 from messense/xtask-actions
Don't capture output when running command in xtask
2022-03-28 12:02:49 +01:00
messense b22d33793d
Don't capture output when running command in xtask 2022-03-28 11:52:30 +08:00
David Hewitt de060573d3
Merge pull request #2250 from messense/pep573-fns
Add FFI definitions for PEP 573 functions
2022-03-28 03:43:35 +01:00
David Hewitt 9dca5cffbb
Merge pull request #2251 from mityax/main
Add rustimport to tools section in readme
2022-03-28 03:36:34 +01:00
messense 03d34ab34d
Show xtask stdout and stderr when running in GitHub
Actions
2022-03-27 22:16:46 +08:00
mityax 4d7c84b459
Fix typo 2022-03-26 22:44:17 +05:30
mityax 08a390a397
Add rustimport to tools section in readme 2022-03-26 22:43:11 +05:30
messense 733a2c68f5
Update changelog entry 2022-03-26 21:27:49 +08:00
messense 23e220985a
Mark `METH_FASTCALL` as limited API on Python 3.10+
0b9c4c6fcf (diff-adb492ab0eb13648d50d0d79e4b6e5517b27f983ab3b21b63e77f54132c98e9dR76)
2022-03-26 21:27:49 +08:00
messense f3f0a612d8
Add FFI definition for `PyModule_AddType` 2022-03-26 21:27:49 +08:00
messense 92c132569f
Add FFI definitions for PEP 573 functions 2022-03-26 21:27:44 +08:00
David Hewitt 8a21db93f3
Merge pull request #2249 from davidhewitt/gh-pages-ci
ci: avoid race between bench and guide
2022-03-25 11:08:33 +00:00
David Hewitt 35a27a8d04 ci: avoid race between bench and guide 2022-03-25 10:10:54 +00:00
Bruno Kolenbrander 43944aef76
Create a better error message for moving self (#2238) 2022-03-24 10:27:37 +01:00
David Hewitt 16ee22c7cc
Merge pull request #2244 from mejrs/lint-more
Add more lints
2022-03-23 13:40:35 +00:00
mejrs 00ea040834 Feedback 2022-03-23 13:30:32 +01:00
David Hewitt 2813c87eaf
Merge pull request #2092 from aganders3/export-conf
Add export-config feature to pyo3-build-config
2022-03-23 11:16:04 +00:00
mejrs 1b9763fef2 Fix merge conflict 2022-03-23 10:10:35 +01:00
messense 7f62c96ead
Merge pull request #2242 from ravenexp/fix-max-abi3-version
Fix `abi3-py310` feature implementation: use Python 3.10 ABI when available.
2022-03-23 16:55:23 +08:00
Bruno Kolenbrander fb689340b4
Merge branch 'main' into lint-more 2022-03-23 09:34:31 +01:00
David Hewitt 60d42b07b4
Merge pull request #2243 from ravenexp/simple-fastcall
pyo3-macros-backend: Replace `pyo3-build-config` with `abi3` feature
2022-03-23 08:01:34 +00:00
mejrs 6f1cf1b662 Add more lints 2022-03-23 08:07:28 +01:00
Sergey Kvachonok 7a44aa1070 pyo3-macros-backend: Replace `pyo3-build-config` with `abi3` feature
Python 3.6 and older are not supported by the current PyO3 version,
so the removed interpreter version check was a no-op.

`pyo3_build_config::get()` attempts to read a config file from disk
when PyO3 is cross-compiling, which is probably bad for rust-analyzer
and other IDEs that attempt to sandbox the proc macro code.
2022-03-23 09:48:15 +03:00
Sergey Kvachonok 5237000317 pyo3-build-config: Fix `abi3-py310` feature
Fix `abi3-py310` feature: use Python 3.10 ABI when available
instead of silently falling back to the 3.9 ABI.
2022-03-23 09:45:25 +03:00
Ashley Anderson 272d2bc0e6
Merge branch 'main' into export-conf 2022-03-22 12:59:54 -04:00
David Hewitt 87c79c0319
Merge pull request #2234 from davidhewitt/pyclass-args-refactor
pyclass: unify pyclass with its pyo3 arguments
2022-03-22 11:38:05 +00:00
David Hewitt 49c1d22606 docs: for #2234 2022-03-22 10:38:36 +00:00
messense 4339214ded
Merge pull request #2239 from zh-jq/patch-v0.16.2
allow to compile with parking_lot 0.12
2022-03-22 14:39:46 +08:00