Skip to content
This repository has been archived by the owner on Dec 18, 2019. It is now read-only.

Commit

Permalink
Merge pull request #51 from will7200/appveyor
Browse files Browse the repository at this point in the history
Update appveyor config
  • Loading branch information
will7200 authored Mar 25, 2018
2 parents f9860da + e783b95 commit 312dad5
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Join the chat at https://gitter.im/Yugioh-bot/Lobby](https://badges.gitter.im/Yugioh-bot/Lobby.svg)](https://gitter.im/Yugioh-bot/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Discord](https://img.shields.io/discord/392538066633359360.svg?colorB=0082ff&style=flat)](https://discord.gg/PGWedhf)
[![Software License][ico-license]](LICENSE)
[![Build Status][ico-travis]][link-travis]
[![Build status](https://ci.appveyor.com/api/projects/status/fk0j6na84w1mw7du/branch/master?svg=true)](https://ci.appveyor.com/project/will7200/yugioh-bot/branch/master)
[![Coverage Status](https://coveralls.io/repos/github/will7200/Yugioh-bot/badge.svg?branch=master)](https://coveralls.io/github/will7200/Yugioh-bot?branch=master)
[![Quality Score][ico-code-quality]][link-code-quality]

Expand Down
20 changes: 19 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ build_script:
- "%PYTHON%\\Scripts\\pyinstaller.exe main.spec"
- "%PYTHON%\\python.exe fix_build.py"

after_build:
- 7z a dlbot.zip dist\dlbot\*
test_script:
# Put your test command here.
# If you don't need to build C extensions on 64-bit Python 3.3 or 3.4,
Expand All @@ -32,7 +34,7 @@ test_script:
# Note that you must use the environment variable %PYTHON% to refer to
# the interpreter you're using - Appveyor does not do anything special
# to put the Python version you want to use on PATH.
- "%PYTHON%\\python.exe setup.py test"
- "rem"

after_test:
# This step builds your wheels.
Expand All @@ -44,8 +46,24 @@ after_test:

artifacts:
# bdist_wheel puts your built wheel in the dist directory
- path: dlbot.zip
name: botexe

- path: dist\*
name: wheels

deploy:
release: DLBOT-v$(appveyor_build_version)
description: 'DLBOT release; Dont forget to run dlbot.exe setup.'
provider: GitHub
auth_token:
secure: bXsbrwh3sAaJTLKxuYVrwDWgwhd5d2zCTtxAhT4/sLeG6iVFhvv6RqkYcSx9zfQ8 # your encrypted token from GitHub
artifact: dlbot.zip # upload all NuGet packages to release assets
draft: false
prerelease: false
on:
branch: master # release from master branch only
#appveyor_repo_tag: true # deploy on tag push only
#on_success:
# You can use this step to upload your artifacts to a public website.
# See Appveyor's documentation for more details. Or you can simply
Expand Down
22 changes: 19 additions & 3 deletions fix_build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
import os
from distutils.dir_util import copy_tree
from glob import glob

copy_folders = [
'APScheduler-*',
'setuptools*',
'six-*',
'pytz*',
'tzlocal*',

]


def copy_file():
copy_tree(os.path.join(os.environ.get('PYTHON'), r'Lib\site-packages\APScheduler-3.4.0-py3.5.egg-info'), 'dist/dlbot/APScheduler-3.4.0-py3.5.egg-info')
copy_tree(r'dist/dlbot/PyQt5/Qt/plugins',r'dist/dlbot')
os.remove('dist/dlbot/APScheduler-3.4.0-py3.5.egg-info/requires.txt')
site_packages = os.path.join(os.environ.get('PYTHON'), 'Lib', 'site-packages')
for folder in copy_folders:
setupfolders = glob(os.path.join(site_packages, folder))
for f in setupfolders:
foldername = os.path.basename(f)
copy_tree(f,
'dist/dlbot/{}'.format(foldername))
copy_tree(r'dist/dlbot/PyQt5/Qt/plugins', r'dist/dlbot')
# os.remove('dist/dlbot/{}/requires.txt'.format(apscheduler_foldername))


if __name__ == "__main__":
Expand Down
39 changes: 28 additions & 11 deletions install.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import re
from colorama import init
from colorama import Fore, Back, Style

init(autoreset=True)
# THESE ARE THE PARAMETERS USED TO CHECK AND INSTALL
# Change these to suit your needs
Expand All @@ -18,6 +19,7 @@
NOX_BIN = os.path.join(os.environ.get(
'USERPROFILE'), 'AppData', 'Roaming', 'Nox', 'bin')
NOX_BIN_OTHER = os.path.join(r'C:\Program Files (x86)\Nox\bin')
SKIP_PIP_TEST = False


def run_command(command, check_output=False):
Expand Down Expand Up @@ -95,7 +97,7 @@ def download_tesseract():
tess_links = list(filter(lambda x: re.search(
tess_search, x.text_content()), links))
original_link = list(filter(lambda x: x.text_content()
== tess_tested_against, links))
== tess_tested_against, links))
if len(original_link) == 1:
tess_download = original_link[0]
print(Back.GREEN + 'Found Expected Tesseract on site ({}), downloading'.format(
Expand Down Expand Up @@ -136,17 +138,25 @@ def install_tesseract():
except FileNotFoundError:
print("Oooo something happened when I downloaded the file, rerun this script")


def set_pip_test(value):
global SKIP_PIP_TEST
SKIP_PIP_TEST = value


def check_required_packages():
if SKIP_PIP_TEST:
return
installed_packages = pip.get_installed_distributions()
packages = {}
for package in installed_packages:
packages[package.project_name] = package.version
with open('requirements.txt') as f:
required = list(map(lambda x: x.split('=')[0].replace('>',''), f.read().splitlines()))
required = list(map(lambda x: x.split('=')[0].replace('>', ''), f.read().splitlines()))
required = filter(lambda x: not '#' in x, required)
all_installed = True
for x in required:
if x in ['scikit_image','scikit_learn','opencv_contrib_python']:
if x in ['scikit_image', 'scikit_learn', 'opencv_contrib_python']:
continue
if x not in packages:
print(Back.YELLOW + "Not in pip {}".format(x))
Expand All @@ -159,15 +169,17 @@ def check_required_packages():
print(Back.RED + "Import error for package")
print(Back.Red + e)
if not all_installed:
print(Back.RED + Style.BRIGHT + "Not all packages required were found\ntry running `pip -r requirements.txt` again" + Back.CYAN)
print(
Back.RED + Style.BRIGHT + "Not all packages required were found\ntry running `pip -r requirements.txt` again" + Back.CYAN)
else:
print(Back.GREEN + "All required packages found"+ Back.CYAN)
print(Back.GREEN + "All required packages found" + Back.CYAN)


# Commands to Run
commands = [
['Creating Temp Folder \t', 'mkdir tmp'],
['Installing Tesseract \t', install_tesseract],
#['Installing Requirements', 'pip install -r requirements.txt'], this command hangs have to do manually
# ['Installing Requirements', 'pip install -r requirements.txt'], this command hangs have to do manually
['Copying nox files required \t', copy_nox_bin_files],
['Checking required packages\t', check_required_packages]
]
Expand All @@ -184,8 +196,13 @@ def command_runner(comm):
run_command(comm)


print(Back.CYAN + Style.BRIGHT + warning)
print(Back.CYAN + "Installing Required components to get this bot up and running")
for index, command in enumerate(commands):
print(Back.CYAN + "Component {}: {}{}".format(index, Fore.RED, command[0]) + Fore.WHITE)
command_runner(command[1])
def main_install():
print(Back.CYAN + Style.BRIGHT + warning)
print(Back.CYAN + "Installing Required components to get this bot up and running")
for index, command in enumerate(commands):
print(Back.CYAN + "Component {}: {}{}".format(index, Fore.RED, command[0]) + Fore.WHITE)
command_runner(command[1])


if __name__ == "__main__":
main_install()
13 changes: 13 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import click
import yaml
from apscheduler.schedulers.background import BackgroundScheduler
from install import set_pip_test, main_install


def setup_logging(
Expand Down Expand Up @@ -140,10 +141,22 @@ def inmain():

sys.exit(inmain())

@click.command()
def version():
import bot
print("Using {}".format(bot.__version__))

@click.command()
def setup():
set_pip_test(True)
main_install()


cli.add_command(bot)
cli.add_command(config)
cli.add_command(gui)
cli.add_command(version)
cli.add_command(setup)

if __name__ == "__main__":
cli()
2 changes: 1 addition & 1 deletion main.spec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ block_cipher = None
a = Analysis(['main.py'],
pathex=['D:\\Sync\\OneDrive\\Yu-gi-oh_bot'],
binaries=[],
datas=[ ('assets/*', 'assets'),('config.ini','.'),('bin/*','bin'), ('.gitignore','tmp')],
datas=[ ('assets/', 'assets'),('config.ini','.'),('bin/','bin/'), ('.gitignore','tmp'), ('logging.yaml','.')],
hiddenimports=['scipy._lib.messagestream',
'cython', 'sklearn', 'sklearn.tree','sklearn.neighbors.quad_tree','sklearn.neighbors.typedefs',
'sklearn.tree._utils','apscheduler.triggers.date'],
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ pip>=9.0.1
colorama==0.3.9
cssselect>=1.0.3
pywin32==223
cryptography>=2.0.3

0 comments on commit 312dad5

Please sign in to comment.