Skip to content

Commit

Permalink
Merge pull request #2746 from wiredfool/msys2
Browse files Browse the repository at this point in the history
Changes to cleanly compile on windows/msys2
  • Loading branch information
wiredfool committed Sep 20, 2017
2 parents e11b478 + 5c77fbb commit 2479019
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 10 deletions.
42 changes: 35 additions & 7 deletions appveyor.yml
Expand Up @@ -10,6 +10,8 @@ environment:
EXECUTABLE: python.exe
PIP_DIR: Scripts
VENV: NO
TEST_OPTIONS:
DEPLOY: YES
matrix:
- PYTHON: C:/vp/pypy2
EXECUTABLE: bin/pypy.exe
Expand All @@ -21,6 +23,11 @@ environment:
- PYTHON: C:/Python34-x64
- PYTHON: C:/Python33
- PYTHON: C:/Python33-x64
- PYTHON: C:/msys64/mingw32
EXECUTABLE: bin/python3
PIP_DIR: bin
TEST_OPTIONS: --processes=0
DEPLOY: NO


install:
Expand All @@ -36,19 +43,38 @@ install:
{
c:\pillow\winbuild\appveyor_install_pypy.cmd
}
- c:\python34\python.exe c:\pillow\winbuild\build_dep.py
- c:\pillow\winbuild\build_deps.cmd

- ps: |
if ($env:PYTHON -eq "c:/msys64/mingw32")
{
c:\msys64\usr\bin\bash -l -c c:\\pillow\\winbuild\\appveyor_install_msys2_deps.sh
}
else
{
c:\python34\python.exe c:\pillow\winbuild\build_dep.py
c:\pillow\winbuild\build_deps.cmd
$host.SetShouldExit(0)
}
build_script:
- '%PYTHON%\%EXECUTABLE% c:\pillow\winbuild\build.py'
- ps: |
if ($env:PYTHON -eq "c:/msys64/mingw32")
{
c:\msys64\usr\bin\bash -l -c c:\\pillow\\winbuild\\appveyor_build_msys2.sh
Write-Host "through install"
$host.SetShouldExit(0)
}
else
{
& $env:PYTHON/$env:EXECUTABLE c:\pillow\winbuild\build.py
$host.SetShouldExit(0)
}
- cd c:\pillow
- dir dist\*.egg
- '%PYTHON%\%EXECUTABLE% selftest.py --installed'

test_script:
- cd c:\pillow
- '%PYTHON%\%PIP_DIR%\pip.exe install nose'
- '%PYTHON%\%EXECUTABLE% test-installed.py -v -s'
- '%PYTHON%\%EXECUTABLE% test-installed.py -v -s %TEST_OPTIONS%'

matrix:
fast_finish: true
Expand All @@ -59,7 +85,7 @@ artifacts:
- path: pillow\dist\*.wheel
name: wheel

after_test:
before_deploy:
- '%PYTHON%\%PIP_DIR%\pip.exe install wheel'
- cd c:\pillow\winbuild\
- '%PYTHON%\%EXECUTABLE% c:\pillow\winbuild\build.py --wheel'
Expand All @@ -77,6 +103,8 @@ deploy:
artifact: /.*egg|wheel/
on:
branch: master
deploy: YES


# Uncomment the following line to get RDP access after the build/test and block for
# up to the timeout limit (~1hr)
Expand Down
9 changes: 6 additions & 3 deletions setup.py
Expand Up @@ -17,7 +17,7 @@
import subprocess

from distutils.command.build_ext import build_ext
from distutils import sysconfig
from distutils import sysconfig, ccompiler
from setuptools import Extension, setup, find_packages

# monkey patch import hook. Even though flake8 says it's not used, it is.
Expand All @@ -44,6 +44,9 @@
class DependencyException(Exception): pass
class RequiredDependencyException(Exception): pass

PLATFORM_MINGW = 'mingw' in ccompiler.get_default_compiler()
PLATFORM_PYPY = hasattr(sys, 'pypy_version_info')

def _dbg(s, tp=None):
if DEBUG:
if tp:
Expand Down Expand Up @@ -607,7 +610,7 @@ def build_extensions(self):
if struct.unpack("h", "\0\1".encode('ascii'))[0] == 1:
defs.append(("WORDS_BIGENDIAN", None))

if sys.platform == "win32" and not hasattr(sys, 'pypy_version_info'):
if sys.platform == "win32" and not (PLATFORM_PYPY or PLATFORM_MINGW):
defs.append(("PILLOW_VERSION", '"\\"%s\\""'%PILLOW_VERSION))
else:
defs.append(("PILLOW_VERSION", '"%s"'%PILLOW_VERSION))
Expand Down Expand Up @@ -781,7 +784,7 @@ def debug_build():
test_suite='nose.collector',
keywords=["Imaging", ],
license='Standard PIL License',
zip_safe=not debug_build(), )
zip_safe=not (debug_build() or PLATFORM_MINGW), )
except RequiredDependencyException as err:
msg = """
Expand Down
3 changes: 3 additions & 0 deletions winbuild/appveyor_build_msys2.sh
@@ -0,0 +1,3 @@
#!/bin/sh

cd /c/pillow && /mingw32/$EXECUTABLE setup.py install
11 changes: 11 additions & 0 deletions winbuild/appveyor_install_msys2_deps.sh
@@ -0,0 +1,11 @@
#!/bin/sh

pacman -S --noconfirm mingw32/mingw-w64-i686-python3 \
mingw32/mingw-w64-i686-python3-pip \
mingw32/mingw-w64-i686-python3-setuptools \
mingw32/mingw-w64-i686-python2-pip \
mingw32/mingw-w64-i686-python2-setuptools \
mingw-w64-i686-libjpeg-turbo

/mingw32/bin/pip install nose olefile
/mingw32/bin/pip3 install nose olefile

0 comments on commit 2479019

Please sign in to comment.