8000 Merge pull request #12 from kkroening/support-python3 · Meshinfo/ffmpeg-python@45f1494 · GitHub
[go: up one dir, main page]

Skip to content

Commit 45f1494

Browse files
authored
Merge pull request kkroening#12 from kkroening/support-python3
Add support for Python3 (fixes kkroening#10)
2 parents eb9e827 + 26e7cff commit 45f1494

File tree

13 files changed

+105
-24
lines changed

13 files changed

+105
-24
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
.cache
2+
.eggs
3+
.tox/
24
dist/
35
ffmpeg/tests/sample_data/dummy2.mp4
4-
venv
6+
ffmpeg_python.egg-info/
7+
venv*

.python-version

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
3.3.6
2+
3.4.6
3+
3.5.3
4+
3.6.1
5+
jython-2.7.0

.travis.yml

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,36 @@
11
language: python
22
before_install:
3-
- curl -O https://johnvansickle.com/ffmpeg/releases/ffmpeg-3.3.1-64bit-static.tar.xz
4-
- tar Jxf ffmpeg-3.3.1-64bit-static.tar.xz
3+
- >
4+
[ -f ffmpeg-3.3.1-64bit-static/ffmpeg ] || (
5+
curl -O https://johnvansickle.com/ffmpeg/releases/ffmpeg-3.3.1-64bit-static.tar.xz &&
6+
tar Jxf ffmpeg-3.3.1-64bit-static.tar.xz
7+
)
8+
matrix:
9+
include:
10+
- python: 2.7
11+
env:
12+
- TOX_ENV=py27
13+
- python: 3.3
14+
env:
15+
- TOX_ENV=py33
16+
- python: 3.4
17+
env:
18+
- TOX_ENV=py34
19+
- python: 3.5
20+
env:
21+
- TOX_ENV=py35
22+
- python: 3.6
23+
env:
24+
- TOX_ENV=py36
25+
- python: pypy
26+
env:
27+
- TOX_ENV=pypy
528
install:
6-
- pip install -r requirements.txt
29+
- pip install tox
730
script:
831
- export PATH=$(readlink -f ffmpeg-3.3.1-64bit-static):$PATH
9-
- py.test
32+
- tox -e $TOX_ENV
33+
cache:
34+
directories:
35+
- .tox
36+
- ffmpeg-3.3.1-64bit-static

ffmpeg/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import unicode_literals
12
from . import _filters, _ffmpeg, _run
23
from ._filters import *
34
from ._ffmpeg import *

ffmpeg/_ffmpeg.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import unicode_literals
12
from .nodes import (
23
FilterNode,
34
GlobalNode,

ffmpeg/_filters.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import unicode_literals
12
from .nodes import (
23
FilterNode,
34
operator,

ffmpeg/_run.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from __future__ import unicode_literals
2+
3+
from past.builtins import basestring
14
import operator as _operator
25
import subprocess as _subprocess
36

@@ -13,6 +16,7 @@
1316
operator,
1417
OutputNode,
1518
)
19+
from functools import reduce
1620

1721
def _get_stream_name(name):
1822
return '[{}]'.format(name)

ffmpeg/nodes.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from __future__ import unicode_literals
2+
3+
from builtins import object
14
import hashlib
25
import json
36

@@ -18,15 +21,18 @@ def __repr__(self):
1821
formatted_props += ['{}={!r}'.format(key, self._kwargs[key]) for key in sorted(self._kwargs)]
1922
return '{}({})'.format(self._name, ','.join(formatted_props))
2023

24+
def __hash__(self):
25+
return int(self._hash, base=16)
26+
2127
def __eq__(self, other):
2228
return self._hash == other._hash
2329

2430
def _update_hash(self):
2531
props = {'args': self._args, 'kwargs': self._kwargs}
26-
my_hash = hashlib.md5(json.dumps(props, sort_keys=True)).hexdigest()
32+
my_hash = hashlib.md5(json.dumps(props, sort_keys=True).encode('utf-8')).hexdigest()
2733
parent_hashes = [parent._hash for parent in self._parents]
2834
hashes = parent_hashes + [my_hash]
29-
self._hash = hashlib.md5(','.join(hashes)).hexdigest()
35+
self._hash = hashlib.md5(','.join(hashes).encode('utf-8')).hexdigest()
3036

3137

3238
class InputNode(Node):

ffmpeg/tests/test_ffmpeg.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from ffmpeg.nodes import operator, FilterNode
1+
from __future__ import unicode_literals
22
import ffmpeg
33
import os
44
import pytest
@@ -72,12 +72,12 @@ def test_repr():
7272
trim3 = ffmpeg.trim(in_file, start_frame=50, end_frame=60)
7373
concatted = ffmpeg.concat(trim1, trim2, trim3)
7474
output = ffmpeg.output(concatted, 'dummy2.mp4')
75-
assert repr(in_file) == "input(filename='dummy.mp4')"
75+
assert repr(in_file) == "input(filename={!r})".format('dummy.mp4')
7676
assert repr(trim1) == "trim(end_frame=20,start_frame=10)"
7777
assert repr(trim2) == "trim(end_frame=40,start_frame=30)"
7878
assert repr(trim3) == "trim(end_frame=60,start_frame=50)"
7979
assert repr(concatted) == "concat(n=3)"
80-
assert repr(output) == "output(filename='dummy2.mp4')"
80+
assert repr(output) == "output(filename={!r})".format('dummy2.mp4')
8181

8282

8383
def test_get_args_simple():

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
future
12
pytest
3+
pytest-runner
24
sphinx
5+
tox

0 commit comments

Comments
 (0)
0