Skip to content

Commit 003b441

Browse files
committed
further adaptations for python312 -> python314
1 parent 257b05d commit 003b441

7 files changed

Lines changed: 79 additions & 66 deletions

File tree

PythonScript.Tests/PythonScript.Tests.vcxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@
208208
</AdditionalLibraryDirectories>
209209
</Link>
210210
<PostBuildEvent>
211-
<Command>copy $(PythonBase)\python312.dll $(TargetDir)
211+
<Command>copy $(PythonBase)\python314.dll $(TargetDir)
212212
$(TargetDir)$(TargetFileName)
213213
</Command>
214214
</PostBuildEvent>
@@ -234,7 +234,7 @@
234234
</AdditionalLibraryDirectories>
235235
</Link>
236236
<PostBuildEvent>
237-
<Command>copy $(PythonBaseX64)\python312.dll $(TargetDir)
237+
<Command>copy $(PythonBaseX64)\python314.dll $(TargetDir)
238238
$(TargetDir)$(TargetFileName)
239239
</Command>
240240
</PostBuildEvent>
@@ -260,7 +260,7 @@
260260
</AdditionalLibraryDirectories>
261261
</Link>
262262
<PostBuildEvent>
263-
<Command>copy $(PythonBaseARM64)\python312.dll $(TargetDir)
263+
<Command>copy $(PythonBaseARM64)\python314.dll $(TargetDir)
264264
$(TargetDir)$(TargetFileName)
265265
</Command>
266266
</PostBuildEvent>
@@ -286,7 +286,7 @@
286286
</AdditionalLibraryDirectories>
287287
</Link>
288288
<PostBuildEvent>
289-
<Command>copy $(PythonBase)\python312.dll $(TargetDir)
289+
<Command>copy $(PythonBase)\python314.dll $(TargetDir)
290290
$(TargetDir)$(TargetFileName)
291291
</Command>
292292
</PostBuildEvent>
@@ -312,7 +312,7 @@
312312
</AdditionalLibraryDirectories>
313313
</Link>
314314
<PostBuildEvent>
315-
<Command>copy $(PythonBaseX64)\python312.dll $(TargetDir)
315+
<Command>copy $(PythonBaseX64)\python314.dll $(TargetDir)
316316
$(TargetDir)$(TargetFileName)
317317
</Command>
318318
</PostBuildEvent>
@@ -338,7 +338,7 @@
338338
</AdditionalLibraryDirectories>
339339
</Link>
340340
<PostBuildEvent>
341-
<Command>copy $(PythonBaseARM64)\python312.dll $(TargetDir)
341+
<Command>copy $(PythonBaseARM64)\python314.dll $(TargetDir)
342342
$(TargetDir)$(TargetFileName)
343343
</Command>
344344
</PostBuildEvent>

PythonScript/project/PythonScript.vcxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ xcopy $(ProjectDir)..\python_tests\*.* "e:\notepadtest\unicode\plugins\config\py
421421
<Link>
422422
<SubSystem>Windows</SubSystem>
423423
<GenerateDebugInformation>true</GenerateDebugInformation>
424-
<AdditionalDependencies>python312.lib;NppPlugin.lib;shlwapi.lib;comctl32.lib;htmlhelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
424+
<AdditionalDependencies>python314.lib;NppPlugin.lib;shlwapi.lib;comctl32.lib;htmlhelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
425425
<AdditionalLibraryDirectories>$(HtmlHelpBase)\lib</AdditionalLibraryDirectories>
426426
</Link>
427427
<PostBuildEvent>
@@ -444,7 +444,7 @@ xcopy $(ProjectDir)..\python_tests\*.* "e:\notepadtest\unicode\plugins\config\py
444444
<Link>
445445
<SubSystem>Windows</SubSystem>
446446
<GenerateDebugInformation>true</GenerateDebugInformation>
447-
<AdditionalDependencies>python312.lib;NppPlugin.lib;shlwapi.lib;comctl32.lib;htmlhelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
447+
<AdditionalDependencies>python314.lib;NppPlugin.lib;shlwapi.lib;comctl32.lib;htmlhelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
448448
<AdditionalLibraryDirectories>$(HtmlHelpBase)\lib</AdditionalLibraryDirectories>
449449
</Link>
450450
<PostBuildEvent>
@@ -467,7 +467,7 @@ xcopy $(ProjectDir)..\python_tests\*.* "e:\notepadtest\unicode\plugins\config\py
467467
<Link>
468468
<SubSystem>Windows</SubSystem>
469469
<GenerateDebugInformation>true</GenerateDebugInformation>
470-
<AdditionalDependencies>python312.lib;NppPlugin.lib;shlwapi.lib;comctl32.lib;htmlhelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
470+
<AdditionalDependencies>python314.lib;NppPlugin.lib;shlwapi.lib;comctl32.lib;htmlhelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
471471
<AdditionalLibraryDirectories>$(HtmlHelpBase)\lib</AdditionalLibraryDirectories>
472472
</Link>
473473
<PostBuildEvent>
@@ -493,7 +493,7 @@ xcopy $(ProjectDir)..\python_tests\*.* "e:\notepadtest\unicode\plugins\config\py
493493
<GenerateDebugInformation>true</GenerateDebugInformation>
494494
<EnableCOMDATFolding>true</EnableCOMDATFolding>
495495
<OptimizeReferences>true</OptimizeReferences>
496-
<AdditionalDependencies>python312.lib;NppPlugin.lib;shlwapi.lib;comctl32.lib;htmlhelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
496+
<AdditionalDependencies>python314.lib;NppPlugin.lib;shlwapi.lib;comctl32.lib;htmlhelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
497497
<AdditionalLibraryDirectories>$(HtmlHelpBase)\lib</AdditionalLibraryDirectories>
498498
</Link>
499499
</ItemDefinitionGroup>
@@ -516,7 +516,7 @@ xcopy $(ProjectDir)..\python_tests\*.* "e:\notepadtest\unicode\plugins\config\py
516516
<GenerateDebugInformation>true</GenerateDebugInformation>
517517
<EnableCOMDATFolding>true</EnableCOMDATFolding>
518518
<OptimizeReferences>true</OptimizeReferences>
519-
<AdditionalDependencies>python312.lib;NppPlugin.lib;shlwapi.lib;comctl32.lib;htmlhelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
519+
<AdditionalDependencies>python314.lib;NppPlugin.lib;shlwapi.lib;comctl32.lib;htmlhelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
520520
<AdditionalLibraryDirectories>$(HtmlHelpBase)\lib</AdditionalLibraryDirectories>
521521
</Link>
522522
</ItemDefinitionGroup>
@@ -539,7 +539,7 @@ xcopy $(ProjectDir)..\python_tests\*.* "e:\notepadtest\unicode\plugins\config\py
539539
<GenerateDebugInformation>true</GenerateDebugInformation>
540540
<EnableCOMDATFolding>true</EnableCOMDATFolding>
541541
<OptimizeReferences>true</OptimizeReferences>
542-
<AdditionalDependencies>python312.lib;NppPlugin.lib;shlwapi.lib;comctl32.lib;htmlhelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
542+
<AdditionalDependencies>python314.lib;NppPlugin.lib;shlwapi.lib;comctl32.lib;htmlhelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
543543
<AdditionalLibraryDirectories>$(HtmlHelpBase)\lib</AdditionalLibraryDirectories>
544544
</Link>
545545
</ItemDefinitionGroup>

PythonScript/src/GILManager.h

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,86 +5,86 @@
55

66
namespace NppPythonScript
77
{
8-
/*
8+
/*
99
10-
This whole schenanigans is necessary, as you can't call PyGILState_Ensure() from a thread that already has the GIL.
10+
This whole schenanigans is necessary, as you can't call PyGILState_Ensure() from a thread that already has the GIL.
1111
12-
For the ScintillaWrapper (specifically, but not exclusively), it's tricky to impossible to tell if we need to release the GIL. If we're running on the
13-
Python worker thread, and we make a call to Scintilla, that triggers a callback, we need to give it up (in order that the callback can run). The callback
14-
identification must be performed with the GIL, so it would block if we didn't give it up. (There's an optimisation that if no callbacks are registered, then it
15-
doesn't check, and doesn't acquire the GIL)
12+
For the ScintillaWrapper (specifically, but not exclusively), it's tricky to impossible to tell if we need to release the GIL. If we're running on the
13+
Python worker thread, and we make a call to Scintilla, that triggers a callback, we need to give it up (in order that the callback can run). The callback
14+
identification must be performed with the GIL, so it would block if we didn't give it up. (There's an optimisation that if no callbacks are registered, then it
15+
doesn't check, and doesn't acquire the GIL)
1616
1717
However, if we're being called from the replace function, and therefore the main thread, we probably don't even have the GIL to give up.
1818
1919
With the different threads running the different callbacks, and python code running on a thread (*generally* - see the editor.replace() suite)
20-
it has become impossible to manage manually (read: the Wrong Way To Do It(tm)). These objects manage the GIL, and provide a easy, safe way to ensure
20+
it has become impossible to manage manually (read: the Wrong Way To Do It(tm)). These objects manage the GIL, and provide a easy, safe way to ensure
2121
you have the GIL when you need it, and give it up correctly whatever happens in the mean time.
2222
23-
The doIHaveTheGIL() function is taken from Python 3.4.0, Issue #17522. An extra workaround is included to make it work when Py_DEBUG is defined.
24-
- see note below where PyThreadState_GET is redefined.
25-
*/
23+
The doIHaveTheGIL() function is taken from Python 3.4.0, Issue #17522. An extra workaround is included to make it work when Py_DEBUG is defined.
24+
- see note below where PyThreadState_GET is redefined.
25+
*/
2626

2727

2828
#ifdef Py_DEBUG
29-
/* For Py_DEBUG, PyThreadState_GET() is redefined to PyThreadState_Get(), which checks that the current ThreadState is not null
30-
* We "undo" that define here, as we need to get the current threadstate without checking if it's not set
31-
*/
29+
/* For Py_DEBUG, PyThreadState_GET() is redefined to PyThreadState_Get(), which checks that the current ThreadState is not null
30+
* We "undo" that define here, as we need to get the current threadstate without checking if it's not set
31+
*/
3232
#undef PyThreadState_GET
3333
#define PyThreadState_GET() (_PyThreadState_Current)
3434
#endif
3535

36-
class GILHandler
36+
class GILHandler
3737
{
3838
protected:
3939
static bool doIHaveTheGIL()
4040
{
4141
//TODO check if PyThreadState_GET should be used or something else
42-
PyThreadState* thisThreadState = PyGILState_GetThisThreadState();
43-
return (thisThreadState && thisThreadState == _PyThreadState_UncheckedGet());
42+
PyThreadState* thisThreadState = PyGILState_GetThisThreadState();
43+
return (thisThreadState && thisThreadState == PyThreadState_GetUnchecked());
4444
}
4545

4646
};
4747

4848

49-
/* GILLock holds the GIL whilst it exists. If you already have the GIL, it will do nothing.
50-
* If however, you didn't already have the lock, it will obtain the lock on construction,
51-
* and release it back upon destruction.
52-
*/
53-
class GILLock : public GILHandler
49+
/* GILLock holds the GIL whilst it exists. If you already have the GIL, it will do nothing.
50+
* If however, you didn't already have the lock, it will obtain the lock on construction,
51+
* and release it back upon destruction.
52+
*/
53+
class GILLock : public GILHandler
5454
{
5555
public:
5656
GILLock();
5757
virtual ~GILLock();
5858

5959
private:
60-
GILLock(const GILLock&); /* disable copying */
61-
GILLock& operator = (const GILLock&); /* disable assignment */
60+
GILLock(const GILLock&) = delete; /* disable copying */
61+
GILLock& operator = (const GILLock&) = delete; /* disable assignment */
6262
PyGILState_STATE m_state;
6363
bool m_hasLock;
6464
};
6565

6666

67-
/* GILRelease will release the GIL if you have it for as long as the object exists.
68-
* On destruction it will reacquire the lock. You can reacquire the GIL sooner than
69-
* destruction by calling reacquire(). This makes the destructor a no-op.
70-
*/
71-
class GILRelease : public GILHandler
67+
/* GILRelease will release the GIL if you have it for as long as the object exists.
68+
* On destruction it will reacquire the lock. You can reacquire the GIL sooner than
69+
* destruction by calling reacquire(). This makes the destructor a no-op.
70+
*/
71+
class GILRelease : public GILHandler
7272
{
7373
public:
74-
GILRelease();
75-
virtual ~GILRelease();
74+
GILRelease();
75+
virtual ~GILRelease();
7676

77-
/** Reacquire the GIL after releasing it
78-
* This is performed automatically on destruction of this object, but if
79-
* you need to reacquire the lock before the object is disposed, then use this method
80-
* After usage of this method, the destructor becomes a no-op
81-
*/
82-
void reacquire();
77+
/** Reacquire the GIL after releasing it
78+
* This is performed automatically on destruction of this object, but if
79+
* you need to reacquire the lock before the object is disposed, then use this method
80+
* After usage of this method, the destructor becomes a no-op
81+
*/
82+
void reacquire();
8383

8484
private:
85-
GILRelease(const GILRelease&);
86-
GILRelease& operator = (const GILRelease&); /* disable assignment */
87-
PyThreadState *m_threadState;
85+
GILRelease(const GILRelease&);
86+
GILRelease& operator = (const GILRelease&); /* disable assignment */
87+
PyThreadState *m_threadState;
8888
bool m_lockReleased;
8989
};
9090

installer/PythonScript.wxs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<Feature Id="FT_PythonScript" Title="PythonScript plugin" AllowAdvertise="no">
2424
<ComponentRef Id="C_startup.py" />
2525
<ComponentRef Id="C_pythonscript.dll" />
26-
<ComponentRef Id="C_python312.dll" />
26+
<ComponentRef Id="C_python314.dll" />
2727
<ComponentGroupRef Id="CG_PythonLib" />
2828
<ComponentGroupRef Id="CG_PythonLibDll" />
2929
</Feature>
@@ -95,9 +95,9 @@
9595
<RemoveFile Id="Remove_F_pythonscript.dll" Name="PythonScript.dll" On="install" />
9696
<File Id="F_pythonscript.dll" Name="PythonScript.dll" Source="$(var.baseDir)\$(var.variantDir)\Release\PythonScript.dll" />
9797
</Component>
98-
<Component Id="C_python312.dll">
99-
<RemoveFile Id="Remove_F_python312.dll" Name="python312.dll" On="install" />
100-
<File Id="F_python312.dll" Name="python312.dll" Source="$(var.pythonDir)\python312.dll" />
98+
<Component Id="C_python314.dll">
99+
<RemoveFile Id="Remove_F_python314.dll" Name="python314.dll" On="install" />
100+
<File Id="F_python314.dll" Name="python314.dll" Source="$(var.pythonDir)\python314.dll" />
101101
</Component>
102102
</Directory>
103103
</Directory>

installer/buildInstaller.bat

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
@echo off
22

33
:: Set PYTHONBUILDDIR to the root of your python directory
4-
:: Or, if you just want to build the installer for PythonScript with an existing python312.dll,
5-
:: set PYTHONBUILDDIR to a path containing a directory, which contains the python312.dll
4+
:: Or, if you just want to build the installer for PythonScript with an existing python314.dll,
5+
:: set PYTHONBUILDDIR to a path containing a directory, which contains the python314.dll
66

77

88
SET ORIGINALDIR=%CD%
@@ -27,13 +27,19 @@ IF "%1"=="x64" SET INST_TEMP_DIR=temp64
2727
IF "%1"=="x64" SET NAME_ADDON=_x64
2828
IF "%1"=="x64" SET MSI_ARCH=x64
2929

30+
IF "%1"=="arm64" SET PYTHONBUILDDIR=%PYTHONBUILDDIR_ARM64%
31+
IF "%1"=="arm64" SET PYTHONSCRIPTDLLDIR=arm64
32+
IF "%1"=="arm64" SET INST_TEMP_DIR=temparm64
33+
IF "%1"=="arm64" SET NAME_ADDON=_arm64
34+
IF "%1"=="arm64" SET MSI_ARCH=arm64
35+
3036
IF NOT EXIST "%PYTHONBUILDDIR%\python.exe" (
31-
echo Your PYTHONBUILDDIR in buildPaths.bat does not contain python.exe. Please set PYTHONBUILDDIR to the root of a built Python 3.12
37+
echo Your PYTHONBUILDDIR in buildPaths.bat does not contain python.exe. Please set PYTHONBUILDDIR to the root of a built Python 3.14
3238
goto error
3339
)
3440

35-
IF NOT EXIST "%PYTHONBUILDDIR%\python312.dll" (
36-
echo Your PYTHONBUILDDIR in buildPaths.bat does not contain python312.dll. Please set PYTHONBUILDDIR to the root of a built Python 3.12
41+
IF NOT EXIST "%PYTHONBUILDDIR%\python314.dll" (
42+
echo Your PYTHONBUILDDIR in buildPaths.bat does not contain python314.dll. Please set PYTHONBUILDDIR to the root of a built Python 3.14
3743
goto error
3844
)
3945

installer/buildPaths.bat.orig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ IF [%PYTHONBUILDDIR%] == [] (
55
)
66
IF [%PYTHONBUILDDIR_X64%] == [] (
77
SET PYTHONBUILDDIR_X64=l:\code\cpython\pcbuild_x64
8+
)
9+
IF [%PYTHONBUILDDIR_ARM64%] == [] (
10+
SET PYTHONBUILDDIR_ARM64=l:\code\cpython\pcbuild_arm64
811
)

installer/buildReleaseZips.bat

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,18 @@ IF "%1"=="x64" SET PYTHONSCRIPTDLLDIR=x64
2424
IF "%1"=="x64" SET INST_TEMP_DIR=temp64
2525
IF "%1"=="x64" SET NAME_ADDON=_x64
2626

27+
IF "%1"=="arm64" SET PYTHONBUILDDIR=%PYTHONBUILDDIR_ARM64%
28+
IF "%1"=="arm64" SET PYTHONSCRIPTDLLDIR=arm64
29+
IF "%1"=="arm64" SET INST_TEMP_DIR=temparm64
30+
IF "%1"=="arm64" SET NAME_ADDON=_arm64
2731

2832
IF NOT EXIST "%PYTHONBUILDDIR%\python.exe" (
29-
echo Your PYTHONBUILDDIR in buildPaths.bat does not contain python.exe. Please set PYTHONBUILDDIR to the root of a built Python 3.12
33+
echo Your PYTHONBUILDDIR in buildPaths.bat does not contain python.exe. Please set PYTHONBUILDDIR to the root of a built Python 3.14
3034
goto error
3135
)
3236

33-
IF NOT EXIST "%PYTHONBUILDDIR%\python312.dll" (
34-
echo Your PYTHONBUILDDIR in buildPaths.bat does not contain python312.dll. Please set PYTHONBUILDDIR to the root of a built Python 3.12
37+
IF NOT EXIST "%PYTHONBUILDDIR%\python314.dll" (
38+
echo Your PYTHONBUILDDIR in buildPaths.bat does not contain python314.dll. Please set PYTHONBUILDDIR to the root of a built Python 3.14
3539
goto error
3640
)
3741

@@ -73,9 +77,9 @@ mkdir %INST_TEMP_DIR%\release\Min\plugins\PythonScript\scripts
7377
mkdir %INST_TEMP_DIR%\release\Min\plugins\PythonScript\doc
7478
mkdir %INST_TEMP_DIR%\release\Tcl\plugins\PythonScript\lib
7579

76-
echo Copying python312.dll
77-
copy %PYTHONBUILDDIR%\python312.dll %INST_TEMP_DIR%\release\Full\plugins\PythonScript
78-
copy %PYTHONBUILDDIR%\python312.dll %INST_TEMP_DIR%\release\Min\plugins\PythonScript
80+
echo Copying python314.dll
81+
copy %PYTHONBUILDDIR%\python314.dll %INST_TEMP_DIR%\release\Full\plugins\PythonScript
82+
copy %PYTHONBUILDDIR%\python314.dll %INST_TEMP_DIR%\release\Min\plugins\PythonScript
7983

8084
echo Copying PythonScript.dll
8185
copy ..\%PYTHONSCRIPTDLLDIR%\release\PythonScript.dll %INST_TEMP_DIR%\release\Full\plugins\PythonScript

0 commit comments

Comments
 (0)