diff options
| -rw-r--r-- | .github/workflows/build.yml | 201 | ||||
| -rw-r--r-- | .travis.yml | 241 | ||||
| -rw-r--r-- | Makefile | 6 | ||||
| -rwxr-xr-x | bin/build-distribution-archives | 36 | ||||
| -rwxr-xr-x | bin/build-electron | 11 | ||||
| -rwxr-xr-x | bin/build-python | 10 | ||||
| -rw-r--r-- | lib/gui/electron.py | 3 | ||||
| -rw-r--r-- | requirements.txt | 2 | ||||
| -rw-r--r-- | stub.py | 26 |
9 files changed, 244 insertions, 292 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..ae16fade --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,201 @@ +name: Build +on: + push: + branches-ignore: + - master + tags: + - "v*" +jobs: + linux: + runs-on: ubuntu-16.04 + steps: + - uses: actions/checkout@v1 + with: + submodules: recursive + - name: download dependencies + shell: bash + run: | + curl -sOL https://inkscape.org/en/gallery/item/12187/inkscape-0.92.3.tar.bz2 + - name: install dependencies + shell: bash + run: | + # I'd love to use a setup-python action but it seems to give a + # python that doesn't support unicode. See: + # https://github.com/actions/setup-python/issues/23 + + sudo apt-get install python2.7 + python -m pip install --upgrade pip + + sudo apt-get install gettext + + # for wxPython + sudo apt-get install glib-networking libsdl1.2-dev + + # for PyGObject + sudo apt install libgirepository1.0-dev + + uname -a + python --version + python -m pip --version + python -m pip debug + + # wxPython doen't publish linux wheels in pypi + wget -q https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-16.04/wxPython-4.0.6-cp27-cp27mu-linux_x86_64.whl + python -m pip install wxPython*.whl + + python -m pip install PyGObject + + python -m pip install -r requirements.txt + python -m pip install pyinstaller==3.3.1 + + tar -jxf inkscape-0.92.3.tar.bz2 + rm inkscape-0.92.3.tar.bz2 + mv inkscape-0.92.3 inkscape + + echo "::add-path::${{ env.pythonLocation }}\bin" + - shell: bash + run: | + make dist + env: + BUILD: linux + - uses: actions/upload-artifact@master + with: + name: inkstitch-linux + path: artifacts + windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v1 + with: + submodules: recursive + - uses: actions/setup-python@v1 + with: + python-version: '2.7.x' + architecture: 'x86' + - name: download dependencies + shell: bash + run: | + curl -sOL https://github.com/lexelby/inkstitch-build-objects/releases/download/v1.0.0/Shapely-1.6.3-cp27-cp27m-win32.whl + curl -sOL https://inkscape.org/en/gallery/item/12187/inkscape-0.92.3.tar.bz2 + - name: install dependencies + shell: bash + run: | + pip install Shapely-1.6.3-cp27-cp27m-win32.whl + pip install -r requirements.txt + pip install pyinstaller==3.3.1 + + # Just using tar -j freezes forever with no output. Heck if I know why. This seems to work. + bzcat inkscape-0.92.3.tar.bz2 | tar -vxf - + rm inkscape-0.92.3.tar.bz2 + mv inkscape-0.92.3 inkscape + + echo "::add-path::${{ env.pythonLocation }}\bin" + - name: fix geos + shell: bash + run: | + cd "${{ env.pythonLocation }}\Lib/site-packages/shapely/DLLs" + cp geos_c.dll geos.dll + - shell: bash + run: | + make dist + env: + BUILD: windows + - uses: actions/upload-artifact@master + with: + name: inkstitch-windows + path: artifacts + mac: + runs-on: macos-latest + steps: + - uses: actions/checkout@v1 + with: + submodules: recursive + - uses: actions/setup-python@v1 + with: + python-version: '2.7.x' + - name: download inkscape + shell: bash + run: | + curl -sOL https://inkscape.org/en/gallery/item/12187/inkscape-0.92.3.tar.bz2 + - name: install dependencies + shell: bash + run: | + brew update + + # this errors because it installs python3 but python2 is already installed + brew install gtk+3 pkg-config gobject-introspection libffi || true + + export LDFLAGS="-L/usr/local/opt/libffi/lib" + export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig" + + # for msgfmt + brew link gettext --force + + echo "::set-env name=GI_TYPELIB_PATH::/usr/local/lib/girepository-1.0/" + + pip --version + pip install PyGObject + pip install -r requirements.txt + pip install pyinstaller==3.3.1 + + tar -jxf inkscape-0.92.3.tar.bz2 + rm inkscape-0.92.3.tar.bz2 + mv inkscape-0.92.3 inkscape + + echo "::add-path::${{ env.pythonLocation }}\bin" + - shell: bash + run: | + make dist + env: + BUILD: osx + - uses: actions/upload-artifact@master + with: + name: inkstitch-mac + path: artifacts + + release: + runs-on: ubuntu-latest + needs: [linux, windows, mac] + if: always() + steps: + - name: determine release info + shell: bash + run: | + if [[ "${GITHUB_REF}" =~ ^v[0-9.]+$ ]]; then + echo "::set-env name=release_tag::${GITHUB_REF}" + echo "::set-env name=prerelease::false" + echo "::set-env name=title::${GITHUB_REF}" + else + branch="${GITHUB_REF#refs/heads/}" + tag="dev-build-$(echo $branch | tr / -)" + echo "::set-env name=release_tag::${tag}" + echo "::set-env name=prerelease::true" + echo "::set-env name=title::development build of $branch" + fi + - name: download linux + uses: actions/download-artifact@v1 + with: + name: 'inkstitch-linux' + path: 'artifacts/' + - name: download windows + uses: actions/download-artifact@v1 + with: + name: 'inkstitch-windows' + path: 'artifacts/' + if: always() + - name: download mac + uses: actions/download-artifact@v1 + with: + name: 'inkstitch-mac' + path: 'artifacts/' + if: always() + - name: create/update release + uses: "marvinpinto/action-automatic-releases@latest" + if: always() + with: + repo_token: "${{secrets.GITHUB_TOKEN}}" + automatic_release_tag: "${{env.release_tag}}" + prerelease: "${{env.prerelease}}" + title: "${{env.title}}" + files: | + artifacts/*.zip diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f94d1fa0..00000000 --- a/.travis.yml +++ /dev/null @@ -1,241 +0,0 @@ -language: python -virtualenv: - # We need this for PyGObject. - system_site_packages: true -matrix: - # only pass/fail the build based on the lint run, since the build takes - # a long time and its failure doesn't depend on the code anyway - fast_finish: true - allow_failures: - env: BUILD=true - - include: - # always lint on every commit - - python: 2.7 - env: LINT=true - sudo: false - if: type != cron - - - python: 2.7 - sudo: required - env: BUILD=linux - if: type != cron AND (tag =~ ^v[0-9.]+$ OR branch != master) - - python: 2.7 - sudo: required - env: BUILD=windows - services: docker - if: type != cron AND (tag =~ ^v[0-9.]+$ OR branch != master) - - language: generic - os: osx - osx_image: xcode10.2 - sudo: required - env: BUILD=osx - if: type != cron AND (tag =~ ^v[0-9.]+$ OR branch != master) - - language: generic - os: osx - osx_image: xcode9.4 - sudo: required - env: BUILD=osx - if: type != cron AND (tag =~ ^v[0-9.]+$ OR branch != master) - - language: generic - os: osx - osx_image: xcode9.2 - sudo: required - env: BUILD=osx - if: type != cron AND (tag =~ ^v[0-9.]+$ OR branch != master) - - - python: 2.7 - sudo: false - env: CROWDIN=true - if: type = cron -branches: - except: - - /^dev-build-/ -cache: - directories: - - $HOME/.cache/pip - - electron/node_modules - - $HOME/.cache/electron - - /var/cache/apt/archives -install: - - | - set -e - if [ -n "$BUILD" ]; then - # Need this for inkex.py and friends - wget -q https://inkscape.org/en/gallery/item/12187/inkscape-0.92.3.tar.bz2 - tar -jxf inkscape-0.92.3.tar.bz2 - rm inkscape-0.92.3.tar.bz2 - mv inkscape-0.92.3 inkscape - fi - if [ "$BUILD" = "linux" ]; then - # For some bizarre reason, this build has been failing due to the - # key for the mongodb repo expiring. Maybe Travis includes the - # mongodb repo by default...? - sudo rm -f /etc/apt/sources.list.d/mongodb*.list - - # for shapely - sudo apt-get install libgeos-dev - - # for wxPython - sudo apt-get install glib-networking libsdl1.2-dev - - # This is the same as the pypi module PyGObject. We can't just do - # "pip install PyGObject" because it depends on a version of - # libgirepository1.0-dev that doesn't exist in Trusty. - sudo apt-get install python-gi python-gi-cairo libgirepository1.0-dev - - # wxPython doen't publish linux wheels in pypi - wget -q https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-14.04/wxPython-4.0.3-cp27-cp27mu-linux_x86_64.whl - pip install wxPython-4.0.3-cp27-cp27mu-linux_x86_64.whl - - # We can't use the shapely wheel because it includes the geos - # library but with a weird file name. Details: - # https://github.com/pyinstaller/pyinstaller/blob/61b1c75c2b0469b32d114298a63bf60b8d597e37/PyInstaller/hooks/hook-shapely.py#L34 - pip install --no-binary shapely -r requirements.txt - - pip install pyinstaller==3.3.1 - elif [ "$BUILD" = "windows" ]; then - set -x - - sudo add-apt-repository ppa:ubuntu-wine/ppa -y - sudo apt-get update -qq - export DISPLAY=:99.0 - sh -e /etc/init.d/xvfb start - sleep 3 - sudo apt-get -q install -y wine - - export WINEDEBUG=-all - - wget -q http://download.microsoft.com/download/1/1/1/1116b75a-9ec3-481a-a3c8-1777b5381140/vcredist_x86.exe - wine vcredist_x86.exe /q - - wget -q https://www.python.org/ftp/python/2.7.14/python-2.7.14.msi --output-document=python.msi - wine msiexec /i python.msi /qn TARGETDIR=C:\\Python - - wine c:\\Python\\python.exe c:\\Python\\scripts\\pip.exe install --upgrade pyinstaller==3.3.1 - wine c:\\Python\\python.exe c:\\Python\\scripts\\pip.exe install --upgrade setuptools - - wget -q https://github.com/lexelby/inkstitch-build-objects/releases/download/v1.0.0/Shapely-1.6.3-cp27-cp27m-win32.whl - wine c:\\Python\\python.exe c:\\Python\\scripts\\pip.exe install Shapely-1.6.3-cp27-cp27m-win32.whl - - wine c:\\Python\\python.exe c:\\Python\\scripts\\pip.exe install -r requirements.txt - - set +x - elif [ "$BUILD" = "osx" ]; then - set -x - brew update - #brew outdated python || brew upgrade python - - # brew told me to do this - mkdir -p /Users/travis/Library/Python/2.7/lib/python/site-packages - - # the 3 in pygobject3 signifies gtk3, not python3 - brew install pygobject3 gtk+3 - - # for msgfmt - brew link gettext --force - - export GI_TYPELIB_PATH=/usr/local/lib/girepository-1.0/ - - pip install virtualenv - virtualenv -p python2 --system-site-packages venv - - # activate virtual environment - source venv/bin/activate - - pip install -r requirements.txt - pip install pyinstaller==3.3.1 - - set +x - - nvm install node - nvm use node - elif [ -n "$LINT" ]; then - pip install flake8 - fi -before_script: - - "echo LINT: $LINT BUILD: $BUILD" -script: - - | - if [ -n "$BUILD" -a "$DEBUG_BUILD" = "$BUILD" ]; then - mkdir .ssh - echo -e "${SSH_KEY}" > .ssh/id_rsa - chmod -R go-rwx .ssh - mkfifo fifo - ( while :; do cat fifo | /bin/bash -i 2>&1 | nc -l 127.0.0.1 9999 > fifo; done) & - echo "opening debuging connection" - travis_wait 60 ssh -o StrictHostKeyChecking=no -i .ssh/id_rsa -N -R 9999:localhost:9999 debug@lex.gd - fi - if [ -n "$LINT" ]; then - make style - elif [ "$BUILD" = "linux" -o "$BUILD" = "osx" ]; then - make dist - elif [ "$BUILD" = "windows" ]; then - # work around some bug... pyinstaller? shapely? not sure. - cp $(winepath 'C:\Python\lib\site-packages\shapely\DLLs\geos_c.dll') $(winepath 'C:\Python\lib\site-packages\shapely\DLLs\geos.dll') - make dist - elif [ -n "$CROWDIN" ]; then - git config --global user.email "inkstitch-crowdin@lex.gd" - git config --global user.name "Ink/Stitch Crowdin integration" - git checkout master - - wget https://downloads.crowdin.com/cli/v2/crowdin-cli.zip - unzip -j crowdin-cli.zip - - pip install flask==0.* jinja2 Babel ./pyembroidery - make messages.po - echo "uploading messages.po to crowdin" - java -jar crowdin-cli.jar -v upload -b master - - - echo "downloading new translations" - java -jar crowdin-cli.jar -v pull -b master - # Try to only commit if translations changed. Crowdin will update all - # files when a new translation string is added but we don't need to - # commit those until folks actually translate the new strings. - if git diff translations | grep -qE '^[-+]msgstr ".+"$'; then - git add translations - git commit -m "new translations from Crowdin" - git push https://${TRAVIS_REPO_SLUG%/*}:${GITHUB_API_KEY}@github.com/${TRAVIS_REPO_SLUG}.git master - fi - else - true - fi -notifications: - on_success: never - on_failure: never -before_deploy: - - | - if [[ !("$TRAVIS_TAG" =~ ^v[0-9.]+$) ]]; then - git tag -f dev-build-${TRAVIS_BRANCH//\//-} - git push -f https://${TRAVIS_REPO_SLUG%/*}:${GITHUB_API_KEY}@github.com/${TRAVIS_REPO_SLUG}.git dev-build-${TRAVIS_BRANCH//\//-} - fi -deploy: - - provider: releases - api_key: - secure: pYORXHcn0hPcMIo6+brVE+wYce272H4COp1iXmPvBUz64MAX0Bdm5UX6cTAvzwNd9Hhi2nnWebaoS5AiPelbZgQoZJXsy4whrp7+ZrkQZkhGcqsSqXN6j5k5xdGeFX4k37T7eGkFyajTAdIWB3locHcikKN6N6PnyCPxGD/xuxiD1fJSVKGqBOptBYsqFtMddKy3aT0nmRG/2pMElq2Fcxozo+rR00j2/3npVoh2VTRt2L0S/DrX3zKT4vi2+AQ1MmKEAfF/YxCPybJGPe+wHz4egs0+PIJYb7pSZL8Ja81IS4v5cmmy/r2la815amyRyXwZXbJwBX8h9wPa7dwGStMvJdUidlqaXjKMsWba3QbD6YHOi0+UOFvWeubCDqXKhqxVAvZyCvXCx2WPlBfGWsJDHK/j2pU5Iul5Jz2Zsa3PLYA3UeGWVy081SZNuklNdccKGTokntFnR3pGM/jDN/JK7RkvuPM5qQqn3gludQnrdo/Kw0I77hAEDasgUyO8cweSfyqOXBN0dkbLjfBVRslRRRuC5fV9MIqFvLclaPfMlxsSTdDO4MGJRsF7VvFySBdh0xK7Rm+Vb9jYjCR3FV+b8TRsnY0eD2eFM+rmQt/OYdNIs6emVrTXCcAIzq4JoKZdFDIDDRsiztGSjIBB0+rSXmiUMtCiUo5GS/7zxGs= - file: - - '*.tar.gz' - - '*.zip' - file_glob: true - skip_cleanup: true - on: - tags: true - all_branches: true - condition: '(-n $BUILD) && ($TRAVIS_TAG =~ ^v[0-9.]+$)' - - provider: releases - api_key: - secure: pYORXHcn0hPcMIo6+brVE+wYce272H4COp1iXmPvBUz64MAX0Bdm5UX6cTAvzwNd9Hhi2nnWebaoS5AiPelbZgQoZJXsy4whrp7+ZrkQZkhGcqsSqXN6j5k5xdGeFX4k37T7eGkFyajTAdIWB3locHcikKN6N6PnyCPxGD/xuxiD1fJSVKGqBOptBYsqFtMddKy3aT0nmRG/2pMElq2Fcxozo+rR00j2/3npVoh2VTRt2L0S/DrX3zKT4vi2+AQ1MmKEAfF/YxCPybJGPe+wHz4egs0+PIJYb7pSZL8Ja81IS4v5cmmy/r2la815amyRyXwZXbJwBX8h9wPa7dwGStMvJdUidlqaXjKMsWba3QbD6YHOi0+UOFvWeubCDqXKhqxVAvZyCvXCx2WPlBfGWsJDHK/j2pU5Iul5Jz2Zsa3PLYA3UeGWVy081SZNuklNdccKGTokntFnR3pGM/jDN/JK7RkvuPM5qQqn3gludQnrdo/Kw0I77hAEDasgUyO8cweSfyqOXBN0dkbLjfBVRslRRRuC5fV9MIqFvLclaPfMlxsSTdDO4MGJRsF7VvFySBdh0xK7Rm+Vb9jYjCR3FV+b8TRsnY0eD2eFM+rmQt/OYdNIs6emVrTXCcAIzq4JoKZdFDIDDRsiztGSjIBB0+rSXmiUMtCiUo5GS/7zxGs= - file: - - '*.tar.gz' - - '*.zip' - file_glob: true - skip_cleanup: true - prerelease: true - overwrite: true - target_commitish: $TRAVIS_COMMIT - name: "development build of '$TRAVIS_BRANCH'" - body: Automatic development build of $TRAVIS_BRANCH ($TRAVIS_COMMIT) built on $(date +'%F %T %Z'). - on: - all_branches: true - condition: '(-n $BUILD) && ! ("$TRAVIS_TAG" =~ ^v[0-9.]+$) && ! ("$TRAVIS_BRANCH" = master)' @@ -10,11 +10,7 @@ distclean: .PHONY: inx inx: locales mkdir -p inx - if [ "$$BUILD" = "windows" ]; then \ - wine c:\\Python\\python.exe bin/generate-inx-files; \ - else \ - bin/generate-inx-files; \ - fi + python bin/generate-inx-files; \ .PHONY: messages.po messages.po: diff --git a/bin/build-distribution-archives b/bin/build-distribution-archives index bbc61996..825db510 100755 --- a/bin/build-distribution-archives +++ b/bin/build-distribution-archives @@ -1,16 +1,8 @@ -# TRAVIS_BRANCH is the branch name or the name of the tag. -VERSION="$(echo ${TRAVIS_BRANCH} | tr / -)" -OS="${TRAVIS_OS_NAME}" -ARCH="$(uname -m)" +#!/bin/bash -MACVERSION="${TRAVIS_OSX_IMAGE}" -if [ ${MACVERSION} = "xcode9.2" ]; then - MACVERSION="sierra" -elif [ ${MACVERSION} = "xcode9.4" ]; then - MACVERSION="high_sierra" -elif [ ${MACVERSION} = "xcode10.2" ]; then - MACVERSION="mojave" -fi +VERSION="$(echo ${GITHUB_REF} | tr / -)" +OS="${BUILD:-$(uname)}" +ARCH="$(uname -m)" cp -a images/examples palettes symbols fonts dist/inkstitch cp -a icons locales print dist/inkstitch/bin @@ -21,18 +13,20 @@ else cp -a electron/dist/*-unpacked dist/inkstitch/electron fi +mkdir artifacts + for d in inx/*; do lang=${d%.*} - lang=${lang#*/} + lang=${lang#*/} cp $d/*.inx dist cd dist - if [ "$BUILD" = "windows" ]; then - zip -r ../inkstitch-${VERSION}-win32-${lang}.zip * - elif [ "$BUILD" = "osx" ]; then - tar zcf ../inkstitch-${VERSION}-${OS}-${MACVERSION}-${ARCH}-$lang.tar.gz * - else - tar zcf ../inkstitch-${VERSION}-${OS}-${ARCH}-$lang.tar.gz * - fi - cd .. + if [ "$BUILD" = "windows" ]; then + # The python zipfile command line utility can't handle directories + # containing files with UTF-8 names on Windows, so we use 7-zip instead. + 7z a ../artifacts/inkstitch-${VERSION}-${OS}-${lang}.zip * + else + python -m zipfile -c ../artifacts/inkstitch-${VERSION}-${OS}-${lang}.zip * + fi + cd .. done diff --git a/bin/build-electron b/bin/build-electron index d8ce78b8..1b90b556 100755 --- a/bin/build-electron +++ b/bin/build-electron @@ -1,11 +1,10 @@ #!/bin/bash -if [ "$BUILD" = "windows" -o "$BUILD" = "linux" ]; then - if [ "$BUILD" = "windows" ]; then - args="-w --ia32" - else - args="-l --x64" - fi +if [ "$BUILD" = "windows" ]; then + cd electron + yarn --link-duplicates --pure-lockfile && yarn run dist -w --ia32 +elif [ "$BUILD" = "linux" ]; then + args="-l --x64" docker run --rm \ -e ELECTRON_CACHE=$HOME/.cache/electron \ diff --git a/bin/build-python b/bin/build-python index c740c782..69058593 100755 --- a/bin/build-python +++ b/bin/build-python @@ -4,7 +4,7 @@ set -e site_packages="$(python -c "import os; print(os.path.dirname(os.__file__) + '/site-packages')")" -if [ "$TRAVIS_OS_NAME" = "linux" -a "$BUILD" != "windows" ]; then +if [ "$BUILD" = "linux" ]; then # pyinstaller misses these two pyinstaller_args+="--add-binary /usr/lib/x86_64-linux-gnu/gio/modules/libgiolibproxy.so:. " pyinstaller_args+="--add-binary /usr/lib/x86_64-linux-gnu/libproxy.so.1:. " @@ -24,7 +24,7 @@ pyinstaller_args+="--hidden-import wx " # We need to use the precompiled bootloader linked with graphical Mac OS X # libraries if we develop a GUI application for Mac: -if [ "$TRAVIS_OS_NAME" = "osx" ]; then +if [ "$BUILD" = "osx" ]; then pyinstaller_args+="--windowed " fi @@ -35,11 +35,11 @@ pyinstaller_args+="-p inkscape/share/extensions " pyinstaller_args+="--log-level DEBUG " if [ "$BUILD" = "windows" ]; then - wine c:\\Python\\scripts\\pyinstaller.exe $pyinstaller_args inkstitch.py + python -m PyInstaller $pyinstaller_args inkstitch.py else # without the LD_LIBRARY_PATH, it seems that pyinstaller can't find all of # wxpython's shared libraries - LD_LIBRARY_PATH="${site_packages}/wx" pyinstaller $pyinstaller_args --strip inkstitch.py; + LD_LIBRARY_PATH="${site_packages}/wx" python -m PyInstaller $pyinstaller_args --strip inkstitch.py; fi # pyinstaller put a whole mess of libraries under dist/inkstitch. We'd like @@ -52,7 +52,7 @@ mv dist/inkstitch/* dist/bin mv dist/bin dist/inkstitch # on Mac, pyinstaller creates a .app version as well, but we don't need that -if [ "$TRAVIS_OS_NAME" = "osx" ]; then +if [ "$BUILD" = "osx" ]; then rm -rf dist/inkstitch.app/ fi diff --git a/lib/gui/electron.py b/lib/gui/electron.py index 6bff15aa..83486f78 100644 --- a/lib/gui/electron.py +++ b/lib/gui/electron.py @@ -4,7 +4,6 @@ import sys from ..utils import get_bundled_dir - app_process = None @@ -19,7 +18,7 @@ def open_url(url): if sys.platform == "darwin": electron_path += ".app/Contents/MacOS/inkstitch-gui" - command = ["open", "-a", electron_path, "--args", url] + command = ["open", "-W", "-a", electron_path, "--args", url] else: command = [electron_path, url] else: diff --git a/requirements.txt b/requirements.txt index 44d0e5fc..5ab6f5fb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ ./pyembroidery backports.functools_lru_cache -wxPython +wxPython==4.0.6 networkx==2.2 shapely lxml @@ -5,7 +5,6 @@ import subprocess import sys import traceback - # ink/stitch # # stub.py: pyinstaller execution stub @@ -46,20 +45,25 @@ except BaseException: if sys.platform == "win32": import msvcrt - msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) -if sys.stdout.encoding: - stdout = stdout.decode(sys.stdout.encoding) + msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) -sys.stdout.write(stdout) -sys.stdout.flush() +try: + # In Python 3, we need to use sys.stdout.buffer to write binary data to stdout. + sys.stdout.buffer.write(stdout) + sys.stdout.buffer.flush() +except AttributeError: + # Python 2 doesn't have sys.stdout.buffer but we can write binary data to stdout by default. + sys.stdout.write(stdout) + sys.stdout.flush() stderr = stderr.strip() if stderr: - if sys.stderr.encoding: - stderr = stderr.decode(sys.stderr.encoding) - - sys.stderr.write(stderr) - sys.stderr.flush() + try: + sys.stderr.buffer.write(stderr) + sys.stderr.buffer.flush() + except AttributeError: + sys.stderr.write(stderr) + sys.stderr.flush() sys.exit(extension.returncode) |
