From d9abfe3d52c1a5da3c7e706e6c0a17a87664f32b Mon Sep 17 00:00:00 2001 From: KmolYuan Date: Mon, 23 Sep 2019 13:28:43 +0800 Subject: [PATCH] Add Windows build. --- .travis.yml | 7 ++- appveyor.yml | 72 +++++++++++++++++++++++++----- cython/platform/set_pycompiler.bat | 18 ++++++++ 3 files changed, 82 insertions(+), 15 deletions(-) create mode 100644 cython/platform/set_pycompiler.bat diff --git a/.travis.yml b/.travis.yml index e083cf57..7f05a52d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,3 @@ -language: python - matrix: include: @@ -34,9 +32,10 @@ matrix: os: linux sudo: required dist: xenial + language: python python: "3.6" install: &python-install - - cd cython && python3 -m pip install -r requirements.txt && cd - + - python3 -m pip install -r cython/requirements.txt script: &python-script - cd cython && python3 setup.py test && cd - deploy: @@ -74,7 +73,7 @@ matrix: script: *python-script after_success: # PyPI deployment - - if [ -n "$TRAVIS_TAG" ]; then + - if [ "$TRAVIS_REPO_SLUG" == "KmolYuan/solvespace" && -n "$TRAVIS_TAG" ]; then python3 -m pip install twine; python3 setup.py sdist bdist_wheel; python3 -m twine upload cython/dist/*.whl --skip-existing; diff --git a/appveyor.yml b/appveyor.yml index 560492c1..6f61c24c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,17 @@ version: '{build}' clone_depth: 1 +environment: + MSYS_DIR: C:\msys64 + matrix: + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 + PYTHON_DIR: C:\Python36-x64 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 + PYTHON_DIR: C:\Python37-x64 for: - - image: Visual Studio 2013 + - matrix: + only: + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 before_build: - git submodule update --init - set tag=x%APPVEYOR_REPO_TAG_NAME% @@ -14,6 +24,55 @@ for: - msbuild "build\test\solvespace-testsuite.vcxproj" /verbosity:minimal /property:Configuration=%BUILD_TYPE% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" test_script: - build\bin\%BUILD_TYPE%\solvespace-testsuite.exe + deploy: + - provider: GitHub + auth_token: + secure: P9/pf2nM+jlWKe7pCjMp41HycBNP/+5AsmE/TETrDUoBOa/9WFHelqdVFrbRn9IC + description: "" + artifact: solvespace.exe,solvespace-cli.exe,solvespace.pdb + on: + APPVEYOR_REPO_NAME: solvespace/solvespace + APPVEYOR_REPO_TAG: true + + - matrix: + only: + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 + PYTHON_DIR: C:\Python36-x64 + install: &python-install + # Environment variables + - set Path=%MSYS_DIR%\mingw64\bin;%MSYS_DIR%\usr\bin;%Path% + - set Path=%PYTHON_DIR%;%PYTHON_DIR%\Scripts;%Path% + # Show Python + - python --version + - pip --version + # Upgrade setuptools + - pip install setuptools -U + # Set Python compiler to MinGW + - cython\platform\set_pycompiler %PYTHON_DIR% + # Install modules + - pip install -r cython\requirements.txt + # Show tool kits + - gcc --version + - mingw32-make --version + build_script: &python-script + - cd cython && python setup.py test && cd .. + deploy_script: &python-deploy + # PyPI deployment + - IF "%APPVEYOR_REPO_TAG%"=="true" + IF "%APPVEYOR_REPO_NAME%"=="KmolYuan/solvespace" ( + pip install twine && + cd cython && + python setup.py bdist_wheel && + twine upload dist\*.whl --skip-existing + ) + + - matrix: + only: + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 + PYTHON_DIR: C:\Python37-x64 + install: *python-install + build_script: *python-script + deploy_script: *python-deploy artifacts: - path: build\bin\%BUILD_TYPE%\solvespace.exe @@ -22,13 +81,4 @@ artifacts: name: solvespace-cli.exe - path: build\bin\%BUILD_TYPE%\solvespace.pdb name: solvespace.pdb - -deploy: - - provider: GitHub - auth_token: - secure: P9/pf2nM+jlWKe7pCjMp41HycBNP/+5AsmE/TETrDUoBOa/9WFHelqdVFrbRn9IC - description: "" - artifact: solvespace.exe,solvespace-cli.exe,solvespace.pdb - on: - APPVEYOR_REPO_NAME: solvespace/solvespace - APPVEYOR_REPO_TAG: true + - path: cython\dist\*.whl diff --git a/cython/platform/set_pycompiler.bat b/cython/platform/set_pycompiler.bat new file mode 100644 index 00000000..03ec1ff1 --- /dev/null +++ b/cython/platform/set_pycompiler.bat @@ -0,0 +1,18 @@ +echo off + +REM Usage: set_pycompiler C:\Python37 +REM Where %PYTHON_DIR% is the directory of your Python installation. +REM In Pyslvs project. +set HERE=%~dp0 +set PYTHON_DIR=%1 + +REM Create "distutils.cfg" +echo [build]>> "%PYTHON_DIR%\Lib\distutils\distutils.cfg" +echo compiler=mingw32>> "%PYTHON_DIR%\Lib\distutils\distutils.cfg" + +REM Apply the patch of "cygwinccompiler.py". +REM Unix "patch" command of Msys. +patch "%PYTHON_DIR%\lib\distutils\cygwinccompiler.py" "%HERE%patch.diff" + +REM Copy "vcruntime140.dll" to "libs". +copy "%PYTHON_DIR%\vcruntime140.dll" "%PYTHON_DIR%\libs"