From fc6f754ec5a7a82b29322cf4b37c8251dde24ecb Mon Sep 17 00:00:00 2001 From: DivingDuck Date: Sat, 16 Nov 2024 20:53:29 +0100 Subject: [PATCH 1/7] Add support for Python 3.12 and 3.13 --- .github/workflows/buildpackage-win.yml | 7 ++-- CleanCacheFiles.bat | 40 ++++++++++++++++++++ printrun/device.py | 2 +- printrun/gcodeplater.py | 4 +- printrun/gcoder.py | 8 ++-- printrun/pronsole.py | 6 +-- printrun/pronterface.py | 2 +- release_windows.bat | 51 +++++++++++++++++++------- requirements.txt | 2 +- 9 files changed, 94 insertions(+), 28 deletions(-) create mode 100644 CleanCacheFiles.bat diff --git a/.github/workflows/buildpackage-win.yml b/.github/workflows/buildpackage-win.yml index 4eb24d9f5..9f7e7d147 100644 --- a/.github/workflows/buildpackage-win.yml +++ b/.github/workflows/buildpackage-win.yml @@ -16,9 +16,10 @@ jobs: os: [windows-latest] # supported architecture: [x64, x86] architecture: [x86, x64] - # supported versions: ['3.8', '3.9', '3.10', '3.11'] - # for x86 only Python 3.9 to 3.11 is supported - python-version: ['3.10'] + # supported versions: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] + # for x86 only Python 3.9 to 3.13 is supported + # Python 3.13 is experimental + python-version: ['3.10', '3.11', '3.12', '3.13'] steps: - name: Checkout diff --git a/CleanCacheFiles.bat b/CleanCacheFiles.bat new file mode 100644 index 000000000..f5d99c2b3 --- /dev/null +++ b/CleanCacheFiles.bat @@ -0,0 +1,40 @@ +echo off +rem ************************************************************** +rem *** This batch file will clean up all __pycache__ folders, *** +rem *** *.pyd files and left over gcoder_line files from *** +rem *** previous builds. For Windows only. *** +rem *** *** +rem *** This is helpful when you switch between Python *** +rem *** versions or you have problems with incompatible *** +rem *** library files. *** +rem *** *** +rem *** Don't forget to delete the virtual environment v3 *** +rem *** if you switch between Python versions. *** +rem *** *** +rem *** Author: DivingDuck, 2024-11-16, Status: working *** +rem ************************************************************** + +echo *** Clean pip cache *** +if exist v3 ( + call v3\Scripts\activate + echo *** Activate virtual environment v3 *** + ) + +pip cache purge + +echo *** Clean all __pycache__ folders *** + +for /d /r . %%d in (__pycache__) do @if exist "%%d" echo "%%d" && rd /s/q "%%d" + +if exist v3 ( + call v3\Scripts\deactivate + echo *** Deactivate virtual environment v3 *** + ) + +echo *** clean gcoder_line files *** +if exist printrun\gcoder_line.c del printrun\gcoder_line.c && echo *** delete printrun\gcoder_line.c deleted *** +if exist printrun\gcoder_line.cp???-win_amd??.pyd del printrun\gcoder_line.cp???-win_amd??.pyd && echo *** printrun\gcoder_line.cp???-win_amd??.pyd deleted *** +if exist printrun\gcoder_line.cp???-win??.pyd del printrun\gcoder_line.cp???-win??.pyd && echo *** printrun\gcoder_line.cp???-win??.pyd deleted *** +if exist printrun\gcoder_line.cp??-win_amd??.pyd del printrun\gcoder_line.cp??-win_amd??.pyd && echo *** printrun\gcoder_line.cp??-win_amd??.pyd deleted *** +if exist printrun\gcoder_line.cp??-win??.pyd del printrun\gcoder_line.cp??-win??.pyd && echo *** printrun\gcoder_line.cp??-win??.pyd deleted *** +pause diff --git a/printrun/device.py b/printrun/device.py index 1657d0c36..0428f5484 100644 --- a/printrun/device.py +++ b/printrun/device.py @@ -206,7 +206,7 @@ def _parse_type(self): def _is_url(self, text): # TODO: Rearrange to avoid long line - host_regexp = re.compile("^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$") + host_regexp = re.compile(r"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$") if ':' in text: bits = text.split(":") if len(bits) == 2: diff --git a/printrun/gcodeplater.py b/printrun/gcodeplater.py index c511c5e68..23c0db6a2 100755 --- a/printrun/gcodeplater.py +++ b/printrun/gcodeplater.py @@ -45,8 +45,8 @@ def gcoder_write(self, f, line, store = False): self.append(line, store = store) -rewrite_exp = re.compile("(%s)" % "|".join(["X([-+]?[0-9]*\.?[0-9]*)", - "Y([-+]?[0-9]*\.?[0-9]*)"])) +rewrite_exp = re.compile("(%s)" % "|".join([r"X([-+]?[0-9]*\.?[0-9]*)", + r"Y([-+]?[0-9]*\.?[0-9]*)"])) def rewrite_gline(centeroffset, gline, cosr, sinr): if gline.is_move and (gline.x is not None or gline.y is not None): diff --git a/printrun/gcoder.py b/printrun/gcoder.py index 6fbc5f410..099cd8428 100755 --- a/printrun/gcoder.py +++ b/printrun/gcoder.py @@ -25,10 +25,10 @@ gcode_parsed_args = ["x", "y", "e", "f", "z", "i", "j"] gcode_parsed_nonargs = 'gtmnd' to_parse = "".join(gcode_parsed_args) + gcode_parsed_nonargs -gcode_exp = re.compile("\([^\(\)]*\)|;.*|[/\*].*\n|([%s])\s*([-+]?[0-9]*\.?[0-9]*)" % to_parse) -gcode_strip_comment_exp = re.compile("\([^\(\)]*\)|;.*|[/\*].*\n") -m114_exp = re.compile("\([^\(\)]*\)|[/\*].*\n|([XYZ]):?([-+]?[0-9]*\.?[0-9]*)") -specific_exp = "(?:\([^\(\)]*\))|(?:;.*)|(?:[/\*].*\n)|(%s[-+]?[0-9]*\.?[0-9]*)" +gcode_exp = re.compile(r"\([^\(\)]*\)|;.*|[/\*].*\n|([%s])\s*([-+]?[0-9]*\.?[0-9]*)" % to_parse) +gcode_strip_comment_exp = re.compile(r"\([^\(\)]*\)|;.*|[/\*].*\n") +m114_exp = re.compile(r"\([^\(\)]*\)|[/\*].*\n|([XYZ]):?([-+]?[0-9]*\.?[0-9]*)") +specific_exp = r"(?:\([^\(\)]*\))|(?:;.*)|(?:[/\*].*\n)|(%s[-+]?[0-9]*\.?[0-9]*)" move_gcodes = ["G0", "G1", "G2", "G3"] class PyLine: diff --git a/printrun/pronsole.py b/printrun/pronsole.py index 0fee067fa..e39a03d14 100644 --- a/printrun/pronsole.py +++ b/printrun/pronsole.py @@ -58,7 +58,7 @@ except ImportError: READLINE = False # neither readline module is available -tempreading_exp = re.compile('\\bT\d*:') +tempreading_exp = re.compile(r'\\bT\d*:') REPORT_NONE = 0 REPORT_POS = 1 @@ -198,7 +198,7 @@ def __init__(self): self.history_file = os.path.join(self.cache_dir,"history") self.config_dir = os.path.join(user_config_dir("Printrun")) self.data_dir = os.path.join(user_data_dir("Printrun")) - self.lineignorepattern=re.compile("ok ?\d*$|.*busy: ?processing|.*busy: ?heating|.*Active Extruder: ?\d*$") + self.lineignorepattern = re.compile(r"ok ?\d*$|.*busy: ?processing|.*busy: ?heating|.*Active Extruder: ?\d*$") # -------------------------------------------------------------- # General console handling @@ -1137,7 +1137,7 @@ def listfiles(self, line): self.log(_("Files on SD card:")) self.log("\n".join(self.sdfiles)) elif self.sdlisting: - self.sdfiles.append(re.sub(" \d+$","",line.strip().lower())) + self.sdfiles.append(re.sub(r" \d+$","",line.strip().lower())) def _do_ls(self, echo): # FIXME: this was 2, but I think it should rather be 0 as in do_upload diff --git a/printrun/pronterface.py b/printrun/pronterface.py index 29e6be180..d37b8d051 100644 --- a/printrun/pronterface.py +++ b/printrun/pronterface.py @@ -2096,7 +2096,7 @@ def listfiles(self, line, ignored = False): self.recvlisteners.remove(self.listfiles) wx.CallAfter(self.filesloaded) elif self.sdlisting: - self.sdfiles.append(re.sub(" \d+$", "", line.strip().lower())) # NOQA + self.sdfiles.append(re.sub(r" \d+$", "", line.strip().lower())) # NOQA def waitforsdresponse(self, l): if "file.open failed" in l: diff --git a/release_windows.bat b/release_windows.bat index 44fbaa163..51c40dc1b 100644 --- a/release_windows.bat +++ b/release_windows.bat @@ -28,19 +28,23 @@ rem ** rem ** 1. Install python 64-bit (3.10.x 64-bit is actually preferred ** rem ** and standard version for Windows 10) ** rem ** https://www.python.org/downloads/release ** -rem ** In case you use an other Python version: Check line 73 to 77 and adjust ** +rem ** In case you use an other Python version: Check line 77 to 82 and adjust ** rem ** the parameter accordingly to build your virtual environment. ** rem ** 2. Install C-compiler environment ** rem ** https://wiki.python.org/moin/WindowsCompilers ** +rem ** (Microsoft Visual Studio 2022 Community version is proofed to work fine) ** rem ** 3. Check for latest repository updates at: ** rem ** http://github.com/kliment/Printrun.git ** -rem ** ** +rem ** 4. It is recommended to delete an existing virtual environment (v3) when you ** +rem ** switch between -x32/-x64 or different Python versions. There is a second ** +rem ** batch script called CleanCacheFiles.bat available for cleaning ** +rem ** former compiling- and __pycache__ artifacts . Run it as often you need. ** rem ** ** rem ** Remark: Plater stand alone application is experimental only. GUI code need an ** rem ** update for closing plater window and running processes. For now you ** rem ** need to terminate the process manually via Task manager. ** rem ** ** -rem ** Author: DivingDuck, 2023-12-15, Status: working ** +rem ** Author: DivingDuck, 2024-11-16, Status: working ** rem ** ** rem ************************************************************************************ rem ************************************************************************************ @@ -52,6 +56,13 @@ if exist dist ( DEL /F/Q/S dist > NUL RMDIR /Q/S dist ) +echo *************************************************** +echo ****** Delete files and directory of .\build ****** +echo *************************************************** +if exist build ( + DEL /F/Q/S build > NUL + RMDIR /Q/S build + ) echo ********************************************* echo ****** Activate virtual environment v3 ****** echo ********************************************* @@ -67,17 +78,22 @@ if exist v3 ( rem for your Python version of choice and add 'rem' for all other versions. rem Attention: rem Minimum version for wxPython is >= 4.2.1. With this version - rem Python x64 (version 3.7 up to 3.11) and - rem Python x86 (version 3.9 up to 3.11) is supported. + rem Python x64 (version 3.8 up to 3.12) and + rem Python x86 (version 3.9 up to 3.12) is supported. - rem py -3.7 -m venv v3 rem py -3.8 -m venv v3 rem py -3.9-32 -m venv v3 rem py -3.9 -m venv v3 rem py -3.10-32 -m venv v3 - py -3.10 -m venv v3 + rem py -3.10 -m venv v3 rem py -3.11-32 -m venv v3 rem py -3.11 -m venv v3 + rem py -3.12-32 -m venv v3 + rem py -3.12 -m venv v3 + + rem Attention: Python 3.13 support is experimental, no 3D view available for now. + rem py -3.13-32 -m venv v3 + py -3.13 -m venv v3 echo ********************************************* echo ****** Activate virtual environment v3 ****** @@ -102,6 +118,7 @@ if exist v3 ( pip install pyinstaller pip install pypiwin32 pip install polygon3 + pip install pytest ) echo ******************************************** @@ -120,15 +137,15 @@ echo ****** pyglet workaround, needs to be below 2.0 (isn't compatible) ****** echo ************************************************************************* rem # 2022-11-01 pip uninstall pyglet -y -pip install pyglet==1.5.27 +pip install pyglet==1.5.29 -echo ************************************************************************** -echo ****** pillow workaround, needs to be below 10.0 (isn't compatible) ****** -echo ************************************************************************** +rem echo ************************************************************************** +rem echo ****** pillow workaround, needs to be below 10.0 (isn't compatible) ****** +rem echo ************************************************************************** rem # 2023-12-15 rem building wxPython 4.2.1 for x86 needs pillow <10.0 -pip uninstall pillow -y -pip install pillow==9.5.0 +rem *** pip uninstall pillow -y +rem *** pip install pillow==9.5.0 echo ****************************************************************** echo ****** Compile G-Code parser gcoder_line.cp??-win_amd??.pyd ****** @@ -140,6 +157,14 @@ if exist printrun\gcoder_line.cp??-win_amd??.pyd ( echo ****** found versions of printrun\gcoder_line.cp??-win_amd??.pyd, deleted ****** echo ******************************************************************************** ) +rem In addition check for 3 digit Python versions +if exist printrun\gcoder_line.cp???-win_amd??.pyd ( + del printrun\gcoder_line.cp???-win_amd??.pyd + echo ***********************************************************************++********* + echo ****** found versions of printrun\gcoder_line.cp???-win_amd??.pyd, deleted ****** + echo ********************************************************************************** + ) + python setup.py build_ext --inplace echo **************************************** diff --git a/requirements.txt b/requirements.txt index 12146cfe7..1d179dda8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ pyserial (>= 3.0) -pillow < 10.0; sys_platform == 'win32' +pillow ; sys_platform == 'win32' wxPython >= 4.2.0 numpy (>= 1.8.2) pyglet >= 1.1, < 2.0 From a1b23d595ddb84ec6250b8f504107f48909fcadb Mon Sep 17 00:00:00 2001 From: DivingDuck Date: Sun, 17 Nov 2024 11:11:21 +0100 Subject: [PATCH 2/7] Windows builds with all supported Python versions at Github activated for testing Local Windows build set to Python 3.12 for further testing --- .github/workflows/buildpackage-win.yml | 2 +- release_windows.bat | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/buildpackage-win.yml b/.github/workflows/buildpackage-win.yml index 9f7e7d147..afd3f41b0 100644 --- a/.github/workflows/buildpackage-win.yml +++ b/.github/workflows/buildpackage-win.yml @@ -19,7 +19,7 @@ jobs: # supported versions: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] # for x86 only Python 3.9 to 3.13 is supported # Python 3.13 is experimental - python-version: ['3.10', '3.11', '3.12', '3.13'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] steps: - name: Checkout diff --git a/release_windows.bat b/release_windows.bat index 51c40dc1b..973a3b354 100644 --- a/release_windows.bat +++ b/release_windows.bat @@ -89,11 +89,11 @@ if exist v3 ( rem py -3.11-32 -m venv v3 rem py -3.11 -m venv v3 rem py -3.12-32 -m venv v3 - rem py -3.12 -m venv v3 + py -3.12 -m venv v3 rem Attention: Python 3.13 support is experimental, no 3D view available for now. rem py -3.13-32 -m venv v3 - py -3.13 -m venv v3 + rem py -3.13 -m venv v3 echo ********************************************* echo ****** Activate virtual environment v3 ****** From 1c172fbe03cdfbbabf5e7bb4010ad9d16c48acf7 Mon Sep 17 00:00:00 2001 From: DivingDuck Date: Mon, 25 Nov 2024 10:35:48 +0100 Subject: [PATCH 3/7] Better processing for outdated modules regarding workarounds, add workaround for regression in actual pefile 2024.8.26 --- release_windows.bat | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/release_windows.bat b/release_windows.bat index 973a3b354..63d98ac48 100644 --- a/release_windows.bat +++ b/release_windows.bat @@ -91,7 +91,8 @@ if exist v3 ( rem py -3.12-32 -m venv v3 py -3.12 -m venv v3 - rem Attention: Python 3.13 support is experimental, no 3D view available for now. + rem Attention: Python 3.13 support is experimental, no 3D view available for now as + rem pyglet 1.5.29 have compiling issues with Python 3.13. rem py -3.13-32 -m venv v3 rem py -3.13 -m venv v3 @@ -129,15 +130,20 @@ pip install --upgrade virtualenv echo ******************************************************** echo ****** check for outdated modules and update them ****** echo ******************************************************** -for /F "skip=2 delims= " %%i in ('pip list --outdated') do py -m pip install --upgrade %%i - - -echo ************************************************************************* -echo ****** pyglet workaround, needs to be below 2.0 (isn't compatible) ****** -echo ************************************************************************* -rem # 2022-11-01 -pip uninstall pyglet -y -pip install pyglet==1.5.29 +rem --exclude pyglet: workaround, needs to be below 2.0 (isn't compatible) +rem --exclude pefile: workaround, (Windows) Pin pefile != 2024.8.26 due to performance +rem regression in pefile 2024.8.26 that heavily impacts PyInstaller’s +rem binary dependency analysis and binary-vs-data classification. See +rem https://pyinstaller.org/en/stable/CHANGES.html#pyinstaller-core +for /F "skip=2 delims= " %%i in ('pip list --outdated --exclude pyglet --exclude pefile') do py -m pip install --upgrade %%i + + +rem echo ************************************************************************* +rem echo ****** pyglet workaround, needs to be below 2.0 (isn't compatible) ****** +rem echo ************************************************************************* +rem # 2022-11-01, 2024-11-24 moved to check for outdated section above --exclude pyglet +rem pip uninstall pyglet -y +rem pip install pyglet==1.5.29 rem echo ************************************************************************** rem echo ****** pillow workaround, needs to be below 10.0 (isn't compatible) ****** From e08c323db88fc81e990adfc1b987297c7838fa47 Mon Sep 17 00:00:00 2001 From: DivingDuck Date: Thu, 12 Dec 2024 23:14:00 +0100 Subject: [PATCH 4/7] Python 3.13 no longer experimental due to pyglet version 1.5.30 update --- .github/workflows/buildpackage-win.yml | 2 +- release_windows.bat | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/buildpackage-win.yml b/.github/workflows/buildpackage-win.yml index afd3f41b0..cea673d4a 100644 --- a/.github/workflows/buildpackage-win.yml +++ b/.github/workflows/buildpackage-win.yml @@ -18,7 +18,7 @@ jobs: architecture: [x86, x64] # supported versions: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] # for x86 only Python 3.9 to 3.13 is supported - # Python 3.13 is experimental + # Python 3.13t is not supported python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] steps: diff --git a/release_windows.bat b/release_windows.bat index 63d98ac48..9e644a787 100644 --- a/release_windows.bat +++ b/release_windows.bat @@ -44,7 +44,7 @@ rem ** Remark: Plater stand alone application is experimental only. GUI code ne rem ** update for closing plater window and running processes. For now you ** rem ** need to terminate the process manually via Task manager. ** rem ** ** -rem ** Author: DivingDuck, 2024-11-16, Status: working ** +rem ** Author: DivingDuck, 2024-12-12, Status: working ** rem ** ** rem ************************************************************************************ rem ************************************************************************************ @@ -89,12 +89,11 @@ if exist v3 ( rem py -3.11-32 -m venv v3 rem py -3.11 -m venv v3 rem py -3.12-32 -m venv v3 - py -3.12 -m venv v3 - - rem Attention: Python 3.13 support is experimental, no 3D view available for now as - rem pyglet 1.5.29 have compiling issues with Python 3.13. + rem py -3.12 -m venv v3 rem py -3.13-32 -m venv v3 - rem py -3.13 -m venv v3 + py -3.13 -m venv v3 + rem Attention: py -3.13-32t and py -3.13t (the experimental + rem free-threaded mode) are not supported jet echo ********************************************* echo ****** Activate virtual environment v3 ****** @@ -117,7 +116,7 @@ if exist v3 ( echo *********************** pip install simplejson pip install pyinstaller - pip install pypiwin32 + pip install pywin32 pip install polygon3 pip install pytest ) From acf930de8fc4ae0228ae5e069e5ef290c423635b Mon Sep 17 00:00:00 2001 From: DivingDuck Date: Thu, 12 Dec 2024 23:41:20 +0100 Subject: [PATCH 5/7] Build package macos-12 is depreciated. Remove macos-12 and dd macos-13, 14 and 15 for testing. Add python Python 3.11, 3.12 and 3.13 for testing --- .github/workflows/buildpackage-mac.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/buildpackage-mac.yml b/.github/workflows/buildpackage-mac.yml index fc518367f..529bef7f7 100644 --- a/.github/workflows/buildpackage-mac.yml +++ b/.github/workflows/buildpackage-mac.yml @@ -13,9 +13,9 @@ jobs: strategy: matrix: - os: [macos-12] + os: [macos-13,macos-14,macos-15] architecture: [x64] - python-version: ['3.10'] + python-version: ['3.10','3.11','3.12','3.13'] steps: - name: Checkout From 04960e3d1ae9c107adbe055572cf077ddb2a58ca Mon Sep 17 00:00:00 2001 From: DivingDuck Date: Fri, 13 Dec 2024 00:07:49 +0100 Subject: [PATCH 6/7] remove py 3.10 --- .github/workflows/buildpackage-mac.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/buildpackage-mac.yml b/.github/workflows/buildpackage-mac.yml index 529bef7f7..77710bb07 100644 --- a/.github/workflows/buildpackage-mac.yml +++ b/.github/workflows/buildpackage-mac.yml @@ -15,7 +15,7 @@ jobs: matrix: os: [macos-13,macos-14,macos-15] architecture: [x64] - python-version: ['3.10','3.11','3.12','3.13'] + python-version: ['3.11','3.12','3.13'] steps: - name: Checkout From 6fb0047626437aed3b8b2b0fb69f7a3691a125f6 Mon Sep 17 00:00:00 2001 From: DivingDuck Date: Fri, 13 Dec 2024 00:50:19 +0100 Subject: [PATCH 7/7] One more fix for macOS --- .github/workflows/build-wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index 58785bea7..0da59d810 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -13,7 +13,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-22.04, windows-2022, macos-12] + os: [ubuntu-22.04, windows-2022, macos-13] steps: - uses: actions/checkout@v4