Commit Graph

249 Commits

Author SHA1 Message Date
William S Fulton 831fc60691 Add docs on the python runtime module 2025-05-13 21:49:37 +01:00
William S Fulton e1cf7b37ac Edit last few commits for python-3.14 and 3.15 support
GHA - python-3.14 testing changed to "can fail" as 3.14 is still in alpha status.

Restore __package__ fallback check as it was.

Correct docs given the import changes.

Issue #3159
Issue #2967

more
2025-04-28 22:57:17 +01:00
Julien Schueller 50e1cc8bc0 Python: Handle __package__ removal
Closes #2967
2025-04-25 22:13:46 +02:00
William S Fulton 4167b0275a Free threading python doc improvements
Move free threading docs to section on multithreading and clarify that users must make their own
code thread-safe.

Issue #3137
[skip ci]
2025-04-25 08:35:16 +01:00
William S Fulton b0c7e23858 Add link to Python free threading site
See issue #3121
[skip ci]
2025-04-20 18:46:19 +01:00
William S Fulton 298c489dc6 Add docs for free threading Python
'make check-python-version' now uses -VV so that a free threading build
can be identified.
2025-04-17 18:51:33 +01:00
Olly Betts dbbe636631 [doc] Add note that -dirvtable currently causes leaks
See https://sourceforge.net/p/swig/bugs/1073/
2024-10-06 07:48:29 +13:00
William S Fulton a9ececf43c html fix
[skip ci]
2024-10-04 22:34:40 +01:00
William S Fulton 3f8e63c41d All you need to know about 'swig/python detected a memory leak' 2024-10-04 22:18:18 +01:00
William S Fulton baa725e5ff Python shebang modernisation for python3
PEP-394 recommends specifying python2 or python3 in shebangs unless the
script is known to only run in an activated virtual environment.

PEP-394 also says distributors may not provide the python command.
Newer versions of Ubuntu, at least, no longer provide python unless the
python-is-python3 package is explicitly installed.

Removed some shebangs from testcases (the test-suite does not need them).
2024-09-22 22:11:33 +01:00
Olly Betts cd40541bd1 [python] Adjust wording around supported versions
See #2537
2024-09-11 15:12:40 +12:00
Olly Betts 5c01f7c536 Remove references to SWIG_FILE_WITH_INIT
These were added in 5f1ac9567b back
in 2007, but there's no trace of defining this macro ever having done
anything in SWIG git history.
2024-09-06 11:48:40 +12:00
William S Fulton 46b7bafb21 Director thread-safety doc tweaks 2024-07-12 19:22:33 +01:00
William S Fulton 5cfe3e7b3c Document directors and SWIG_THREADS 2024-07-02 08:57:09 +01:00
William S Fulton ba9b0a35ab Merge branch 'char_binary_java_fix-tidyup'
* char_binary_java_fix-tidyup:
  Move SWIGStringWithLengthHelper to csharphead.swg
  cdata whitespace/cosmetic fixups
  cdata doc updates
  Rename `typemaps/cdata_struct.swg` to `typemaps/cdata_begin.swg`. And `typemaps/cdata.swg` to `typemaps/cdata.swg`. Move `cdata_apply.swg` content to `typemaps/cdata.swg`.
  Group the C# marshalling of STRING-LENGTH typemap  into C# class named SWIGStringWithLengthHelper.
  Leave Length & string reverse order typemap in typemaps/strings.swg
  Support old C# as "LPUTF8Str" was add in 2017.
  Improve documentation. Follow @wsfulton reviews.
  Use a dummy for MzScheme and untested OCaml cdate. To prevent compilation error.
  Further fixing follow reviews.
  Reorganise raw data typemap,  so typemaps folder contain only common part. Improve document.
  Inline SWIG_string_to_utf8_bytes SWIG_utf8_bytes_to_string code
  Fixes of STRING/BYTES LENGTH typemaps.

 Conflicts:
	CHANGES.current
2024-06-13 10:53:19 +01:00
William S Fulton ea2380d52a cdata doc updates
The cdata.i docs in C#, Java, D, Go had a confusing mix of target language
and C declarations. Improve the main cdata documentation in Library.html instead.
2024-06-07 08:27:15 +01:00
William S Fulton 21aa6e8f9e Merge branch 'py-stable-abi2'
* py-stable-abi2:
  Note about abi3audit and inlined functions
  Add recent stable ABI improvements to changes file
  Switch to SWIG_Py_DECREF instead of Py_Decref
  Show ABI version in CI job name
  C89 conformance for Python stable ABI
  Remove Py_TYPE definition
  Move Stable ABI to more sensible section and update html sectioning
  Add abi3audit information for Python stable ABI
  Use PyObject_Free instead of deprecated macros
  Don't run abi3audit on builtin test
  Strict Python stable abi conformance fix for PyUnicode_GetLength
  Don't use abi3audit if not installed
  Unused parameter warning fix in SWIG_Python_TypeError
  Add PY_ABI_VER for testing Python stable ABI using abi3audit
  configure.ac python versions update
  Tidy up EXTRA_ build flags
  Py_DecRef Py_IncRef for examples and html docs
  Additional casts for Python DecRef change
  Py_XDECREF -> Py_DecRef for stable ABI compliance
  Py_DECREF -> Py_DecRef for stable ABI compliance
  Py_IncRef casts
  Py_XINCREF -> Py_IncRef for stable ABI compliance
  Py_INCREF -> Py_IncRef for stable ABI compliance
  Add Python increment and decrement wrappers
  minor enhancement in changes file

Conflicts:
	CHANGES.current
2024-03-25 22:07:09 +00:00
William S Fulton 5cd9bc7092 Note about abi3audit and inlined functions 2024-03-25 19:59:22 +00:00
William S Fulton 2a02238883 Move Stable ABI to more sensible section and update html sectioning 2024-03-25 07:52:50 +00:00
William S Fulton 639a76fe12 Add abi3audit information for Python stable ABI 2024-03-25 07:52:50 +00:00
William S Fulton 5b710e3298 Py_DecRef Py_IncRef for examples and html docs 2024-03-24 18:12:21 +00:00
Olly Betts a02102ad18 [js,python] Note oldest node and python3 we CI test
See #2537
2024-03-22 08:30:21 +13:00
Olly Betts a1cafe585d Fix Python examples in manual to use print(...)
Python 3 dropped support for `print` without parentheses.  The
amended examples should still work in Python 2.
2024-03-20 16:19:17 +13:00
Erez Geva 1bf59e0bbc Fixes of STRING/BYTES LENGTH typemaps.
Fix Java STRING LENGTH typemap.
Use string type in static typed languages (Java, C#, D and Go).

Add BYTES LENGTH typemap and apply it for binary data.
Use byte type in static typed languages.

Add li_cdata_cpp, li_cdata and char_binary
 tests for most of languages(apart from R and experimental).

Fix the director_binary_string test and add it to C#, D, Go,
 Perl, PHP, Python, Ruby and octave.

Update documents.

Signed-off-by: Erez Geva <ErezGeva2@gmail.com>
2024-02-29 02:09:09 +01:00
William S Fulton 76e73a0ed7 Python stable ABI notes 2023-12-20 07:58:21 +00:00
William S Fulton ef0bbcd6ed Document Python stable ABI support
Remove -stable-abi option: going forwards enabling the stable ABI
simply requires setting Py_LIMITED_ABI when compiling the wrappers.
2023-12-18 23:30:36 +00:00
William S Fulton a75b87d318 Rename -py3-stable-abi option to -stable-abi
Since this was first added, the -py3 option has been dropped
and the Stable ABI is known as exactly that, not the Python3 Stable ABI.

Document the new option and turn on c++20 testing for it to cover
std::filesystem and std::string_view testing which are affected
2023-12-06 08:01:22 +00:00
William S Fulton d701f0b4b2 Correct the implementation of Python PEP 207.
Don't convert all exceptions into a NotImplemented return
when wrapping operators which are marked with %pythonmaybecall.

Closes #1783
2023-10-21 09:25:10 +01:00
William S Fulton 066ad40132 Documentation clarification about $action in Python "shadow" feature
See issue #2582
2023-07-29 19:03:38 +01:00
Olly Betts 10ca0edddb Add %rename to %pythoncode example
Without this you get two set_transform() functions defined in the
.py file, which can trigger warnings from linting tools.

Renaming the SWIG-generated wrapper is a reasonably clean solution
(though does leave an unused _set_transform() Python function).

See #2578
2023-05-15 11:09:13 +12:00
Olly Betts 567c73731b Python: Suggest argcargv.i to handle char**
We were providing an example set of typemaps in the manual, but they
were specific to Python2 which isn't helpful these days.

For typical cases argcargv.i is a better option.  It doesn't currently
seem to directly support the "argv without argc" case which this example
actually shows, but generally APIs take a length as well as a char**.

Closes: #2040
2023-04-21 10:03:31 +12:00
Olly Betts abf5c8a357 [python] Remove doc caveat for Python < 2.1
The minimum version we now support is Python 2.7.
2022-10-11 10:30:37 +13:00
Olly Betts 37c8185bd3 Replace reference to SWIG_POINTER_EXCEPTION in docs
This has only been present for backward compatibility since 2006
and now has the value 0 so doesn't do anything, so don't use it
as an example of a flag in the docs.
2022-10-06 18:06:36 +13:00
Olly Betts 631b41ae7b Use https for swig.org links 2022-10-06 13:16:39 +13:00
Olly Betts 0b9d4eff09 Update everything for dropping Python 3.2 support 2022-07-19 13:20:07 +12:00
William S Fulton b35ebc81a9 Doxygen comments take precedence over the autodoc feature.
If a "docstring" feature is present it will still override a Doxygen comment.
If the "autodoc" feature is also present, the combined "autodoc" and "docstring"
will override the Doxygen comment. If no "docstring" is present then the
"autodoc" feature will not be generated when there is a Doxygen comment.

This way the "autodoc" feature can be specified and used to provide documentation
for 'missing' Doxygen comments.

Closes #1635
2022-04-06 08:08:14 +01:00
William S Fulton a343b7e254 Remove -py3 command line option
Closes #1779
2022-03-23 18:13:07 +00:00
William S Fulton f068f2c2d6 Add Python < 3.3 support for pyabc.i
pyabc.i for abstract base classes now supports versions of Python
prior to 3.3 by using the collection module for these older versions.
Python-3.3 and later continue to use the collections.abc module.
The -py3 option no longer has any effect on the %pythonabc feature.
2022-03-23 07:58:01 +00:00
William S Fulton 21c2e47661 Python -flatstaticmethod corrections
Correct logic for suppressing static methods.
Previous logic was missing director disown methods.
Add changes file entry for -flatstaticmethod.

Closes #2137
2022-03-21 19:22:49 +00:00
Julien Schueller 484e5316f2 Python: Option to generate flat class methods 2022-03-18 11:10:14 +01:00
Olly Betts 2a9431ebfb Remove confusing extra parameter from doc example
The initial prototype shown in these examples has a `len` parameter
but that the rest of the example is as if that parameter isn't there
so remove it from the initial prototype.

Fixes https://sourceforge.net/p/swig/bugs/1289/
2022-03-09 15:05:44 +13:00
William S Fulton 3159de3e9f Add support for Python variable annotations as a feature.
Both function annotations and variable annotations are turned on using the
"python:annotations" feature. Example:

  %feature("python:annotations", "c");

  struct V {
    float val;
  };

The generated code contains a variable annotation containing the C float type:

  class V(object):
      val: "float" = property(_example.V_val_get, _example.V_val_set)
      ...

Python 3.5 and earlier do not support variable annotations, so variable
annotations can be turned off with a "python:annotations:novar" feature flag.
Example turning on function annotations but not variable annotations globally:

  %feature("python:annotations", "c");
  %feature("python:annotations:novar");

or via the command line:

  -features python:annotations=c,python:annotations:novar

Closes #1951
2022-03-02 19:33:03 +00:00
William S Fulton 5a945bb135 More docs on -fastproxy and annotations 2022-03-02 07:44:04 +00:00
William S Fulton bc68a9b034 Document limitations with Python annotations
[skip ci]
2022-02-28 19:58:21 +00:00
William S Fulton 2072ae19c9 Python function annotations removed from -py3 option.
Python function annotations containing C/C++ types are no longer
generated when using the -py3 option. Function annotations support
has been moved to a feature to provide finer grained control.
It can be turned on globally by adding:

  %feature("python:annotations", "c");

or by using the command line argument:

  -features python:annotations=c

The implementation is designed to be expandable to support different
annotations implementations. Future implementations could implement
something like the following for generating pure Python types:

  %feature("python:annotations", "python");

or typing module types to conform to PEP-484:

  %feature("python:annotations", "typing");

Closes #1561
Issue #735
2022-02-27 10:47:50 +00:00
Olly Betts 005ffc76de [python] Fix double free on error in docs example
Closes #2073
2022-01-26 13:30:15 +13:00
William S Fulton 7a65f028f8 Update docs - python static members access
[skip-ci]
2021-10-20 11:53:18 +01:00
Zackery Spytz 8f795a4220 Fix references to pyopers.swg in the Python docs
[skip ci]
2020-06-09 17:42:46 -06:00
William S Fulton b7bcb338cf Add C++20 documentation chapter 2020-06-08 20:56:40 +01:00
William S Fulton 7070320335 Revert "Add C++20 documentation chapter"
This reverts commit 36e8d521de.

Conflicts:
	Doc/Manual/R.html
2020-06-08 20:06:55 +01:00