Commit graph

12 commits

Author SHA1 Message Date
PatTheMav 318db2842a obs-scripting: Add PyType_Modified import for Swig 4.1.1 compat 2023-02-04 15:26:38 -08:00
PatTheMav 24a123119a obs-scripting: Fix issues between runtime and compile-time versions
Calling `PyEval_InitThreads` has been deprecated in Python 3.7 and the
function itself will be removed in Python 3.11. The current check
guards this function behind a version check that only happens at compile
time.

This in turn leads to crashes when run on Python 3.6, as the necessary
initialization for `PyEval_ReleaseThread` did not take place.

This commit ensures the manual initialization takes place based on the
runtime version of Python and avoids loading the associated symbols
on Python 3.9 or later.
2022-08-02 19:36:50 -04:00
PatTheMav ab21c7e5b0 obs-scripting: Add support for multiple Python 3 versions
This changes the way obs-scripting looks for and loads an available
Python 3 library. It tries to find a best possible version (starting
with Python 3.10) down to and including Python 3.6 by existing file
naming conventions and loads the most recent variant it can find.

User specified search path is either a Python installation directory
(Windows), or a Framework directory containing `Python.framework`
(macOS). The dll or dylib names are composed automatically.
The Python home path is also composed automatically on macOS (where
it has to point inside the Framework directory).
2022-07-21 12:16:36 -04:00
tytan652 ba6f9f3f46 obs-scripting: Replace OBS_UNUSED with UNUSED_PARAMETER
OBS_UNUSED is not portable to MSVC.
2022-07-20 08:22:08 +02:00
PatTheMav 8d0131c519 obs-scripting: Fix macro redefinition warning
In Python 3.9+, `PyCFunction_New` and `PyCFunction_NewEx` are themselves
macros around `PyMethod_New`. To fix the warning, both macros need to
be untouched for those Python versions, instead the actual function
`PyMethod_New` needs to be imported and aliased.

This commit:

- Adds the import of the `PyCMethod_New` symbol
- Adds the function definition for `Import_PyCMethod_New`
- Adds the `PyCMethod_New` function alias
2022-05-14 16:10:11 -07:00
PatTheMav a0923c9b6e obs-scripting: Fix loading of scripting libraries with runtime lookup
macOS uses runtime lookup for symbols in obs-scripting. While this guard
fixes a compiler warning, it also leads to the `_PyCMethod_New` symbol
being undefined.

In turn any library linking with obs-scripting will then fail to load
because of that undefined symbol. Removing this guard fixes that issue.
2022-05-14 16:10:11 -07:00
PatTheMav 4c1687901e obs-scripting: Fix compiler warnings 2022-05-04 12:09:04 -04:00
Scratch a78558b46a obs-scripting: add transition duration functions 2021-10-15 16:50:59 -07:00
PatTheMav ecdc81ba0f obs-scripting: Add Py 3.8+ C-API changes
Closes obsproject/obs-studio#3689
2021-01-27 11:33:34 -08:00
comex 849d5462ad obs-scripting: Add missing Python imports
Add PyDict_New and PyTuple_New to obs-scripting-python-import.[ch];
these functions are used by SWIG's generated code when I build OBS on
macOS with SWIG 4.0.1.
2020-03-08 18:35:35 -07:00
jp9000 f53df7da64 clang-format: Apply formatting
Code submissions have continually suffered from formatting
inconsistencies that constantly have to be addressed.  Using
clang-format simplifies this by making code formatting more consistent,
and allows automation of the code formatting so that maintainers can
focus more on the code itself instead of code formatting.
2019-06-23 23:49:10 -07:00
jp9000 9eabfdbf1e deps/obs-scripting: Add scripting support
Allows Lua/Python scripting support.
2018-01-04 11:37:42 -08:00