switch to buildbot.json

This commit is contained in:
Henning Peters 2016-02-09 15:31:55 +01:00
parent bc9a31df3e
commit 8d3957c5e6
6 changed files with 19 additions and 243 deletions

View File

@ -1,71 +0,0 @@
#!/usr/bin/env python
from __future__ import print_function
import os
import sys
import shutil
from subprocess import call
def x(cmd):
print('$ '+cmd)
res = call(cmd, shell=True)
if res != 0:
sys.exit(res)
if len(sys.argv) < 2:
print('usage: %s <install-mode> [<pip-date>]')
sys.exit(1)
install_mode = sys.argv[1]
if install_mode == 'prepare':
x('python pip-clear.py')
pip_date = len(sys.argv) > 2 and sys.argv[2]
if pip_date:
x('python pip-date.py %s pip setuptools wheel six' % pip_date)
x('pip install -r requirements.txt')
x('pip list')
elif install_mode == 'pip':
if os.path.exists('dist'):
shutil.rmtree('dist')
x('python setup.py sdist')
x('python pip-clear.py')
filenames = os.listdir('dist')
assert len(filenames) == 1
x('pip list')
x('pip install dist/%s' % filenames[0])
elif install_mode == 'setup-install':
x('python setup.py install')
elif install_mode == 'setup-develop':
x('pip install -e .')
elif install_mode == 'test':
x('pip install pytest')
x('pip list')
if os.path.exists('tmp'):
shutil.rmtree('tmp')
os.mkdir('tmp')
try:
old = os.getcwd()
os.chdir('tmp')
x('python -m spacy.en.download')
x('python -m pytest --tb="native" ../spacy/ -x --models --vectors --slow')
finally:
os.chdir(old)

19
buildbot.json Normal file
View File

@ -0,0 +1,19 @@
{
"build": {
"sdist": [
"python pip-clear.py",
"pip install -r requirements.txt",
"python setup.py sdist"
],
"install": [
"python pip-clear.py",
"pip install source.tar.gz",
"python -m spacy.en.download --force"
]
},
"test": {
"after": ["install"],
"package": "spacy",
"args": "--tb='native' -x --models --vectors --slow"
}
}

View File

@ -1,28 +0,0 @@
#!/usr/bin/env python
from __future__ import print_function
from pip.commands.uninstall import UninstallCommand
from pip import get_installed_distributions
packages = []
for package in get_installed_distributions():
if package.location.endswith('dist-packages'):
continue
elif package.project_name in ('pip', 'setuptools'):
continue
packages.append(package.project_name)
if packages:
pip = UninstallCommand()
options, args = pip.parse_args(packages)
options.yes = True
try:
pip.run(options, args)
except OSError as e:
if e.errno != 13:
raise e
print("You lack permissions to uninstall this package. Perhaps run with sudo? Exiting.")
exit(13)

View File

@ -1,96 +0,0 @@
#!/usr/bin/env python
from __future__ import print_function
import json
import re
import sys
from bisect import bisect
from datetime import datetime
from datetime import timedelta
import ssl
try:
from urllib.request import Request, build_opener, HTTPSHandler, URLError
except ImportError:
from urllib2 import Request, build_opener, HTTPSHandler, URLError
from pip.commands.uninstall import UninstallCommand
from pip.commands.install import InstallCommand
from pip import get_installed_distributions
def get_releases(package_name):
url = 'https://pypi.python.org/pypi/%s/json' % package_name
ssl_context = HTTPSHandler(
context=ssl.SSLContext(ssl.PROTOCOL_TLSv1))
opener = build_opener(ssl_context)
retries = 10
while retries > 0:
try:
r = opener.open(Request(url))
break
except URLError:
retries -= 1
return json.loads(r.read().decode('utf8'))['releases']
def parse_iso8601(s):
return datetime(*map(int, re.split('[^\d]', s)))
def select_version(select_date, package_name):
versions = []
for version, dists in get_releases(package_name).items():
date = [parse_iso8601(d['upload_time']) for d in dists]
if date:
versions.append((sorted(date)[0], version))
versions = sorted(versions)
min_date = versions[0][0]
if select_date < min_date:
raise Exception('invalid select_date: %s, must be '
'%s or newer.' % (select_date, min_date))
return versions[bisect([x[0] for x in versions], select_date) - 1][1]
installed_packages = [
package.project_name
for package in
get_installed_distributions()
if (not package.location.endswith('dist-packages') and
package.project_name not in ('pip', 'setuptools'))
]
if installed_packages:
pip = UninstallCommand()
options, args = pip.parse_args(installed_packages)
options.yes = True
try:
pip.run(options, args)
except OSError as e:
if e.errno != 13:
raise e
print("You lack permissions to uninstall this package. Perhaps run with sudo? Exiting.")
exit(13)
date = parse_iso8601(sys.argv[1])
packages = {p: select_version(date, p) for p in sys.argv[2:]}
args = ['=='.join(a) for a in packages.items()]
cmd = InstallCommand()
options, args = cmd.parse_args(args)
options.ignore_installed = True
options.force_reinstall = True
try:
print(cmd.run(options, args))
except OSError as e:
if e.errno != 13:
raise e
print("You lack permissions to uninstall this package. Perhaps run with sudo? Exiting.")
exit(13)

View File

@ -1,32 +0,0 @@
param (
[string]$python = $(throw "-python is required."),
[string]$install_mode = $(throw "-install_mode is required."),
[string]$pip_date,
[string]$compiler
)
$ErrorActionPreference = "Stop"
if(!(Test-Path -Path ".build"))
{
if($compiler -eq "mingw32")
{
virtualenv .build --system-site-packages --python $python
}
else
{
virtualenv .build --python $python
}
if($compiler)
{
"[build]`r`ncompiler=$compiler" | Out-File -Encoding ascii .\.build\Lib\distutils\distutils.cfg
}
}
.build\Scripts\activate.ps1
python build.py prepare $pip_date
python build.py $install_mode
python build.py test
exit $LASTEXITCODE

16
venv.sh
View File

@ -1,16 +0,0 @@
#!/bin/bash
set -e
if [ ! -d ".build" ]; then
virtualenv .build --python $1
fi
if [ -d ".build/bin" ]; then
source .build/bin/activate
elif [ -d ".build/Scripts" ]; then
source .build/Scripts/activate
fi
python build.py prepare $3
python build.py $2
python build.py test