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

Commit bee8a76

Browse files
committed
Merge july-23-patch and release 2.6.0
- 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
2 parents b8e2eec + 80bc0ec commit bee8a76

24 files changed

+256
-113
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ build/
77
dist/
88

99
pros_cli.egg-info/
10+
11+
out/
12+
*.zip

Jenkinsfile

Lines changed: 28 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,36 @@
11
stage('Build') {
2-
def build_ver = '2.4.2'
3-
parallel unix: {
4-
node('linux') {
5-
def venv = new edu.purdue.pros.venv()
6-
stage('Clean') {
7-
sh 'git init'
8-
sh 'git clean -d -x -f'
9-
}
10-
stage('Dependencies') {
11-
tool 'python3'
12-
if(isUnix()) {
13-
sh 'sudo apt-get install -y python3-pip'
14-
}
15-
venv.create_virtualenv()
16-
venv.run 'pip3 install wheel twine'
17-
}
18-
stage('Clone') {
2+
parallel (
3+
"linux64": {
4+
node("lin64") {
195
checkout scm
20-
sh 'git describe --tags > version'
21-
build_ver = readFile 'version'
22-
build_ver = build_ver.replaceAll("\\s","")
23-
println "Building CLI at version ${build_ver}"
24-
}
25-
stage('Build') {
26-
venv.run 'python setup.py bdist_wheel'
27-
dir('dist') {
28-
archiveArtifacts artifacts: 'pros_cli-*-none-any.whl', fingerprint: true
29-
}
30-
}
31-
}
32-
}, windows64: {
33-
node('win&&x64') {
34-
def venv = new edu.purdue.pros.venv()
35-
stage('Clean') {
36-
bat "${tool name: 'Default', type: 'git'} init"
37-
bat "${tool name: 'Default', type: 'git'} clean -d -x -f"
6+
sh './scripts/install_build_dependencies.sh'
7+
sh 'vex -mr jenkins ./scripts/build.sh'
8+
archiveArtifacts artifacts: 'out/*', onlyIfSuccessful: true
389
}
39-
stage('Dependenices') {
40-
tool 'MSBuild'
41-
venv.create_virtualenv()
42-
dir('cx_Freeze') {
43-
checkout changelog: false, poll: false, scm: [$class: 'MercurialSCM', credentialsId: '', installation: 'Mercurial', source: 'https://bitbucket.org/anthony_tuininga/cx_freeze']
44-
venv.run 'pip3 install .'
45-
}
46-
}
47-
stage('Clone') {
10+
},
11+
"linux86": {
12+
node("lin86") {
4813
checkout scm
49-
bat 'git describe --tags > version'
50-
build_ver = readFile 'version'
51-
build_ver = build_ver.replaceAll("\\s","")
52-
bat 'git describe --tags --abbrev=0 > inst_version'
53-
inst_ver = readFile 'inst_version'
54-
inst_ver = inst_ver.replaceAll("\\s","")
14+
sh './scripts/install_build_dependencies.sh'
15+
sh 'vex -mr jenkins ./scripts/build.sh'
16+
archiveArtifacts artifacts: 'out/*', onlyIfSuccessful: true
5517
}
56-
stage('Build') {
57-
venv.run 'pip3 install --upgrade -r requirements.txt'
58-
venv.run 'python build.py build_exe'
59-
archiveArtifacts artifacts: 'pros_cli-*-win*.zip', fingerprint: true
18+
},
19+
"windows64": {
20+
node("win64") {
21+
checkout scm
22+
bat 'powershell -file .\\scripts\\install_build_dependencies.ps1'
23+
bat '.\\scripts\\build.bat'
24+
archiveArtifacts artifacts: 'out/*', onlyIfSuccessful: true
6025
}
61-
}
62-
}
63-
stage('Windows Installers') {
64-
node('win&&advinst') {
65-
ws {
66-
git credentialsId: 'phabricator-sigbot-ssh-key', poll: false, url: 'ssh://git@phabricator.purduesigbots.com/diffusion/WININSTALLER/pros-windows-installers.git'
67-
bat 'if exist .\\exe.win del /s /q .\\exe.win'
68-
bat 'if exist .\\exe.win rmdir /s /q .\\exe.win'
69-
bat 'mkdir .\\exe.win'
70-
for(file in unarchive(mapping: ['**pros_cli-*-win-32bit.zip': '.'])) {
71-
file.unzip(file.getParent().child('exe.win'))
72-
}
73-
def advinst = "\"${tool 'Advanced Installer'}\\AdvancedInstaller.com\""
74-
bat """
75-
${advinst} /edit pros-windows.aip /SetVersion ${inst_ver}
76-
${advinst} /edit pros-windows.aip /ResetSync APPDIR\\cli -clearcontent
77-
${advinst} /edit pros-windows.aip /NewSync APPDIR\\cli exe.win -existingfiles delete
78-
${advinst} /build pros-windows.aip
79-
"""
80-
bat """
81-
${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"
82-
${advinst} /build pros-updates.aip
83-
"""
84-
archiveArtifacts artifacts: 'output/*', fingerprint: true
26+
},
27+
"windows86": {
28+
node("win86") {
29+
checkout scm
30+
bat 'powershell -file .\\scripts\\install_build_dependencies.ps1'
31+
bat '.\\scripts\\build.bat'
32+
archiveArtifacts artifacts: 'out/*', onlyIfSuccessful: true
8533
}
8634
}
87-
}
88-
}
89-
doDeploy()
35+
)
36+
}

build.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,20 @@
1313
install_reqs = [str(r.req) for r in parse_requirements('requirements.txt', session=False)]
1414

1515
build_exe_options = {
16-
'packages': ['ssl', 'prosconductor.providers.githubreleases', 'requests'],
16+
'packages': ['ssl', 'prosconductor.providers.githubreleases', 'requests', 'idna'],
1717
"include_files": [(requests.certs.where(), 'cacert.pem')],
1818
'excludes': ['pip', 'distutils'], # optimization excludes
19-
'constants': ['CLI_VERSION=\'{}\''.format(open('version').read().strip())]
19+
'constants': ['CLI_VERSION=\'{}\''.format(open('version').read().strip())],
20+
'include_msvcr': True
2021
# 'zip_include_packages': [],
2122
# 'zip_exclude_packages': []
2223
}
2324

25+
build_mac_options = {
26+
'bundle_name': 'PROS CLI',
27+
'iconfile': 'pros.icns'
28+
}
29+
2430
modules = []
2531
for pkg in [proscli, prosconductor, prosconductor.providers, prosconfig, prosflasher]:
2632
modules.append(pkg.__name__)
@@ -33,14 +39,14 @@
3339

3440
setup(
3541
name='pros-cli',
36-
version=open('version').read().strip(),
42+
version=open('pip_version').read().strip(),
3743
packages=modules,
3844
url='https://github.com/purduesigbots/pros-cli',
3945
license='MPL-2.0',
4046
author='Purdue ACM Sigbots',
4147
author_email='pros_development@cs.purdue.edu',
4248
description='Command Line Interface for managing PROS projects',
43-
options={"build_exe": build_exe_options},
49+
options={"build_exe": build_exe_options, 'bdist_mac': build_mac_options},
4450
install_requires=install_reqs,
4551
executables=[Executable('proscli/main.py', targetName=targetName)]
4652
)
@@ -52,4 +58,4 @@
5258
py_compile.compile('./prosconductor/providers/githubreleases.py', cfile='{}/githubreleases.pyc'.format(build_dir))
5359
import shutil
5460
import platform
55-
shutil.make_archive('pros_cli-{}-win-{}'.format(open('version').read().strip(), platform.architecture()[0]), 'zip', build_dir, '.')
61+
shutil.make_archive('pros_cli-{}-{}-{}'.format(open('version').read().strip(), platform.system()[0:3].lower(), platform.architecture()[0]), 'zip', build_dir, '.')

pip_version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.6.0

pros.icns

375 KB
Binary file not shown.

proscli/build.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ def make(ctx, build_args):
2929
cwd = '.'
3030
env = os.environ.copy()
3131
if os.name == 'nt':
32-
env['PATH'] += ';' + os.path.join(os.environ.get('PROS_TOOLCHAIN'), 'bin')
3332
cmd = os.path.join(os.environ.get('PROS_TOOLCHAIN'), 'bin', 'make.exe')
3433
else:
3534
cmd = 'make'
35+
if os.environ.get('PROS_TOOLCHAIN'):
36+
env['PATH'] += os.pathsep + os.path.join(os.environ.get('PROS_TOOLCHAIN'), 'bin')
3637
build_args = ['make'] + list(build_args) # prepend 'make' because of magic
3738
click.echo('Invoking {} in {}...'.format(' '.join(build_args), cwd))
3839
p = subprocess.Popen(executable=cmd, args=build_args, cwd=cwd, env=env,

proscli/conductor.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ def list_depots(cfg):
6565
if not bool(depots):
6666
click.echo('No depots currently registered! Use `pros conduct add-depot` to add a new depot')
6767
else:
68-
click.echo([(d.name, d.registrar, d.location) for d in depots])
6968
click.echo(tabulate.tabulate([(d.name, d.registrar, d.location) for d in depots],
7069
['Name', 'Registrar', 'Location'], tablefmt='simple'))
7170

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

213212

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

439438

440-
@conduct.command('new-lib', aliases=['install-lib', 'add-lib', 'new-library', 'install-library', 'add-library'],
439+
@conduct.command('add-lib', aliases=['install-lib', 'new-lib', 'new-library', 'install-library', 'add-library'],
441440
help='Installs a new library')
442441
@click.argument('location')
443442
@click.argument('library')
444443
@click.argument('version', default='latest')
445444
@click.argument('depot', default='auto')
445+
@click.option('--force', is_flag=True, default=False)
446446
@default_cfg
447-
def newlib(cfg, location, library, version, depot):
447+
def newlib(cfg, location, library, version, depot, force):
448448
if not (version == 'latest') and len(version.split('.')) < 3:
449449
depot = version
450450
version = 'latest'
@@ -499,7 +499,7 @@ def newlib(cfg, location, library, version, depot):
499499
'No local libraries match the specified name, version, and depot. Check your arguments and make sure the appropriate libraries are downloaded')
500500
click.get_current_context().abort()
501501
sys.exit()
502-
local.install_lib(selected, location, cfg.pros_cfg)
502+
local.install_lib(selected, location, cfg.pros_cfg, overwrite=force)
503503
print('Installed library {} v. {} in {} from {}'.format(selected.name, selected.version, location, selected.depot))
504504

505505

@@ -571,6 +571,8 @@ def upgradelib(cfg, location, library, version, depot):
571571
sys.exit()
572572
local.upgrade_project(selected, location, cfg.pros_cfg)
573573
proj_config = prosconfig.ProjectConfig(location)
574+
if type(proj_config.libraries) is list:
575+
proj_config.libraries = dict()
574576
proj_config.libraries[selected.name] = selected.version
575577
proj_config.save()
576578
print('Updated library {} v. {} in {} from {}'.format(selected.name, selected.version, location, selected.depot))

proscli/conductor_management.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,16 @@
1212
# Commands in this module are typically for automation/IDE purposes and probably won't be used by front-end users
1313

1414

15-
@conduct.command('create-template', short_help='Creates a template with the specified name, version, and depot')
15+
@conduct.command('create-template', short_help='Creates a template with the specified name and version')
1616
@click.argument('name')
1717
@click.argument('version')
18-
@click.argument('depot')
19-
@click.option('--location')
18+
@click.argument('location')
2019
@click.option('--ignore', '-i', multiple=True)
2120
@click.option('--upgrade-files', '-u', multiple=True)
2221
@default_cfg
23-
def create_template(cfg, name, version, depot, location, ignore, upgrade_files):
22+
def create_template(cfg, name, version, location, ignore, upgrade_files):
2423
first_run(cfg)
25-
template = local.create_template(utils.Identifier(name, version, depot), location=location)
24+
template = local.create_template(utils.Identifier(name, version, None), location=location)
2625
template.template_ignore = list(ignore)
2726
template.upgrade_paths = list(upgrade_files)
2827
template.save()

proscli/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import click
2-
#from pkg_resources import get_distribution
32
import proscli
43
from proscli.utils import default_options, get_version
54

5+
66
def main():
77
# the program name should always be pros. don't care if it's not...
88
try:
99
cli.main(prog_name='pros')
1010
except KeyboardInterrupt:
1111
click.echo('Aborted!')
1212

13+
1314
@click.command('pros',
1415
cls=click.CommandCollection,
1516
context_settings=dict(help_option_names=['-h', '--help']),

proscli/utils.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
1-
import os
2-
31
import click
42
import sys
3+
import os.path
54

65
from proscli.state import State
76

87
pass_state = click.make_pass_decorator(State)
98

109
def get_version():
1110
try:
12-
if os.path.isfile(os.path.join(__file__, '../../version')):
13-
return open(os.path.join(__file__, '../../version')).read().strip()
14-
except Exception:
15-
pass
16-
try:
17-
if getattr(sys, 'frozen', False):
18-
import BUILD_CONSTANTS
19-
return BUILD_CONSTANTS.CLI_VERSION
11+
return open(os.path.join(os.path.dirname(__file__), '..', 'version')).read().strip()
2012
except Exception:
21-
pass
13+
try:
14+
if getattr(sys, 'frozen', False):
15+
import BUILD_CONSTANTS
16+
return BUILD_CONSTANTS.CLI_VERSION
17+
except Exception:
18+
pass
2219
return None # Let click figure it out
2320

2421
def verbosity_option(f):

prosconductor/providers/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,11 @@ def list_local(self, template_types=None):
101101
if os.path.isdir(os.path.join(self.config.directory, x))]:
102102
if TemplateTypes.kernel in template_types and 'template.pros' in os.listdir(item) and os.path.basename(item).startswith('kernel'):
103103
template_config = TemplateConfig(os.path.join(item, 'template.pros'))
104+
template_config.depot = self.config.name
104105
result[TemplateTypes.kernel].add(template_config.identifier)
105106
elif TemplateTypes.library in template_types and 'template.pros' in os.listdir(item) and not os.path.basename(item).startswith('kernel'):
106107
template_config = TemplateConfig(os.path.join(item, 'template.pros'))
108+
template_config.depot = self.config.name
107109
result[TemplateTypes.library].add(template_config.identifier)
108110
return result
109111

prosconductor/providers/local.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,5 +209,7 @@ def install_lib(identifier, dest, pros_cli, overwrite=False):
209209
if any([fnmatch.fnmatch(f, p) for p in config.template_ignore]):
210210
verbose('Removing {}'.format(f))
211211
os.remove(os.path.join(root, f))
212+
if type(proj_config.libraries) is list:
213+
proj_config.libraries = dict()
212214
proj_config.libraries[identifier.name] = identifier.version
213215
proj_config.save()

prosconfig/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __init__(self, path: str='.', create: bool=False, raise_on_error: bool=True)
7777
raise ConfigNotFoundException('A project config was not found for {}'.format(path))
7878

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

scripts/build.bat

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
@echo off
2+
3+
set root=%~dp0..
4+
5+
set python=python
6+
echo Testing python executable version
7+
python -c "import sys; exit(0 if sys.version_info > (3,5) else 1)"
8+
if errorlevel 1 set python=python3
9+
10+
echo Installing wheel and cx_Freeze
11+
git clone --branch 5.0.2 https://github.com/anthony-tuininga/cx_Freeze.git
12+
pip3 install --upgrade cx_Freeze\.
13+
pip3 install --upgrade wheel
14+
15+
echo Updating version
16+
%python% %root%\version.py
17+
18+
echo Installing pros-cli requirements
19+
pip3 install --upgrade -r %root%\requirements.txt
20+
21+
echo Building Wheel
22+
%python% %root%\setup.py bdist_wheel
23+
24+
echo Building Binary
25+
%python% %root%\build.py build_exe
26+
27+
echo Moving artifacts to .\out
28+
if not exist %root%\out mkdir %root%\out
29+
del /Q %root%\out\*.*
30+
copy %root%\dist\pros_cli*.whl %root%\out\
31+
copy %root%\pros_cli*.zip %root%\out\
32+
33+
cd out
34+
%python% %root%\version.py
35+
cd ..
36+

0 commit comments

Comments
 (0)