Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Python version 3.12 and 3.13 #1465

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/buildpackage-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.11','3.12','3.13']

steps:
- name: Checkout
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/buildpackage-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.13t is not supported
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']

steps:
- name: Checkout
Expand Down
40 changes: 40 additions & 0 deletions CleanCacheFiles.bat
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion printrun/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions printrun/gcodeplater.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions printrun/gcoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions printrun/pronsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion printrun/pronterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
76 changes: 53 additions & 23 deletions release_windows.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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-12-12, Status: working **
rem ** **
rem ************************************************************************************
rem ************************************************************************************
Expand All @@ -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 *********************************************
Expand All @@ -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 py -3.13-32 -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 ******
Expand All @@ -100,8 +116,9 @@ if exist v3 (
echo ***********************
pip install simplejson
pip install pyinstaller
pip install pypiwin32
pip install pywin32
pip install polygon3
pip install pytest
)

echo ********************************************
Expand All @@ -112,23 +129,28 @@ 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.27

echo **************************************************************************
echo ****** pillow workaround, needs to be below 10.0 (isn't compatible) ******
echo **************************************************************************
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) ******
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 ******
Expand All @@ -140,6 +162,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 ****************************************
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading