-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge deployment into master to fix wheel building and deployment wit…
…h PR #13 Also bumps version number to 2.0.0
- Loading branch information
Showing
5 changed files
with
146 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
numpy==1.14.0 | ||
pillow==5.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]', | ||
|