diff --git a/.github/workflows/buildpackage-mac.yml b/.github/workflows/buildpackage-mac.yml index 804868f2f..d070cdf27 100644 --- a/.github/workflows/buildpackage-mac.yml +++ b/.github/workflows/buildpackage-mac.yml @@ -1,4 +1,4 @@ -name: Build Mac OS X app +name: Build macOS app on: push: @@ -34,15 +34,27 @@ jobs: - name: Make pyinstaller spec run: | pyi-makespec --hidden-import="pkg_resources.py2_warn" -F --add-data images/\*:images --add-data \*.png:. --add-data \*.ico:. -w -i P-face.icns pronterface.py + # Edit spec file + export git_hash=$(git rev-parse --short "$GITHUB_SHA") + sed -i '' '$ s/.$//' pronterface.spec + cat >> pronterface.spec <` +`sudo usermod -G serial -a ` -where `` should be your username. Log out and in to make this group change active and allow communication with your printer. +where `` should be your username. Log out and in to make this group change active and allow communication with your printer. ### Fedora @@ -79,12 +78,12 @@ To use pronterface, you need: * numpy (for 3D view) * pycairo (to use Projector feature) * cairosvg (to use Projector feature) - * dbus (to inhibit sleep on some Linux systems) + * dbus (to inhibit sleep on some Linux systems) ### Use Python virtual environment Easiest way to run Printrun from source is to create and use a Python [virtual environment](https://docs.python.org/3/tutorial/venv.html). -The following section assumes Linux. Please see specific instructions for Windows and macOS X below. +The following section assumes Linux. Please see specific instructions for Windows and macOS below. **Ubuntu/Debian note:** You might need to install `python3-venv` first. @@ -149,7 +148,7 @@ Download and install [Python 3.6](https://www.python.org/downloads/) and follow ``` -### macOS X +### macOS Install Python 3, you can use Brew: @@ -157,7 +156,17 @@ Install Python 3, you can use Brew: $ brew install python3 ``` -And follow the above **Python virtual environment** section. You don't need to search for wxPython wheel, macOS wheels are available from the Python Package Index. +Then continue to install and set up Printrun: + +```console +$ git clone https://github.com/kliment/Printrun.git # clone the repository +$ cd Printrun # change to Printrun directory +$ python3 -m venv venv # create an virtual environment +$ . venv/bin/activate # activate the virtual environment (notice the space after the dot) +(venv) $ python -m pip install -r requirements.txt # install the rest of dependencies +# follow instructions for cython gcoder here if desired +(venv) $ python pronterface.py # run Pronterface +``` # USING PRINTRUN @@ -393,7 +402,7 @@ For example, following macro toggles the diagnostic information similarily to th Macro parameters are available in '!'-escaped python code as locally defined list variable: arg[0] arg[1] ... arg[N] -All python code is executed in the context of the pronsole (or PronterWindow) object, +All python code is executed in the context of the pronsole (or PronterWindow) object, so it is possible to use all internal variables and methods, which provide great deal of functionality. However the internal variables and methods are not very well documented and may be subject of change, as the program is developed. Therefore it is best to use pronsole commands, which easily contain majority of the functionality that might be needed. @@ -401,7 +410,7 @@ Therefore it is best to use pronsole commands, which easily contain majority of Some useful python-mode-only variables: ```python -!self.settings - contains all settings, e.g. +!self.settings - contains all settings, e.g. port (!self.settings.port), baudrate, xy_feedrate, e_feedrate, slicecommand, final_command, build_dimensions You can set them also via pronsole command "set", but you can query the values only via python code. !self.p - printcore object (see USING PRINTCORE section for using printcore object) @@ -412,7 +421,7 @@ Some useful python-mode-only variables: Some useful methods: ```python -!self.onecmd - invokes raw command, e.g. +!self.onecmd - invokes raw command, e.g. !self.onecmd("move x 10") !self.onecmd("!print self.p.loud") !self.onecmd("button "+self.cur_button+" fanOFF /C cyan M107") @@ -484,4 +493,3 @@ along with Printrun. If not, see . ``` All scripts should contain this license note, if not, feel free to ask us. Please note that files where it is difficult to state this license note (such as images) are distributed under the same terms. - diff --git a/buildinstructions.txt b/buildinstructions.txt index ff272cfe0..79f3fba71 100644 --- a/buildinstructions.txt +++ b/buildinstructions.txt @@ -19,13 +19,19 @@ python pronterface.py for packaging: pip install pyinstaller -pyi-makespec -F --add-data images/\*:images --add-data \*.png:. --add-data \*.ico:. -w -i P-face.icns pronterface.py +pyi-makespec --hidden-import="pkg_resources.py2_warn" -F --add-data images/\*:images --add-data \*.png:. --add-data \*.ico:. -w -i P-face.icns pronterface.py rm -rf dist -pyinstaller --clean pronterface.spec -y -(edit .plist file to add: -NSAppSleepDisabled - +sed -i '' '$ s/.$//' pronterface.spec +cat >> pronterface.spec <. import os +import platform import sys import re import gettext @@ -39,12 +40,20 @@ def install_locale(domain): shared_locale_dir = os.path.join(DATADIR, 'locale') translation = None lang = locale.getdefaultlocale() - - if os.path.exists('./locale'): - translation = gettext.translation(domain, './locale', languages=[lang[0]], fallback= True) + osPlatform = platform.system() + + if osPlatform == "Darwin": + # improvised workaround for macOS crash with gettext.translation, see issue #1154 + if os.path.exists(shared_locale_dir): + gettext.install(domain, shared_locale_dir) + else: + gettext.install(domain, './locale') else: - translation = gettext.translation(domain, shared_locale_dir, languages=[lang[0]], fallback= True) - translation.install() + if os.path.exists('./locale'): + translation = gettext.translation(domain, './locale', languages=[lang[0]], fallback= True) + else: + translation = gettext.translation(domain, shared_locale_dir, languages=[lang[0]], fallback= True) + translation.install() class LogFormatter(logging.Formatter): def __init__(self, format_default, format_info):