Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

setup multibuild for compiling multi-platform wheels #55

Merged
merged 45 commits into from
Jul 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
5115aa0
Add multibuild submodule (master branch)
anthrotype Jul 5, 2018
0b5e0e1
remove redundant tests/.coveragerc
anthrotype Jul 5, 2018
9c4e39b
.gitignore: we store coverage files in .tox, already ignored
anthrotype Jul 5, 2018
21f58db
.gitignore: add htmlcov/ folder
anthrotype Jul 5, 2018
55a8f3c
tests/__init__.py: define DATA_DIR global path to 'tests/data'
anthrotype Jul 5, 2018
d8dd8dd
test_hintfonts: use DATA_DIR global; save output to tmpdir
anthrotype Jul 5, 2018
af4bfcf
test_hintfontsmm: reference and outputs in tmpdir, use DATA_DIR
anthrotype Jul 5, 2018
2044481
.coveragerc: fix source/paths, skip_covered, etc.
anthrotype Jul 5, 2018
31dd5ed
setup.py: add test requirements to 'testing' extra
anthrotype Jul 5, 2018
5cd503d
dev-requirements.txt: only tox; the rest is handled by tox
anthrotype Jul 5, 2018
2f2bf3b
tox.ini: run in parallel with combined coverage, etc.
anthrotype Jul 5, 2018
d6627e7
tox.ini: split 'sdist' and 'bdist' environments
anthrotype Jul 5, 2018
a808f1c
travis: set up multibuild
anthrotype Jul 5, 2018
76bbcc7
add multibuild's config.sh setup file
anthrotype Jul 5, 2018
83e9e4b
tox.ini: set TOXPYTHON env variable for finding Appveyor pythons
anthrotype Jul 5, 2018
c2a9ccd
tox.ini: add 'wheel' and 'pypi' commands
anthrotype Jul 5, 2018
d5d95b8
appveyor: build wheels for both 32 and 64 bit, etc.
anthrotype Jul 5, 2018
ae22900
tox.ini: passenv TWINE_USERNAME and TWINE_PASSWORD
anthrotype Jul 5, 2018
e6a0ff1
tox.ini: must define 'basepython' with TOXPYTHON else Appveyor fails
anthrotype Jul 5, 2018
93bf66b
config.sh: apply codacy suggestions
anthrotype Jul 5, 2018
dcbb522
appveyor doesn't like my batch if statement.. let's try powershell
anthrotype Jul 5, 2018
2bb40b7
.travis: need to install tox on Travis default python to be able to u…
anthrotype Jul 5, 2018
2c68fde
tox.ini: need to create sdist to build wheel from it!
anthrotype Jul 5, 2018
a05737c
tox.ini: make 'pypi-wheel' environment; called by Appveyor on tags
anthrotype Jul 5, 2018
b0d90e4
.travis: on osx we need to bootstrap pip in order to install tox...
anthrotype Jul 5, 2018
58c6132
travis: move the osx pip bootstrapping in 'after_success'
anthrotype Jul 5, 2018
b2a91cb
appveyor: disable 2.7 64-bit and 3.6 32-bit.. too slow :(
anthrotype Jul 5, 2018
4caa670
config.sh: remove .tox folder after run_tests to fix permission errors
anthrotype Jul 5, 2018
a28434b
tox.ini: allow to control PYTEST_NUM_PROCESSES via env variable
anthrotype Jul 6, 2018
4d76735
psautohint: always use utf-8 for reading/writing text files
anthrotype Jul 6, 2018
b3cc245
config.sh: .tox dir to clean up is one dir above
anthrotype Jul 6, 2018
1c177ee
ufoFont: fix TypeError when writeHashMap
anthrotype Jul 6, 2018
7f07b7e
travis: after 'before_install', we've already sourced a venv
anthrotype Jul 6, 2018
7257a03
ufoFont: use ET.parse(path).getroot() instead of ET.XML(string)
anthrotype Jul 6, 2018
c951a3c
config.in: cd.. back to repository root before calling tox
anthrotype Jul 6, 2018
3c096d7
tox: use a single 'codecov' env that inherits from 'coverage' env
anthrotype Jul 6, 2018
1552510
put .coverage files outside .tox dir at root of repo
anthrotype Jul 6, 2018
4998b48
travis: add deploy stage; save pip cache
anthrotype Jul 6, 2018
632b68c
travis: add encrypted pypi password
anthrotype Jul 6, 2018
35b6813
appveyor: add same TWINE_USERNAME and TWINE_PASSWORD as afdko repo
anthrotype Jul 6, 2018
87e1dcb
tests/__init__: minor
anthrotype Jul 6, 2018
0ab12f5
tox.ini: remove unused 'pypi-wheel' env; we call twine directly now
anthrotype Jul 6, 2018
40741f7
[ci-travis] Configure twine [skip ci]
miguelsousa Jul 6, 2018
c46ed0c
[ci-appveyor] Configure twine
miguelsousa Jul 6, 2018
3dcf59a
appveyor: compile wheel first, then run tests; reuse same wheel for PyPI
anthrotype Jul 6, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 80 additions & 8 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,93 @@
cache:
- '%LOCALAPPDATA%\pip\Cache'

environment:
global:
TWINE_USERNAME: "adobe-type-tools-ci"
# TWINE_PASSWORD is set in Appveyor settings

matrix:
- TOXENV: py27-cov
- TOXENV: py36-cov
- PYTHON: "C:\\Python27"
PYTHON_VERSION: "2.7"
PYTHON_ARCH: "32"
TOXENV: "py27-cov"
TOXPYTHON: "C:\\Python27\\python.exe"

# - PYTHON: "C:\\Python36"
# PYTHON_VERSION: "3.6"
# PYTHON_ARCH: "32"
# TOXENV: "py36-cov"
# TOXPYTHON: "C:\\Python36\\python.exe"

# - PYTHON: "C:\\Python27-x64"
# PYTHON_VERSION: "2.7"
# PYTHON_ARCH: "64"
# TOXENV: "py27-cov"
# TOXPYTHON: "C:\\Python27-x64\\python.exe"

- PYTHON: "C:\\Python36-x64"
PYTHON_VERSION: "3.6"
PYTHON_ARCH: "64"
TOXENV: "py36-cov"
TOXPYTHON: "C:\\Python36-x64\\python.exe"

matrix:
fast_finish: true

skip_branch_with_pr: true

init:
- "ECHO %PYTHON% %PYTHON_VERSION% %PYTHON_ARCH%"

install:
- git submodule update --init
- python -m pip install --upgrade pip
- pip install -r requirements.txt
- pip install -r dev-requirements.txt
# checkout git sub-modules
- git submodule update --init --recursive

# prepend newly installed Python to the PATH
- SET PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%

# check that we have the expected version and architecture for Python
- python --version
- python -c "import struct; print(struct.calcsize('P') * 8)"

# upgrade pip to avoid out-of-date warnings
- python -m pip install --disable-pip-version-check --upgrade pip
- python -m pip --version

# install tox
- python -m pip install -r dev-requirements.txt

# build psautohint wheel
- tox -e wheel
- for /f "usebackq tokens=*" %w in (`dir /b dist\psautohint*.whl`) do set WHEEL_PATH=%cd%\dist\%w

build: false

test_script:
- tox
# run tests on the compiled wheel
- tox --installpkg "%WHEEL_PATH%"

on_success:
# upload test coverage to codecov.io
- tox -e codecov
# if commit is tagged, upload wheel to PyPI
- ps: >-
if($env:APPVEYOR_REPO_TAG -eq 'true') {
Write-Output ("Deploying " + $env:APPVEYOR_REPO_TAG_NAME + " to PyPI...")
pip install --upgrade twine
twine upload $env:WHEEL_PATH
} else {
Write-Output "Not deploying as this is not a tagged commit"
}

skip_branch_with_pr: true
on_failure:
# print the content of tox *.log files
- ps: Get-Content .tox\\log\\*.log
- ps: $envlogdir = ".tox\\" + ${env:TOXENV} + "\\log"; `
foreach($logfile in Get-ChildItem $envlogdir){ `
$logpath = $envlogdir + "\\" + $logfile; `
Get-Content -path $logpath }

artifacts:
# archive the generated packages in the ci.appveyor.com build report
- path: dist\*.whl
18 changes: 13 additions & 5 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
# measure 'branch' coverage in addition to 'statement' coverage
# See: http://coverage.readthedocs.io/en/coverage-4.5.1/branch.html
branch = True
parallel = True

# list of directories or packages to measure
source = psautohint

# these are treated as equivalent when combining data
[paths]
source =
python/psautohint

omit =
*/__init__.py
.tox/*/lib/python*/site-packages/psautohint
.tox/*/Lib/site-packages/psautohint
.tox/pypy*/site-packages/psautohint

[report]
# Regexes for lines to exclude from consideration
Expand All @@ -18,11 +21,16 @@ exclude_lines =
pragma: no cover

# don't complain if tests don't hit defensive assertion code
# ...
raise AssertionError
raise NotImplementedError

# don't complain if non-runnable code isn't run
if 0:
if __name__ == .__main__.:

# Don't include files that are 100% covered
skip_covered = True

# ignore source code that can’t be found
ignore_errors = True

Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ MANIFEST
build
dist
.DS_Store
tests/.coverage*
.tox/
.pytest_cache/
.coverage*
htmlcov/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
path = tests/data
url = https://github.com/adobe-type-tools/psautohint-testdata.git
ignore = dirty
[submodule "multibuild"]
path = multibuild
url = https://github.com/matthew-brett/multibuild/
99 changes: 69 additions & 30 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,82 @@
dist: trusty
sudo: false

sudo: required
language: python
# The travis Python version is unrelated to the version we build and test
# with. This is set with the MB_PYTHON_VERSION variable.
python: 3.5
services: docker

branches:
only:
- master
# We want to build wip/* branches since these are not usually used for PRs
- /^wip\/.*$/
# We want to build version tags as well.
- /^v\d+\.\d+.*$/

env:
global:
# directory containing the project source
- REPO_DIR=.
# pip dependencies to _build_ project
# - BUILD_DEPENDS="..."
# pip dependencies to _test_ project
- TEST_DEPENDS="-rdev-requirements.txt"
- PLAT=x86_64
- UNICODE_WIDTH=32
- TWINE_USERNAME=adobe-type-tools-ci
# TWINE_PASSWORD is set in Travis settings

matrix:
exclude:
# Exclude the default Python 3.5 build
- python: 3.5
include:
- python: 2.7
env: TOXENV=py27-cov
- python: 3.6
env: TOXENV=py36-cov
# The 'osx' environment uses the python2.7 by default.
# TODO: maybe also tests python3 on macOS
- language: generic
os: osx
env: TOXENV=py27-cov
- os: linux
env:
- MB_PYTHON_VERSION=2.7
- os: linux
env:
- MB_PYTHON_VERSION=3.6
- os: osx
language: generic
env:
- MB_PYTHON_VERSION=2.7
- os: osx
language: generic
env:
- MB_PYTHON_VERSION=3.6

cache: pip

before_install:
- source multibuild/common_utils.sh
- source multibuild/travis_steps.sh
- before_install

install:
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then
curl -O https://bootstrap.pypa.io/get-pip.py;
python get-pip.py --user;
python -m pip install --user virtualenv;
python -m virtualenv .venv/;
source .venv/bin/activate;
fi
- pip install --upgrade pip
- pip install -r requirements.txt
- pip install -r dev-requirements.txt
- build_wheel $REPO_DIR $PLAT

script:
- tox
- tox -e bdist
- install_run $PLAT

after_success:
- pip install tox
# upload code coverage to Codecov.io
- tox -e codecov
# if tagged, create the source distribution for the deploy stage
- if [ -n "$TRAVIS_TAG" ] && [ "$BUILD_SDIST" == true ]; then tox -e sdist; fi
# copy compiled wheels to dist/ where Travis `dpl` tool can find them and upload to PyPI
- if [ -n "$TRAVIS_TAG" ]; then mkdir -p dist; cp wheelhouse/*.whl dist; fi

branches:
only:
- master
# We want to build wip/* branches since these are not usually used for PRs
- /^wip\/.*$/
# We want to build version tags as well.
- /^v\d+\.\d+.*$/
deploy:
provider: pypi
on:
tags: true
repo: adobe-type-tools/psautohint
all_branches: true
# 'check' is a do-nothing setup.py command, to prevent Travis from trying
# to rebuild the wheel we just built with multibuild
distributions: check
skip_cleanup: true
skip_upload_docs: true
34 changes: 34 additions & 0 deletions config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

# Define custom utilities
# Test for OSX with [ -n "$IS_OSX" ]

function pre_build {
# Any stuff that you need to do before you start building the wheels
# Runs in the root directory of this repository.
:
}

function run_tests {
# The function is called from an empty temporary directory.
cd ..

# Get absolute path to the pre-compiled wheel
wheelhouse=$(abspath wheelhouse)
wheel=$(ls ${wheelhouse}/psautohint*.whl | head -n 1)
if [ ! -e "${wheel}" ]; then
echo "error: can't find wheel in ${wheelhouse} folder" 1>&2
exit 1
fi

# select tox environment based on the current python version
# E.g.: '2.7' -> 'py27-cov'
TOXENV="py${MB_PYTHON_VERSION//\./}-cov"

# Install pre-compiled wheel and run tests against it
tox --installpkg "${wheel}" -e "${TOXENV}"

# clean up after us, or else running tox later on outside the docker
# container can lead to permission errors
rm -rf .tox
}
5 changes: 0 additions & 5 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
# required for formatting the 'long_description' as Markdown
setuptools>=36.4.0
wheel>=0.31.0

coverage>=4.5.1
tox>=2.9.1
1 change: 1 addition & 0 deletions multibuild
Submodule multibuild added at 7cca00
2 changes: 1 addition & 1 deletion python/psautohint/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ def main(args=None):
options = get_options(args)

if options.logFile:
open(options.logFile, 'w')
open(options.logFile, 'w', encoding="utf-8")

try:
hintFiles(options)
Expand Down
4 changes: 2 additions & 2 deletions python/psautohint/otfFont.py
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,7 @@ def getfdInfo(self, fontPSName, inputPath, allow_no_blues, noFlex,
srcFontInfo = os.path.dirname(inputPath)
srcFontInfo = os.path.join(srcFontInfo, "fontinfo")
if os.path.exists(srcFontInfo):
with open(srcFontInfo, "rU") as fi:
with open(srcFontInfo, "r", encoding="utf-8") as fi:
fontInfoData = fi.read()
fontInfoData = re.sub(r"#[^\r\n]+", "", fontInfoData)
else:
Expand Down Expand Up @@ -1368,7 +1368,7 @@ def test2():
# Takes first argument = bez path, writes T2 string.
# Use form "cid0769" for CID keys references.
path = sys.argv[1]
with open(path, "rt") as fp:
with open(path, "rt", encoding="utf-8") as fp:
bezString = fp.read()

convertBezToT2(bezString)
Expand Down
Loading