Skip to content

Commit bcb01a4

Browse files
committed
More tweaks
1 parent ad75aaf commit bcb01a4

File tree

6 files changed

+93
-65
lines changed

6 files changed

+93
-65
lines changed

modules/yup_python/modules/yup_YupMain_module.cpp

Lines changed: 36 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -20,48 +20,40 @@
2020
*/
2121

2222
#include "../utilities/yup_PyBind11Includes.h"
23-
#include "../bindings/yup_YupCore_bindings.h"
24-
25-
#if YUP_MODULE_AVAILABLE_juce_events
26-
#include "ScriptJuceEventsBindings.h"
27-
#endif
28-
29-
#if YUP_MODULE_AVAILABLE_juce_data_structures
30-
#include "ScriptJuceDataStructuresBindings.h"
31-
#endif
23+
#include "../utilities/yup_CrashHandling.h"
3224

33-
#if YUP_MODULE_AVAILABLE_juce_graphics
34-
#include "ScriptJuceGraphicsBindings.h"
35-
#endif
25+
#include "../bindings/yup_YupCore_bindings.h"
3626

37-
#if YUP_MODULE_AVAILABLE_juce_gui_basics
38-
#include "ScriptJuceGuiBasicsBindings.h"
39-
#include "ScriptJuceGuiEntryPointsBindings.h"
27+
/*
28+
#if YUP_MODULE_AVAILABLE_yup_events
29+
#include "yup_YupEvents_bindings.h"
4030
#endif
4131
42-
#if YUP_MODULE_AVAILABLE_juce_gui_extra
43-
#include "ScriptJuceGuiExtraBindings.h"
32+
#if YUP_MODULE_AVAILABLE_yup_data_model
33+
#include "yup_YupDataModel_bindings.h"
4434
#endif
4535
46-
#if YUP_MODULE_AVAILABLE_juce_audio_basics
47-
#include "ScriptJuceAudioBasicsBindings.h"
36+
#if YUP_MODULE_AVAILABLE_yup_graphics
37+
#include "yup_YupGraphics_bindings.h"
4838
#endif
4939
50-
#if YUP_MODULE_AVAILABLE_juce_audio_devices
51-
#include "ScriptJuceAudioDevicesBindings.h"
40+
#if YUP_MODULE_AVAILABLE_yup_gui
41+
#include "yup_YupGui_bindings.h"
42+
#include "yup_YupGuiEntryPoints_bindings.h"
5243
#endif
5344
54-
#if YUP_MODULE_AVAILABLE_juce_audio_processors
55-
#include "ScriptJuceAudioProcessorsBindings.h"
45+
#if YUP_MODULE_AVAILABLE_yup_audio_basics
46+
#include "yup_YupAudioBasics_bindings.h"
5647
#endif
5748
58-
#if YUP_MODULE_AVAILABLE_juce_audio_formats
59-
#include "ScriptJuceAudioFormatsBindings.h"
49+
#if YUP_MODULE_AVAILABLE_yup_audio_devices
50+
#include "yup_YupAudioDevices_bindings.h"
6051
#endif
6152
62-
#if YUP_MODULE_AVAILABLE_juce_audio_utils
63-
#include "ScriptJuceAudioUtilsBindings.h"
53+
#if YUP_MODULE_AVAILABLE_yup_audio_processors
54+
#include "yup_YupAudioProcessors_bindings.h"
6455
#endif
56+
*/
6557

6658
//==============================================================================
6759

@@ -81,44 +73,34 @@ PYBIND11_MODULE (YUP_PYTHON_MODULE_NAME, m)
8173

8274
yup::Bindings::registerYupCoreBindings (m);
8375

84-
#if YUP_MODULE_AVAILABLE_juce_events
85-
yup::Bindings::registerJuceEventsBindings (m);
86-
#endif
87-
88-
#if YUP_MODULE_AVAILABLE_juce_data_structures
89-
yup::Bindings::registerJuceDataStructuresBindings (m);
90-
#endif
91-
92-
#if YUP_MODULE_AVAILABLE_juce_graphics
93-
yup::Bindings::registerJuceGraphicsBindings (m);
94-
#endif
95-
96-
#if YUP_MODULE_AVAILABLE_juce_gui_basics
97-
yup::Bindings::registerJuceGuiBasicsBindings (m);
98-
yup::Bindings::registerJuceGuiEntryPointsBindings (m);
76+
/*
77+
#if YUP_MODULE_AVAILABLE_yup_events
78+
yup::Bindings::registerYupEventsBindings (m);
9979
#endif
10080
101-
#if YUP_MODULE_AVAILABLE_juce_gui_extra
102-
yup::Bindings::registerJuceGuiExtraBindings (m);
81+
#if YUP_MODULE_AVAILABLE_yup_data_model
82+
yup::Bindings::registerYupDataModelBindings (m);
10383
#endif
10484
105-
#if YUP_MODULE_AVAILABLE_juce_audio_basics
106-
yup::Bindings::registerJuceAudioBasicsBindings (m);
85+
#if YUP_MODULE_AVAILABLE_yup_graphics
86+
yup::Bindings::registerYupGraphicsBindings (m);
10787
#endif
10888
109-
#if YUP_MODULE_AVAILABLE_juce_audio_devices
110-
yup::Bindings::registerJuceAudioDevicesBindings (m);
89+
#if YUP_MODULE_AVAILABLE_yup_gui
90+
yup::Bindings::registerYupGuiBindings (m);
91+
yup::Bindings::registerYupGuiEntryPointsBindings (m);
11192
#endif
11293
113-
#if YUP_MODULE_AVAILABLE_juce_audio_processors
114-
yup::Bindings::registerJuceAudioProcessorsBindings (m);
94+
#if YUP_MODULE_AVAILABLE_yup_audio_basics
95+
yup::Bindings::registerYupAudioBasicsBindings (m);
11596
#endif
11697
117-
#if YUP_MODULE_AVAILABLE_juce_audio_formats
118-
yup::Bindings::registerJuceAudioFormatsBindings (m);
98+
#if YUP_MODULE_AVAILABLE_yup_audio_devices
99+
yup::Bindings::registerYupAudioDevicesBindings (m);
119100
#endif
120101
121-
#if YUP_MODULE_AVAILABLE_juce_audio_utils
122-
yup::Bindings::registerJuceAudioUtilsBindings (m);
102+
#if YUP_MODULE_AVAILABLE_yup_audio_processors
103+
yup::Bindings::registerYupAudioProcessorsBindings (m);
123104
#endif
105+
*/
124106
}

modules/yup_python/scripting/yup_ScriptEngine.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,13 @@ ScriptEngine::~ScriptEngine()
153153

154154
//==============================================================================
155155

156+
String ScriptEngine::getScriptingVersion() const
157+
{
158+
String version;
159+
version << PY_MAJOR_VERSION << "." << PY_MINOR_VERSION << "." << PY_MICRO_VERSION;
160+
return version;
161+
}
162+
156163
File ScriptEngine::getScriptingHome() const
157164
{
158165
if (currentConfig != nullptr)

modules/yup_python/scripting/yup_ScriptEngine.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ class YUP_API ScriptEngine
103103

104104
//==============================================================================
105105

106+
/** Get the version of the scripting engine.
107+
108+
This returns the version of python in form of major.minor.micro (3.13.5).
109+
110+
@return The version of the scripting engine.
111+
*/
112+
String getScriptingVersion() const;
113+
106114
/** Get the scripting home directory.
107115
108116
When the scripting home is prepared using the prepareScriptingHome method,

modules/yup_python/yup_python.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@
3838

3939
//==============================================================================
4040

41-
//#if YUP_MODULE_AVAILABLE_yup_core
42-
#include "bindings/yup_YupCore_bindings.cpp"
43-
//#endif
44-
45-
//==============================================================================
46-
4741
#include "modules/yup_YupMain_module.cpp"
4842
#include "modules/yup_YupInternal_module.cpp"
4943

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
==============================================================================
3+
4+
This file is part of the YUP library.
5+
Copyright (c) 2025 - [email protected]
6+
7+
YUP is an open source library subject to open-source licensing.
8+
9+
The code included in this file is provided under the terms of the ISC license
10+
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
11+
to use, copy, modify, and/or distribute this software for any purpose with or
12+
without fee is hereby granted provided that the above copyright notice and
13+
this permission notice appear in all copies.
14+
15+
YUP IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
16+
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
17+
DISCLAIMED.
18+
19+
==============================================================================
20+
*/
21+
22+
#include "bindings/yup_YupCore_bindings.cpp"

tests/yup_python/yup_ScriptPython.cpp

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,20 @@ class ScriptPythonTest : public ::testing::Test
6161

6262
TEST_F (ScriptPythonTest, RunPythonTests)
6363
{
64+
auto currentWorkingDirectory = File::getCurrentWorkingDirectory();
65+
auto restoreWorkingDirectoryAtScopeExit = ErasedScopeGuard ([&]
66+
{
67+
currentWorkingDirectory.setAsCurrentWorkingDirectory();
68+
});
69+
70+
auto baseFolder = getPytestTestFolder().getParentDirectory();
71+
baseFolder.setAsCurrentWorkingDirectory();
72+
6473
auto script = String (R"(
6574
import importlib
75+
import sys
76+
77+
sys.path.append('{{root_path}}/lib/python{{version}}/site-packages')
6678
6779
package = 'pytest'
6880
@@ -74,11 +86,14 @@ TEST_F (ScriptPythonTest, RunPythonTests)
7486
finally:
7587
globals()[package] = importlib.import_module(package)
7688
77-
pytest.main(['-x', '{{test_path}}', '-vv'])
78-
)")
79-
.dedentLines()
80-
.replace ("{{root_path}}", engine->getScriptingHome().getFullPathName())
81-
.replace ("{{test_path}}", getPytestTestFolder().getFullPathName());
89+
pytest.main(['-x', '{{test_path}}'])
90+
)");
91+
92+
script = script
93+
.dedentLines()
94+
.replace ("{{version}}", engine->getScriptingVersion().upToLastOccurrenceOf (".", false, false))
95+
.replace ("{{root_path}}", engine->getScriptingHome().getFullPathName())
96+
.replace ("{{test_path}}", getPytestTestFolder().getFullPathName());
8297

8398
auto result = engine->runScript (script);
8499

0 commit comments

Comments
 (0)