Skip to content

Commit

Permalink
Fix and update Windows build scripts by DivingDuck
Browse files Browse the repository at this point in the history
* add pycairo for running projector
* add simplejson polygon3
* Replace time.clock() with time.perf_counter()
* Replace wx.FutureCall with wx.CallLater
* Bundle GTK3 runtime library to Pronterface for Windows 10-64bit
* Make GTK3 a submodule of Printrun, delete GTK3 files from this repository, change buildpackage-win.yml to integrate GTK3 as submodule and compile the correct version GTK3 version for 32-/64-bit or as external reference via windows system environment path
* Add Python 3.10 to github Workflow (windows)
* cairosvg 2.6.0 have problems with locale, so we will stay to version 2.5.2 as workaround for now
* some cleaning for release_windows.bat and update of information in dummy file VERSION
  • Loading branch information
DivingDuck authored Jan 31, 2023
1 parent 2e2adc6 commit 0c296ba
Show file tree
Hide file tree
Showing 10 changed files with 279 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/buildpackage-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
matrix:
os: [macos-latest]
architecture: [x64]
python-version: [3.8]
python-version: ['3.10']

steps:
- name: Checkout
Expand Down
55 changes: 50 additions & 5 deletions .github/workflows/buildpackage-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,71 @@ jobs:
strategy:
matrix:
os: [windows-latest]
architecture: [x64, x86]
python-version: [3.8]
# remove x86 builds for now as there are no snapshot builds of wxPython available
#architecture: [x64, x86]
architecture: [x64]
# add python '3.10' because wxPython 4.2 is now available (2022-08-21)
# remove python '3.6' because not longer supported (2022-03-17)
python-version: ['3.7', '3.8', '3.9','3.10']

steps:
- name: Checkout
uses: actions/checkout@v2
# Import submodule PrintrunGTK3
with:
submodules: recursive

- name: Set up Python
uses: actions/setup-python@v2
with:
architecture: ${{ matrix.architecture }}
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip pyinstaller setuptools wheel cython cffi -r requirements.txt
python -m pip install --upgrade pip pyinstaller setuptools wheel simplejson polygon3 cython cffi -r requirements.txt
# - name: Update to wxPython Version for x86 and py 3.8
# # Latest development version for x86 and Python 3.6 is for now (2021-12-18) 4.1.2a1.dev5226+a843ed14
# # Latest development version for x86 and Python 3.8+3.9 is for now (2022-03-17) 4.1.2a1.dev5226+a843ed14
# # Remove Python 3.6
# if: ${{ matrix.architecture == 'x86' && matrix.python-version == '3.8' }}
# run: |
# python -m pip install -U --pre -f https://wxpython.org/Phoenix/snapshot-builds/ wxPython==4.1.2a1.dev5226+a843ed14
# - name: Update to wxPython Version for x86 and py 3.9
# # Latest development version for x86 and Python 3.6 is for now (2021-12-18) 4.1.2a1.dev5226+a843ed14
# # Latest development version for x86 and Python 3.8+3.9 is for now (2022-03-17) 4.1.2a1.dev5226+a843ed14
# # Remove Python 3.6
# if: ${{ matrix.architecture == 'x86' && matrix.python-version == '3.9' }}
# run: |
# python -m pip install -U --pre -f https://wxpython.org/Phoenix/snapshot-builds/ wxPython==4.1.2a1.dev5226+a843ed14
#
#
- name: Update to wxPython latest Version for x64
# Latest development version for x64 and Python 3.7 to 3.10, can be removed if requirements.txt is fixed
if: ${{ matrix.architecture == 'x64' && matrix.python-version >= '3.7' }}
run: |
# python -m pip install -U --pre -f https://wxpython.org/Phoenix/snapshot-builds/ wxPython
python -m pip install -U wxPython
- name: Build Cython ext
run: |
python setup.py build_ext --inplace
- name: Make pyinstaller spec
# Build pyinstaller spec depending on GTK3 x32/x64 binaries or w/o GTK3 bundle
# for running Projector. The user can install the GTK3 libraries external and
# set the environment path to the installation manually if the bundle is not
# included or found (last option) via submodules
- name: Make pyinstaller spec with GTK3 x64 bundle
if: ${{ matrix.architecture == 'x64' && hashFiles('PrintrunGTK3/GTK3Windows10-64') != '' }}
run: |
pyi-makespec --hidden-import="pkg_resources.py2_warn" -F --add-binary "PrintrunGTK3/GTK3Windows10-64/*.dll;." --add-data "VERSION;cairocffi" --add-data "VERSION;cairosvg" --add-data "images/*;images" --add-data "*.png;." --add-data "*.ico;." -w -i pronterface.ico pronterface.py
- name: Make pyinstaller spec with GTK3 x32 bundle
if: ${{ matrix.architecture == 'x86' && hashFiles('PrintrunGTK3/GTK3Windows10-32') != '' }}
run: |
pyi-makespec --hidden-import="pkg_resources.py2_warn" -F --add-binary "PrintrunGTK3/GTK3Windows10-32/*.dll;." --add-data "VERSION;cairocffi" --add-data "VERSION;cairosvg" --add-data "images/*;images" --add-data "*.png;." --add-data "*.ico;." -w -i pronterface.ico pronterface.py
- name: Make pyinstaller spec without GTK3 bundle
if: ${{ hashFiles('PrintrunGTK3') == '' }}
run: |
pyi-makespec --hidden-import="pkg_resources.py2_warn" -F --add-data "images/*;images" --add-data "*.png;." --add-data "*.ico;." -w -i pronterface.ico pronterface.py
pyi-makespec --hidden-import="pkg_resources.py2_warn" -F --add-data "VERSION;cairocffi" --add-data "VERSION;cairosvg" --add-data "images/*;images" --add-data "*.png;." --add-data "*.ico;." -w -i pronterface.ico pronterface.py
- name: Make pyinstaller build
run: |
pyinstaller --clean pronterface.spec -y
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ uploads
.vagrant
prontserve-env
pronterface.spec
pronsole.spec
printrun/gcoder_line.c
printrun/gcoder_line*.so
printrun/gcoder_line*.pyd
Expand All @@ -23,4 +24,7 @@ printrun/gcoder_line*.pyd
/v3/
/.vs/
/dist
/slic3rconf.ini
/slic3rconf.ini
/PrusaSlicer.ini
/.eggs
/SuperSlicer.ini
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "PrintrunGTK3"]
path = PrintrunGTK3
url = https://github.com/DivingDuck/PrintrunGTK3
1 change: 1 addition & 0 deletions PrintrunGTK3
Submodule PrintrunGTK3 added at e26b8d
61 changes: 61 additions & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
This is a dummy file for pyinstaller to compile Pronterface.Cairocffi and cairosvg won't find
the GTK3 runtime libraries needed for running Projector under Windows w / o this file.

You can find a suitable version of GTK3 for Windows 10 here : https://github.com/DivingDuck/PrintrunGTK3.
For further information please follow the links.PrintrunGTK3 is a submodule of Printrun.

The DLL binaries are based on https ://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer
for 64 Bit version and http ://www.tarnyko.net/dl/gtk.htm for 32 Bit version and are not modified.

Please run following git commands in case you can't find the directory 'PrintrunGTK' in your repository:
git checkout master
git submodule add https ://github.com/DivingDuck/PrintrunGTK3
git submodule update --init --recursive

For updating an existing submodule to latest version run :
git submodule update --remote

Compiling Pronterface manually :
Follow the instructions in release_windows.bat and activate the correct pyi - makespec version depending on your needs.


List of DLL's for Projector based on Windows 10 for 64bit program version:
--------------------------------------------------------------------------
https ://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer
https ://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer/releases/download/2021-01-30/gtk3-runtime-3.24.24-2021-01-30-ts-win64.exe

libbrotlicommon.dll
libbrotlidec.dll
libbz2 - 1.dll
libcairo - 2.dll
libexpat - 1.dll
libfontconfig - 1.dll
libfreetype - 6.dll
libgcc_s_seh - 1.dll
libglib - 2.0 - 0.dll
libgraphite2.dll
libharfbuzz - 0.dll
libiconv - 2.dll
libintl - 8.dll
libpcre - 1.dll
libpixman - 1 - 0.dll
libpng16 - 16.dll
libstdc++ - 6.dll
libwinpthread - 1.dll
zlib1.dll


List of DLL's for Projector based on Windows 10 for 32bit program version:
--------------------------------------------------------------------------
http ://www.tarnyko.net/dl/gtk.htm
http://www.tarnyko.net/repo/gtk3_build_system/gtk+-bundle_3.6.4-20130513_win32.zip

File list :
libcairo - 2.dll
libexpat - 1.dll
libfontconfig - 1.dll
libfreetype - 6.dll
libpixman - 1 - 0.dll
libpng15 - 15.dll
Remark.txt
zlib1.dll
15 changes: 9 additions & 6 deletions printrun/gcview.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,12 +471,15 @@ def update_status(self, extra):
wx.CallAfter(self.SetStatusText, message, 0)

def process_slider(self, event):
new_layer = self.layerslider.GetValue()
new_layer = min(self.model.max_layers + 1, new_layer)
new_layer = max(1, new_layer)
self.model.num_layers_to_draw = new_layer
self.update_status("")
wx.CallAfter(self.Refresh)
if self.model is not None:
new_layer = self.layerslider.GetValue()
new_layer = min(self.model.max_layers + 1, new_layer)
new_layer = max(1, new_layer)
self.model.num_layers_to_draw = new_layer
self.update_status("")
wx.CallAfter(self.Refresh)
else:
logging.info(_("G-Code view, can't process slider. Please wait until model is loaded completely."))

def set_current_gline(self, gline):
if gline.is_move and gline.gcview_end_vertex is not None \
Expand Down
21 changes: 13 additions & 8 deletions printrun/projectlayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ def draw_layer(self, image):
if self.layer_red:
pngImage = pngImage.AdjustChannels(1, 0, 0, 1)

dc.DrawBitmap(wx.Bitmap(pngImage), self.offset[0], self.offset[1], True)
# AGE2022-07-31 Python 3.10 and DrawBitmap expects offset
# as integer value. Convert float values to int
dc.DrawBitmap(wx.Bitmap(pngImage), int(self.offset[0]), int(self.offset[1]), True)

elif self.slicer == 'bitmap':
if isinstance(image, str):
Expand All @@ -130,16 +132,18 @@ def draw_layer(self, image):
pass

def show_img_delay(self, image):
print("Showing", str(time.clock()))
print("Showing", str(time.perf_counter()))
self.control_frame.set_current_layer(self.index)
self.draw_layer(image)
wx.FutureCall(1000 * self.interval, self.hide_pic_and_rise)
# AGe 2022-07-31 Python 3.10 and CallLater expects delay in millyseconds as
# integer value instead of float. Convert float value to int
wx.CallLater(int(1000 * self.interval), self.hide_pic_and_rise)

def rise(self):
if self.direction == "Top Down":
print("Lowering", str(time.clock()))
print("Lowering", str(time.perf_counter()))
else:
print("Rising", str(time.clock()))
print("Rising", str(time.perf_counter()))

if self.printer is not None and self.printer.online:
self.printer.send_now("G91")
Expand All @@ -165,15 +169,16 @@ def rise(self):
else:
time.sleep(self.pause)

wx.FutureCall(1000 * self.pause, self.next_img)
# AGe 2022-07-31 Python 3.10 expects delay in millyseconds as integer value instead of float. Convert float value to int
wx.CallLater(int(1000 * self.pause), self.next_img)

def hide_pic(self):
print("Hiding", str(time.clock()))
print("Hiding", str(time.perf_counter()))
self.pic.Hide()

def hide_pic_and_rise(self):
wx.CallAfter(self.hide_pic)
wx.FutureCall(500, self.rise)
wx.CallLater(500, self.rise)

def next_img(self):
if not self.running:
Expand Down
Loading

0 comments on commit 0c296ba

Please sign in to comment.