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

Commit

Permalink
Merge july-23-patch and release 2.6.0
Browse files Browse the repository at this point in the history
- Fixed a bug when finding COM ports
- Project folders no longer have to be empty when creating a new project
- Template files correctly no longer know anything about their depot
- New PROS installers
  • Loading branch information
edjubuh committed Oct 12, 2017
2 parents b8e2eec + 80bc0ec commit bee8a76
Show file tree
Hide file tree
Showing 24 changed files with 256 additions and 113 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ build/
dist/

pros_cli.egg-info/

out/
*.zip
109 changes: 28 additions & 81 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,89 +1,36 @@
stage('Build') {
def build_ver = '2.4.2'
parallel unix: {
node('linux') {
def venv = new edu.purdue.pros.venv()
stage('Clean') {
sh 'git init'
sh 'git clean -d -x -f'
}
stage('Dependencies') {
tool 'python3'
if(isUnix()) {
sh 'sudo apt-get install -y python3-pip'
}
venv.create_virtualenv()
venv.run 'pip3 install wheel twine'
}
stage('Clone') {
parallel (
"linux64": {
node("lin64") {
checkout scm
sh 'git describe --tags > version'
build_ver = readFile 'version'
build_ver = build_ver.replaceAll("\\s","")
println "Building CLI at version ${build_ver}"
}
stage('Build') {
venv.run 'python setup.py bdist_wheel'
dir('dist') {
archiveArtifacts artifacts: 'pros_cli-*-none-any.whl', fingerprint: true
}
}
}
}, windows64: {
node('win&&x64') {
def venv = new edu.purdue.pros.venv()
stage('Clean') {
bat "${tool name: 'Default', type: 'git'} init"
bat "${tool name: 'Default', type: 'git'} clean -d -x -f"
sh './scripts/install_build_dependencies.sh'
sh 'vex -mr jenkins ./scripts/build.sh'
archiveArtifacts artifacts: 'out/*', onlyIfSuccessful: true
}
stage('Dependenices') {
tool 'MSBuild'
venv.create_virtualenv()
dir('cx_Freeze') {
checkout changelog: false, poll: false, scm: [$class: 'MercurialSCM', credentialsId: '', installation: 'Mercurial', source: 'https://bitbucket.org/anthony_tuininga/cx_freeze']
venv.run 'pip3 install .'
}
}
stage('Clone') {
},
"linux86": {
node("lin86") {
checkout scm
bat 'git describe --tags > version'
build_ver = readFile 'version'
build_ver = build_ver.replaceAll("\\s","")
bat 'git describe --tags --abbrev=0 > inst_version'
inst_ver = readFile 'inst_version'
inst_ver = inst_ver.replaceAll("\\s","")
sh './scripts/install_build_dependencies.sh'
sh 'vex -mr jenkins ./scripts/build.sh'
archiveArtifacts artifacts: 'out/*', onlyIfSuccessful: true
}
stage('Build') {
venv.run 'pip3 install --upgrade -r requirements.txt'
venv.run 'python build.py build_exe'
archiveArtifacts artifacts: 'pros_cli-*-win*.zip', fingerprint: true
},
"windows64": {
node("win64") {
checkout scm
bat 'powershell -file .\\scripts\\install_build_dependencies.ps1'
bat '.\\scripts\\build.bat'
archiveArtifacts artifacts: 'out/*', onlyIfSuccessful: true
}
}
}
stage('Windows Installers') {
node('win&&advinst') {
ws {
git credentialsId: 'phabricator-sigbot-ssh-key', poll: false, url: 'ssh://git@phabricator.purduesigbots.com/diffusion/WININSTALLER/pros-windows-installers.git'
bat 'if exist .\\exe.win del /s /q .\\exe.win'
bat 'if exist .\\exe.win rmdir /s /q .\\exe.win'
bat 'mkdir .\\exe.win'
for(file in unarchive(mapping: ['**pros_cli-*-win-32bit.zip': '.'])) {
file.unzip(file.getParent().child('exe.win'))
}
def advinst = "\"${tool 'Advanced Installer'}\\AdvancedInstaller.com\""
bat """
${advinst} /edit pros-windows.aip /SetVersion ${inst_ver}
${advinst} /edit pros-windows.aip /ResetSync APPDIR\\cli -clearcontent
${advinst} /edit pros-windows.aip /NewSync APPDIR\\cli exe.win -existingfiles delete
${advinst} /build pros-windows.aip
"""
bat """
${advinst} /edit pros-updates.aip /NewUpdate output\\pros-win.exe -name "PROS${inst_ver}" -display_name "PROS ${build_ver}" -url "${env.BUILD_URL}artifact/output/pros-win.exe"
${advinst} /build pros-updates.aip
"""
archiveArtifacts artifacts: 'output/*', fingerprint: true
},
"windows86": {
node("win86") {
checkout scm
bat 'powershell -file .\\scripts\\install_build_dependencies.ps1'
bat '.\\scripts\\build.bat'
archiveArtifacts artifacts: 'out/*', onlyIfSuccessful: true
}
}
}
}
doDeploy()
)
}
16 changes: 11 additions & 5 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,20 @@
install_reqs = [str(r.req) for r in parse_requirements('requirements.txt', session=False)]

build_exe_options = {
'packages': ['ssl', 'prosconductor.providers.githubreleases', 'requests'],
'packages': ['ssl', 'prosconductor.providers.githubreleases', 'requests', 'idna'],
"include_files": [(requests.certs.where(), 'cacert.pem')],
'excludes': ['pip', 'distutils'], # optimization excludes
'constants': ['CLI_VERSION=\'{}\''.format(open('version').read().strip())]
'constants': ['CLI_VERSION=\'{}\''.format(open('version').read().strip())],
'include_msvcr': True
# 'zip_include_packages': [],
# 'zip_exclude_packages': []
}

build_mac_options = {
'bundle_name': 'PROS CLI',
'iconfile': 'pros.icns'
}

modules = []
for pkg in [proscli, prosconductor, prosconductor.providers, prosconfig, prosflasher]:
modules.append(pkg.__name__)
Expand All @@ -33,14 +39,14 @@

setup(
name='pros-cli',
version=open('version').read().strip(),
version=open('pip_version').read().strip(),
packages=modules,
url='https://github.com/purduesigbots/pros-cli',
license='MPL-2.0',
author='Purdue ACM Sigbots',
author_email='pros_development@cs.purdue.edu',
description='Command Line Interface for managing PROS projects',
options={"build_exe": build_exe_options},
options={"build_exe": build_exe_options, 'bdist_mac': build_mac_options},
install_requires=install_reqs,
executables=[Executable('proscli/main.py', targetName=targetName)]
)
Expand All @@ -52,4 +58,4 @@
py_compile.compile('./prosconductor/providers/githubreleases.py', cfile='{}/githubreleases.pyc'.format(build_dir))
import shutil
import platform
shutil.make_archive('pros_cli-{}-win-{}'.format(open('version').read().strip(), platform.architecture()[0]), 'zip', build_dir, '.')
shutil.make_archive('pros_cli-{}-{}-{}'.format(open('version').read().strip(), platform.system()[0:3].lower(), platform.architecture()[0]), 'zip', build_dir, '.')
1 change: 1 addition & 0 deletions pip_version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.6.0
Binary file added pros.icns
Binary file not shown.
3 changes: 2 additions & 1 deletion proscli/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ def make(ctx, build_args):
cwd = '.'
env = os.environ.copy()
if os.name == 'nt':
env['PATH'] += ';' + os.path.join(os.environ.get('PROS_TOOLCHAIN'), 'bin')
cmd = os.path.join(os.environ.get('PROS_TOOLCHAIN'), 'bin', 'make.exe')
else:
cmd = 'make'
if os.environ.get('PROS_TOOLCHAIN'):
env['PATH'] += os.pathsep + os.path.join(os.environ.get('PROS_TOOLCHAIN'), 'bin')
build_args = ['make'] + list(build_args) # prepend 'make' because of magic
click.echo('Invoking {} in {}...'.format(' '.join(build_args), cwd))
p = subprocess.Popen(executable=cmd, args=build_args, cwd=cwd, env=env,
Expand Down
12 changes: 7 additions & 5 deletions proscli/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def list_depots(cfg):
if not bool(depots):
click.echo('No depots currently registered! Use `pros conduct add-depot` to add a new depot')
else:
click.echo([(d.name, d.registrar, d.location) for d in depots])
click.echo(tabulate.tabulate([(d.name, d.registrar, d.location) for d in depots],
['Name', 'Registrar', 'Location'], tablefmt='simple'))

Expand Down Expand Up @@ -211,7 +210,7 @@ def list_templates(cfg, template_types, filters, offline_only):
click.echo(json.dumps(table))


@conduct.command(short_help='Download a template', aliases=['dl'])
@conduct.command(short_help='Download a template', aliases=['dl', 'd'])
@click.argument('name', default='kernel')
@click.argument('version', default='latest')
@click.argument('depot', default='auto')
Expand Down Expand Up @@ -437,14 +436,15 @@ def register(cfg, location, kernel):
# endregion


@conduct.command('new-lib', aliases=['install-lib', 'add-lib', 'new-library', 'install-library', 'add-library'],
@conduct.command('add-lib', aliases=['install-lib', 'new-lib', 'new-library', 'install-library', 'add-library'],
help='Installs a new library')
@click.argument('location')
@click.argument('library')
@click.argument('version', default='latest')
@click.argument('depot', default='auto')
@click.option('--force', is_flag=True, default=False)
@default_cfg
def newlib(cfg, location, library, version, depot):
def newlib(cfg, location, library, version, depot, force):
if not (version == 'latest') and len(version.split('.')) < 3:
depot = version
version = 'latest'
Expand Down Expand Up @@ -499,7 +499,7 @@ def newlib(cfg, location, library, version, depot):
'No local libraries match the specified name, version, and depot. Check your arguments and make sure the appropriate libraries are downloaded')
click.get_current_context().abort()
sys.exit()
local.install_lib(selected, location, cfg.pros_cfg)
local.install_lib(selected, location, cfg.pros_cfg, overwrite=force)
print('Installed library {} v. {} in {} from {}'.format(selected.name, selected.version, location, selected.depot))


Expand Down Expand Up @@ -571,6 +571,8 @@ def upgradelib(cfg, location, library, version, depot):
sys.exit()
local.upgrade_project(selected, location, cfg.pros_cfg)
proj_config = prosconfig.ProjectConfig(location)
if type(proj_config.libraries) is list:
proj_config.libraries = dict()
proj_config.libraries[selected.name] = selected.version
proj_config.save()
print('Updated library {} v. {} in {} from {}'.format(selected.name, selected.version, location, selected.depot))
Expand Down
9 changes: 4 additions & 5 deletions proscli/conductor_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@
# Commands in this module are typically for automation/IDE purposes and probably won't be used by front-end users


@conduct.command('create-template', short_help='Creates a template with the specified name, version, and depot')
@conduct.command('create-template', short_help='Creates a template with the specified name and version')
@click.argument('name')
@click.argument('version')
@click.argument('depot')
@click.option('--location')
@click.argument('location')
@click.option('--ignore', '-i', multiple=True)
@click.option('--upgrade-files', '-u', multiple=True)
@default_cfg
def create_template(cfg, name, version, depot, location, ignore, upgrade_files):
def create_template(cfg, name, version, location, ignore, upgrade_files):
first_run(cfg)
template = local.create_template(utils.Identifier(name, version, depot), location=location)
template = local.create_template(utils.Identifier(name, version, None), location=location)
template.template_ignore = list(ignore)
template.upgrade_paths = list(upgrade_files)
template.save()
Expand Down
3 changes: 2 additions & 1 deletion proscli/main.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import click
#from pkg_resources import get_distribution
import proscli
from proscli.utils import default_options, get_version


def main():
# the program name should always be pros. don't care if it's not...
try:
cli.main(prog_name='pros')
except KeyboardInterrupt:
click.echo('Aborted!')


@click.command('pros',
cls=click.CommandCollection,
context_settings=dict(help_option_names=['-h', '--help']),
Expand Down
19 changes: 8 additions & 11 deletions proscli/utils.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
import os

import click
import sys
import os.path

from proscli.state import State

pass_state = click.make_pass_decorator(State)

def get_version():
try:
if os.path.isfile(os.path.join(__file__, '../../version')):
return open(os.path.join(__file__, '../../version')).read().strip()
except Exception:
pass
try:
if getattr(sys, 'frozen', False):
import BUILD_CONSTANTS
return BUILD_CONSTANTS.CLI_VERSION
return open(os.path.join(os.path.dirname(__file__), '..', 'version')).read().strip()
except Exception:
pass
try:
if getattr(sys, 'frozen', False):
import BUILD_CONSTANTS
return BUILD_CONSTANTS.CLI_VERSION
except Exception:
pass
return None # Let click figure it out

def verbosity_option(f):
Expand Down
2 changes: 2 additions & 0 deletions prosconductor/providers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ def list_local(self, template_types=None):
if os.path.isdir(os.path.join(self.config.directory, x))]:
if TemplateTypes.kernel in template_types and 'template.pros' in os.listdir(item) and os.path.basename(item).startswith('kernel'):
template_config = TemplateConfig(os.path.join(item, 'template.pros'))
template_config.depot = self.config.name
result[TemplateTypes.kernel].add(template_config.identifier)
elif TemplateTypes.library in template_types and 'template.pros' in os.listdir(item) and not os.path.basename(item).startswith('kernel'):
template_config = TemplateConfig(os.path.join(item, 'template.pros'))
template_config.depot = self.config.name
result[TemplateTypes.library].add(template_config.identifier)
return result

Expand Down
2 changes: 2 additions & 0 deletions prosconductor/providers/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,5 +209,7 @@ def install_lib(identifier, dest, pros_cli, overwrite=False):
if any([fnmatch.fnmatch(f, p) for p in config.template_ignore]):
verbose('Removing {}'.format(f))
os.remove(os.path.join(root, f))
if type(proj_config.libraries) is list:
proj_config.libraries = dict()
proj_config.libraries[identifier.name] = identifier.version
proj_config.save()
2 changes: 1 addition & 1 deletion prosconfig/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __init__(self, path: str='.', create: bool=False, raise_on_error: bool=True)
raise ConfigNotFoundException('A project config was not found for {}'.format(path))

self.kernel = None # type: str
self.libraries = [] # type: List[str]
self.libraries = {} # type: List[str]
self.output = 'bin/output.bin' # type: str
super(ProjectConfig, self).__init__(file, error_on_decode=raise_on_error)

Expand Down
36 changes: 36 additions & 0 deletions scripts/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@echo off

set root=%~dp0..

set python=python
echo Testing python executable version
python -c "import sys; exit(0 if sys.version_info > (3,5) else 1)"
if errorlevel 1 set python=python3

echo Installing wheel and cx_Freeze
git clone --branch 5.0.2 https://github.com/anthony-tuininga/cx_Freeze.git
pip3 install --upgrade cx_Freeze\.
pip3 install --upgrade wheel

echo Updating version
%python% %root%\version.py

echo Installing pros-cli requirements
pip3 install --upgrade -r %root%\requirements.txt

echo Building Wheel
%python% %root%\setup.py bdist_wheel

echo Building Binary
%python% %root%\build.py build_exe

echo Moving artifacts to .\out
if not exist %root%\out mkdir %root%\out
del /Q %root%\out\*.*
copy %root%\dist\pros_cli*.whl %root%\out\
copy %root%\pros_cli*.zip %root%\out\

cd out
%python% %root%\version.py
cd ..

Loading

0 comments on commit bee8a76

Please sign in to comment.