Skip to content

Commit

Permalink
Merge deployment into master to fix wheel building and deployment wit…
Browse files Browse the repository at this point in the history
…h PR #13

Also bumps version number to 2.0.0
  • Loading branch information
RedFantom authored Jan 27, 2018
1 parent a0b3864 commit c9fdd1b
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 39 deletions.
25 changes: 14 additions & 11 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@ environment:
- PYTHON: "C:\\PYTHON35-x64"
- PYTHON: "C:\\PYTHON36"
- PYTHON: "C:\\PYTHON36-x64"
install:
- "%PYTHON%\\python.exe -m pip install codecov coverage nose"
- "%PYTHON%\\python.exe -m pip install setuptools pip wheel --upgrade"
build: off
test_script:
- "%PYTHON%\\python.exe setup.py install"
- "rd /s /q ttkthemes"
- "%PYTHON%\\python.exe -m nose --with-coverage --cover-package=ttkthemes --cover-xml"
after_test:
- "%PYTHON%\\Scripts\\codecov.exe -f C:\\projects\\ttk-themes\\coverage.xml"
- "%PYTHON%\\python.exe setup.py bdist_wheel"
- "%PYTHON%\\python.exe ci.py"
artifacts:
- path: "dist/*.whl"
name: "wheel-windows-%PYTHON%"
- path: "dist\\*.whl"
deploy:
provider: GitHub
auth_token:
secure: QimY++/91urL/oMJL/q2zYFqc1C7747HguEaIbPQovtC3zG8CK+TiCmFOCXy1D6e
artifact: dist/*.whl
draft: false
prerelease: false
force_update: true
on:
branch: master
appveyor_repo_tag: true

38 changes: 11 additions & 27 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,40 @@ matrix:
include:
- os: linux
python: '2.7'
env: PYTHON=python PIP="python -m pip" NOSE="-m nose"
env: PYTHON=python NUMBER="27" OS="linux"
- os: linux
python: '3.4'
env: PYTHON=python PIP="python -m pip" NOSE="-m nose"
env: PYTHON=python NUMBER="34" OS="linux"
- os: linux
python: '3.5'
env: PYTHON=python PIP="python -m pip" NOSE="-m nose"
env: PYTHON=python NUMBER="35" OS="linux"
- os: linux
python: '3.6'
env: PYTHON=python PIP="python -m pip" NOSE="-m nose"
env: PYTHON=python NUMBER="36" OS="linux"
- os: osx
language: generic
env: PYTHON=python PIP=pip2 NOSE="-m nose"
- os: osx
language: generic
env: PYTHON=python3 PIP=pip3 NOSE="-m nose"
env: PYTHON=python3 PIP=pip3 NUMBER="36" OS="darwin"
allow_failures:
- os: osx

env: PACKAGES="python-tk python3-tk libtk-img"

before_install:
# Linux
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
export DISPLAY=:99.0;
sh -e /etc/init.d/xvfb start;
sleep 3;
sudo apt-get install $PACKAGES;
$PIP install codecov coverage nose pip setuptools -U;
else
brew install python python3 || echo "Installed Python";
fi;
# macOS
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
brew install $PYTHON pipenv || echo "Installed PipEnv";
sudo -H $PIP install codecov coverage nose pip setuptools -U;
fi;

script:
- $PIP install .
- rm -rf ttkthemes
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then $PYTHON $NOSE --with-coverage --cover-xml --cover-package=ttkthemes; fi;

after_success:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then $PYTHON -m codecov -f coverage.xml; fi;
- $PYTHON setup.py bdist_wheel
- $PYTHON ci.py

deploy:
provider: releases
api_key:
secure: jIWRWxe9KbnrHCYPv0LbGda57N/NeN2ns0C+ZWTzYQYeD11rSv4UKjq0RdzsXicA4XV1sN5bFG0bSdM9ap7NPblFmuFo2VF5hTyS3tv8E3oVHOexIfwb6HSoBHfd8ijhmLxJQ8f057WZE12xBeW4YYwhjCPf3wXEinkg3U1moKZz0FCuLdlALIOMg/qlMzX17w4jIgoU/aHRx0d/eLZBcTr4WNMgE91KK/BMyHrajG+oy8bM4M/Tf0ILynJLiUHMbONGHo43apnr+s4OllEsxZjh4Min25x9CUQzPSm4wFWGM2Ypa+3R+MnqmfYKhDQNW7Cj+4GArDdbaG2oK4BTJZ9wn6YcKVC7saU4vDHdpHrz/DdC0XAuvOobT+hUJcIOmJ5uoJp6H61719SvQmbLtaHvzEVEb66qPvXHGgJkEXhOtkfWQAX4p/2ipL9UMy8cP4lXNG0/ESkBsJj1JbIoh+w+jP8wGzBVuSYsV2ESefTvxRqg5lZqFUmvg+FIjbT2fQEl5G9CTx1nVQ6E91cOaVOZQuNMZ7/XHg90u5O8NsXwtJtYIvSlDgyAggSss7nvrpNq2ej9e2ZC+i7ESik/V6NxzG9CWV7aMXwV8+OUovInNZt2w1ZNpcijRGOzlEduB6MDeRKdq4r1+Zcljf6pwdH40gH4yR01dvc6s8WmmoI=
file: dist/*.whl
file: "dist/*.whl"
file_glob: true
skip_cleanup: true
on:
repo: RedFantom/ttkthemes
tags: true
118 changes: 118 additions & 0 deletions ci.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
"""
Author: RedFantom
License: GNU GPLv3
Copyright (c) 2017-2018 RedFantom
"""
# Standard library imports only
import sys
import os
import shutil

DEPENDENCIES = ["numpy", "pillow"]
REQUIREMENTS = ["codecov", "coverage", "nose", "setuptools", "pip", "wheel"]
PACKAGES = "python-tk python3-tk libtk-img"


def run_command(command):
"""
:param command: command to run on os.system
:return: exit code
"""
print("Running system command: ", command)
return_info = os.system(command)
if sys.platform == "win32":
return return_info
else:
return os.WEXITSTATUS(return_info)


def check_wheel_existence():
"""Return True if a wheel is built"""
return len([file for file in os.listdir("dist") if file.endswith(".whl")]) != 0


def ci(python="python", codecov="codecov", coverage_file="coverage.xml"):
"""
Run the most common CI tasks
"""
# Upgrade pip and setuptools and install dependencies
import pip
pip.main(["install"] + DEPENDENCIES + REQUIREMENTS + ["-U"])
# Build the installation wheel
return_code = run_command("{} setup.py bdist_wheel".format(python))
if return_code != 0:
print("Building and installing wheel failed.")
exit(return_code)
assert os.path.exists(os.path.join("ttkthemes", "tkimg"))
# Check if an artifact exists
assert check_wheel_existence()
print("Wheel file exists.")
# Install the wheel file
wheel = [file for file in os.listdir("dist") if file.endswith(".whl")][0]
print("Wheel file:", wheel)
return_code = run_command("{} -m pip install {}".format(python, wheel))
if return_code != 0:
print("Installation of wheel failed.")
exit(return_code)
print("Wheel file installed.")
# Run the tests
return_code = run_command("{} -m nose --with-coverage --cover-xml --cover-package=ttkthemes".format(python))
if return_code != 0:
print("Tests failed.")
exit(return_code)
print("Tests successful.")
# Run codecov
return_code = run_command("{} -f {}".format(codecov, coverage_file))
if return_code != 0:
print("Codecov failed.")
exit(return_code)
# Successfully finished CI
exit(0)


def ci_windows():
"""
Run CI tasks on AppVeyor. CI on AppVeyor is relatively easy, so
just the general ci() is used.
"""
ci(
python="%PYTHON%\\python.exe",
codecov="%PYTHON%\\Scripts\\codecov.exe",
coverage_file="C:\\projects\\ttk-themes\\coverage.xml"
)


def ci_macos():
"""
Setup Travis-CI macOS for wheel building
"""
run_command("brew install $PYTHON pipenv || echo \"Installed PipEnv\"")
command_string = "sudo -H $PIP install "
for element in DEPENDENCIES + REQUIREMENTS + ["-U"]:
command_string += element + " "
run_command(command_string)
# Build a wheel
run_command("sudo -H $PYTHON setup.py bdist_wheel")
assert check_wheel_existence()
exit(0)


def ci_linux():
"""
Setup Travis-CI linux for installation and testing
"""
run_command("sudo apt-get install {}".format(PACKAGES))
ci()


# Run CI tasks on AppVeyor and Travis-CI (macOS and Linux)
if __name__ == '__main__':
if sys.platform == "win32":
ci_windows()
elif "linux" in sys.platform: # linux2 on Python 2, linux on Python 3
ci_linux()
elif sys.platform == "darwin":
ci_macos()
else:
raise RuntimeError("Invalid platform: ", sys.platform)

2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
numpy==1.14.0
pillow==5.0.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def read(fname):
name='ttkthemes',
packages=['ttkthemes'],
package_data={"ttkthemes": ["themes/*", "tkimg/*"]},
version='1.5.2',
version='2.0.0',
description='A group of themes for the ttk extensions of Tkinter with a Tkinter.Tk wrapper',
author='The ttkthemes authors',
author_email='[email protected]',
Expand Down

0 comments on commit c9fdd1b

Please sign in to comment.