Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.

Commit aebb993

Browse files
authored
Merge pull request #13 from sijis/feature/py3_compat
Enable python3 support
2 parents 02e1529 + 9ef7094 commit aebb993

File tree

6 files changed

+22
-17
lines changed

6 files changed

+22
-17
lines changed

dev-requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
coverage==3.7.1
1+
coverage
22
nose
33
nose-cov
4-
testtools
4+
testtools

packer.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ def __init__(self, packerfile, exc=None, only=None, vars=None,
4141
self.packer = sh.Command(exec_path)
4242
self.packer = self.packer.bake(**kwargs)
4343

44-
def build(
45-
self, parallel=True, debug=False, force=False,
46-
machine_readable=False):
44+
def build(self, parallel=True, debug=False, force=False,
45+
machine_readable=False):
4746
"""Executes a `packer build`
4847
4948
:param bool parallel: Run builders in parallel
@@ -74,8 +73,8 @@ def fix(self, to_file=None):
7473
result = self.packer_cmd()
7574
if to_file:
7675
with open(to_file, 'w') as f:
77-
f.write(result.stdout)
78-
result.fixed = json.loads(result.stdout)
76+
f.write(result.stdout.decode())
77+
result.fixed = json.loads(result.stdout.decode())
7978
return result
8079

8180
def inspect(self, mrf=True):
@@ -115,7 +114,8 @@ def inspect(self, mrf=True):
115114

116115
result = self.packer_cmd()
117116
if mrf:
118-
result.parsed_output = self._parse_inspection_output(result.stdout)
117+
result.parsed_output = self._parse_inspection_output(
118+
result.stdout.decode())
119119
else:
120120
result.parsed_output = None
121121
return result

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def read(*parts):
2020
description='A Python interface for Hashicorp\'s Packer',
2121
long_description=read('README.rst'),
2222
py_modules=['packer'],
23-
install_requires=["sh==1.11"],
23+
install_requires=["sh"],
2424
classifiers=[
2525
'Programming Language :: Python',
2626
'Natural Language :: English',

tests/resources/simple-test.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"builders": [
3+
{
4+
"type": "null",
5+
"ssh_host": "127.0.0.1",
6+
"ssh_username": "root",
7+
"ssh_password": "password"
8+
}
9+
]
10+
}

tests/test_packer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
PACKER_PATH = '/usr/bin/packer'
77
TEST_RESOURCES_DIR = 'tests/resources'
8-
TEST_PACKERFILE = os.path.join(TEST_RESOURCES_DIR, 'packerfile.json')
8+
TEST_PACKERFILE = os.path.join(TEST_RESOURCES_DIR, 'simple-test.json')
99
TEST_BAD_PACKERFILE = os.path.join(TEST_RESOURCES_DIR, 'badpackerfile.json')
1010

1111

tox.ini

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
# content of: tox.ini , put in same dir as setup.py
22
[tox]
3-
envlist=flake8,py27,py26
3+
envlist=flake8,py27,py26,py35
44

5-
[testenv:py26]
6-
deps =
7-
-rdev-requirements.txt
8-
commands=nosetests --with-cov --cov-report term-missing --cov packer tests -v
9-
10-
[testenv:py27]
5+
[testenv]
116
deps =
127
-rdev-requirements.txt
138
commands=nosetests --with-cov --cov-report term-missing --cov packer tests -v

0 commit comments

Comments
 (0)