Commit graph

115 commits

Author SHA1 Message Date
tytan652 9fa23c8cca obs-scripting: Remove Python version upper limit on Linux
Also removes it for FreeBSD and OpenBSD
2024-05-03 15:31:20 -04:00
PatTheMav e87a5c3691 obs-scripting: Update Linux slice for CMake build framework 3.0 2024-04-13 23:48:38 -04:00
Exeldro a0e666d8e3 deps/obs-scripting: Fix lua tick crash 2024-02-03 17:08:53 -06:00
derrod 538ea46e5a deps/obs-scripting: Replace circlebuf with deque 2024-01-16 16:45:09 +01:00
PatTheMav aa137f0766 deps: Update CMake target source lists with alphabetic sorting
Also manually updates some CMake script files to make code more
readable.
2023-12-19 17:59:44 -05:00
PatTheMav c665308fbf obs-scripting: Disable Python 3.11 support on Windows
Inlined functions in Python's header files result in unresolvable
symbols at link time when building in Debug config on Windows.

This downgrades the upper limit on Windows to 3.10 again until a proper
fix can be found.

macOS is unaffected because it can link binaries with dynamic runtime
lookup.
2023-12-09 19:37:18 +01:00
PatTheMav 6164184b4a obs-scripting: Add missing function import for PyType_IsSubtype 2023-12-09 19:37:18 +01:00
PatTheMav cab950c23b obs-scripting: Fix Python version detection on Windows
Prior code would not only iterate over possible versioned python DLL
names, but also replace possible named subdirectories contained in the
path string.

This commit changes the same code to only change the filename and leave
the path prefix intact.
2023-12-09 19:37:18 +01:00
PatTheMav 95cab7178e obs-scripting: Add Python 3.11 support for Windows and macOS 2023-11-11 17:45:55 -06:00
PatTheMav 24073568e5 obs-scripting: Fix Sparkle delta updates by disabling bytecode caching
Python automatically creates bytecode caches which end up inside the
application bundle of OBS Studio on macOS. These directories will lead
to a hash mismatch when Sparkle attempts to apply a delta update (to
ensure that the patch can be applied).

As the added directories will make the hash check fail, having a valid
Python framework configured in OBS Studio (even without any script
added) will thus prevent Sparkle from using delta updates.
2023-11-04 18:26:50 -05:00
Smartkin e0bc8a8c9c obs-scripting: Search native libraries in Lua script's location 2023-10-14 19:04:00 -05:00
Ryan Foster 41a915db9e deps: Update CMake minimum to 3.22
Since Ubuntu 22.04 is now our minimum supported Ubuntu version, and it
has CMake 3.22, let's make CMake 3.22 the minimum CMake version.
2023-08-05 16:45:46 -07:00
Penwywern a542d51e59 obs-scripting: Fix python save callback Py_BuildValue
Py_BuildValue doesn't directly accept C bools.
This fixes the callback by passing instead a Py_Bool object built from
the C bool.
2023-06-29 06:02:22 -07:00
Exeldro 90c55e03fe obs-scripting: Add config file functions 2023-06-22 00:54:47 -07:00
PatTheMav 04f8039b3e obs-scripting: Silence clang warnings about unreachable code
Source code is generated by Swig, so we just silence the warning.
2023-06-16 14:12:58 -04:00
Ilya Chernikov a609cfb2f0 deps/obs-scripting: Fix crash removing callbacks in script_unload
Signed-off-by: Ilya Chernikov <chernikov.i123@gmail.com>
2023-06-10 14:38:14 -07:00
Lain 106c7aa61f Update copyrights/names 2023-05-20 01:31:18 -07:00
PatTheMav 69a0cd2910 obs-scripting: Replace macro with plain C code
Instead of using a non-debuggable macro function, keep function
references and desired function names in a static array that can then
be iterated over to add desired functions.

This allows for proper debugging as well as makes the combination of
function and function name more explicit.
2023-05-13 17:00:30 -07:00
derrod 82137de0bb deps/obs-scripting: Set file/chunk name when loading lua scripts 2023-05-13 16:45:47 -07:00
Exeldro f75fa626d8 obs-scripting: Fix loading lua utf8 path 2023-04-22 16:22:33 -07:00
PatTheMav 6e07b86729 cmake: Remove EXCLUDE_FROM_ALL directive from interface libraries 2023-04-04 17:27:54 +00:00
PatTheMav 349372b3b3 cmake: Add changes for CMake build framework 3.0
New code path only taken if OBS_CMAKE_VERSION is set to 3.0.0 or
greater, old functionality remains unchanged.
2023-03-26 18:20:38 -04:00
Ryan Foster 3fe241e95f obs-scripting: Enable Python 3.11 2023-03-26 10:27:52 +11:00
PatTheMav 318db2842a obs-scripting: Add PyType_Modified import for Swig 4.1.1 compat 2023-02-04 15:26:38 -08:00
tytan652 e13e0937a2 obs-scripting: Fix compilation warnings on Clang and GCC
* Fix unused-parameter when Python is disabled
* Calm PySys_SetArgv deprecation since Python 3.11
2023-01-28 23:20:41 -08:00
tytan652 f147be2d68 obslua: Ignore maybe-unitialized warning with SWIG and GCC
Only with SWIG version earlier than 4.1 because it is fixed upstream.
fa2f9dc5da
2023-01-19 13:08:46 -05:00
tytan652 c6a8b03719 obs-scripting: Fix compilation warnings on Clang and GCC
- Fix Python deprecation warnings
- Fix maybe uninitialized warning (GCC only)
2023-01-19 13:08:46 -05:00
PatTheMav bd12a3e919
deps: Replace invocations of sprintf with snprintf
Fixes deprecation warnings in Xcode 14/clang on macOS and reduces
chance of buffer overflows.
2022-11-11 19:51:27 +01:00
PatTheMav d9f89be35a obs-scripting: Add obs_sceneitem_group_enum_items function call
Adds function call to enumerate over items contained in a source group.
2022-10-11 15:19:41 +02:00
Patrick Heyer 49b4ba8ed9 obs-scripting: Fix block comment formatting
Co-authored-by: Norihiro Kamae <norihiro@nagater.net>
2022-10-10 02:07:02 +02:00
PatTheMav 0af8bdb350 obs-scripting: Fix script state variable being reset by tick callback
When loading a new Python script, the GIL might be released while
importing the module, allowing the tick to run and change and reset the
cur_python_script state variable. Use the busy_script variable to save
and restore the value if not null.
2022-10-10 02:07:02 +02:00
Matt Gajownik 77d810148d obs-scripting: Enable Python autodoc
This provides more useful information in auto-complete, complete with
parameter summaries.

Example:

"""
    obs_properties_add_path(props, name, description, type, filter, default_path) -> obs_property_t *

    Parameters
    ----------
    props: obs_properties_t *
    name: char const *
    description: char const *
    type: enum enum obs_path_type
    filter: char const *
    default_path: char const *

"""
2022-10-01 16:16:45 -07:00
Matt Gajownik 0c7abb7fca obs-scripting: Re-enable Python annotations
The default for this setting was changed in SWIG 4.
For more info see https://github.com/swig/swig/commit/2072ae19c
2022-10-01 16:16:45 -07:00
Exeldro ddff584b46 obs-scripting: Fix compile when python is not found 2022-10-01 05:26:21 -07:00
Matt Gajownik 1b2fc73021 frontend-tools: Display Python version in UI 2022-09-23 12:08:11 +10:00
PatTheMav 76c782bcdc deps: Fix broken prefix for obspython binary module on Linux 2022-09-17 16:11:31 -07:00
tytan652 1272209710 obs-scripting: Fix SWIG flags for non-macOS POSIX 2022-08-08 15:00:09 +02: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
gxalpha ca470b2d53 deps/obs-scripting: Ignore base_set_crash_handler 2022-07-27 12:05:16 -04:00
Kurt Kartaltepe 57c9844f15 v4l2,scripting: Add more thread names
This sets some thread names for the scripting backend's defer thread and
the v4l2 udev thread.
2022-07-24 09:21:58 +10: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
PatTheMav 47b3ff5e64 obs-scripting: Switch swig to stable ABI usage 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 e27f90fa5a obs-scripting: Fix crashes introduced by Swig update to 4.1.0
Fixes issues introduced by https://github.com/swig/swig/pull/2238. As
obs-scripting is not compatible with the SWIGPYTHON_BUILTIN, obspython
needs to disable this feature.
2022-07-13 16:50:09 -04:00
jpark37 5e3c824801 obs-scripting: Suppress long volatile warning 2022-07-11 22:07:10 -07:00
PatTheMav 64efcd155d obs-scripting: Fix swig runtime header generation for macOS
Due to swig using a hardcoded swig library path in self-compiled
variants, we need to pass our custom swig library path with every
invocation of swig on macOS.

CMake's `add_custom_command` function does _not_ inherit the environment
variables used during configuration, hence why it needs to be passed
explicitly on invocation.

Usage of CMake's "-E env" command module should allow for cross-platform
compatible invocation.
2022-07-07 14:19:23 -04:00
gxalpha e1776d872a deps/obs-scripting: Log script load/unload 2022-07-02 16:35:20 -07:00
PatTheMav 29759ef8fb obs-scripting: Fix missing frontend bindings for Python
The obspython.i file requires `ENABLE_UI` to be defined for the swig
compiler to pull in the actual obs-frontend-api header. If this is not
the case, swig will not discover the required methods and ENUMs and
in turn will not make those available in the scripting environment.
2022-05-28 16:23:14 -07:00
PatTheMav 893d3ce218 obs-scripting: Fix missing frontend bindings for Lua
The obslua.i file requires `ENABLE_UI` to be defined for the swig
compiler to pull in the actual obs-frontend-api header. If this is not
the case, swig will not discover the required methods and ENUMs and
in turn will not make those available in the scripting environment.
2022-05-28 16:23:14 -07: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