Skip to content
This repository was archived by the owner on Jun 20, 2024. It is now read-only.

Commit 9010c63

Browse files
committed
Make changes to build.py to allow Python 3.x builds. Add Travis job for checking the master build
1 parent b07a230 commit 9010c63

5 files changed

Lines changed: 33 additions & 19 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,4 @@ ENV/
101101
*.swp
102102
*.zip
103103
*.xidl
104+
*.kmk

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ matrix:
1717
- python: 3.6
1818
env: TOXENV=packaging
1919

20+
# Building Library.py
21+
- python: 2.7
22+
env: TOXENV=build
23+
24+
- python: 3.6
25+
env: TOXENV=build
26+
2027
cache:
2128
- pip
2229
- directories:

build.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66
77
"""
88
from xml.dom import minidom
9-
import pprint
10-
import sys
119
import os
1210
import re
1311
import hashlib
14-
import urllib2
12+
import requests
1513
import shutil
1614
import begin
1715

@@ -621,18 +619,18 @@ def preprocess(xidl, target):
621619
emit = True
622620
for line in xidl.splitlines():
623621
line = line.strip()
624-
if line.startswith('<if target='):
622+
if line.startswith(b'<if target='):
625623
if target in line:
626624
emit = True
627625
else:
628626
emit = False
629627
continue
630-
elif line == '</if>':
628+
elif line == b'</if>':
631629
emit = True
632630
continue
633631
if emit:
634632
lines.append(line)
635-
return "\n".join(lines)
633+
return b"\n".join(lines)
636634

637635

638636
###########################################################
@@ -645,13 +643,13 @@ def get_vbox_version(config_kmk):
645643
"Return the vbox config major, minor, build"
646644
with open(config_kmk, 'rb') as f:
647645
config = f.read()
648-
major = re.search("VBOX_VERSION_MAJOR = (?P<major>[\d])",
646+
major = re.search(b"VBOX_VERSION_MAJOR = (?P<major>[\d])",
649647
config).groupdict()['major']
650-
minor = re.search("VBOX_VERSION_MINOR = (?P<minor>[\d])",
648+
minor = re.search(b"VBOX_VERSION_MINOR = (?P<minor>[\d])",
651649
config).groupdict()['minor']
652-
build = re.search("VBOX_VERSION_BUILD = (?P<build>[\d])",
650+
build = re.search(b"VBOX_VERSION_BUILD = (?P<build>[\d])",
653651
config).groupdict()['build']
654-
return ".".join([major, minor, build])
652+
return b".".join([major, minor, build])
655653

656654
def download_master(downloads):
657655
print("Download the master xidl")
@@ -663,11 +661,11 @@ def download_master(downloads):
663661

664662
def download_stable(downloads):
665663
print("Download latest tarball for stable release then unpack xidl")
666-
url = urllib2.urlopen('https://www.virtualbox.org/wiki/Downloads')
667-
page = url.read()
664+
with requests.get('https://www.virtualbox.org/wiki/Downloads') as r:
665+
page = r.content
666+
668667
match = re.search("http://download.virtualbox.org/virtualbox/"
669-
"([0-9\.]+)/VirtualBox-([0-9\.]+).tar.bz2"
670-
, page)
668+
"([0-9\.]+)/VirtualBox-([0-9\.]+).tar.bz2", page)
671669
if not match:
672670
raise Exception("Failed to find source tarball url")
673671
sourceurl = page[match.start():match.end()]
@@ -710,7 +708,7 @@ def main(virtualbox_xidl='VirtualBox.xidl',
710708

711709
print("Create new virtualbox/library.py")
712710
xidl = open(virtualbox_xidl, 'rb').read()
713-
xidl = preprocess(xidl, target='xpidl')
711+
xidl = preprocess(xidl, target=b'xpidl')
714712

715713
xml = minidom.parseString(xidl)
716714

@@ -778,14 +776,14 @@ def main(virtualbox_xidl='VirtualBox.xidl',
778776
code.extend(source['result'])
779777
code.extend(source['enum'])
780778
code.extend(source['interface'])
781-
code = "\n".join(code)
779+
code = b"\n".join([c.encode('utf-8') if not isinstance(c, bytes) else c for c in code])
782780
print(" vbox version : %s" % vbox_version)
783781
print(" xidl hash : %s" % xidl_hash)
784782
print(" version : %s" % version)
785-
print(" line count : %s" % code.count("\n"))
783+
print(" line count : %s" % code.count(b"\n"))
786784
library_path = os.path.join('.', 'virtualbox', 'library.py')
787785
if os.path.exists(library_path):
788786
os.unlink(library_path)
789-
with open(library_path, 'w') as f:
787+
with open(library_path, 'wb') as f:
790788
f.write(code)
791789

dev-requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
tox==2.7.0
22
flake8==3.3.0
33
Sphinx==1.6.1
4+
requests==2.18.3
5+
begins
6+
funconf

tox.ini

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = lint, docs, packaging
2+
envlist = lint, docs, packaging, build
33

44
[testenv:lint]
55
commands =
@@ -16,3 +16,8 @@ commands =
1616
python -m pip install readme_renderer check-manifest
1717
check-manifest --ignore *.yml,.github*
1818
python setup.py check --metadata --restructuredtext --strict
19+
20+
[testenv:build]
21+
commands =
22+
python -m pip install -r dev-requirements.txt
23+
python build.py --build-against-master --force-download

0 commit comments

Comments
 (0)