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

Skip to content
8000

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
OutputNod F438 e,
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

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[aliases]
2+
test=pytest

setup.py

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
from distutils.core import setup
2-
from ffmpeg._filters import __all__ as filter_names
1+
from setuptools import setup
32
from textwrap import dedent
43
import subprocess
54

@@ -61,18 +60,34 @@ def get_current_commit_hash():
6160
'wrapper',
6261
]
6362

64-
keywords = misc_keywords + file_formats + filter_names
63+
keywords = misc_keywords + file_formats
6564

6665
setup(
67-
name = 'ffmpeg-python',
68-
packages = ['ffmpeg'],
69-
version = '0.1.5',
70-
description = 'Python bindings for FFmpeg - with support for complex filtering',
71-
author = 'Karl Kroening',
72-
author_email = 'karlk@kralnet.us',
73-
url = 'https://github.com/kkroening/ffmpeg-python',
74-
download_url = download_url,
75-
classifiers = [],
76-
keywords = keywords,
77-
long_description = long_description,
66+
name='ffmpeg-python',
67+
packages=['ffmpeg'],
68+
setup_requires=['pytest-runner'],
69+
tests_require=['pytest'],
70+
version='0.1.5',
71+
description='Python bindings for FFmpeg - with support for complex filtering',
72+
author='Karl Kroening',
73+
author_email='karlk@kralnet.us',
74+
url='https://github.com/kkroening/ffmpeg-python',
75+
download_url=download_url,
76+
keywords=keywords,
77+
long_description=long_description,
78+
install_requires=['future'],
79+
classifiers=[
80+
'Intended Audience :: Developers',
81+
'License :: OSI Approved :: Apache Software License',
82+
'Natural Language :: English',
83+
'Operating System :: OS Independent',
84+
'Programming Language :: Python',
85+
'Programming Language :: Python :: 2',
86+
'Programming Language :: Python :: 2.7',
87+
'Programming Language :: Python :: 3',
88+
'Programming Language :: Python :: 3.3',
89+
'Programming Language :: Python :: 3.4',
90+
'Programming Language :: Python :: 3.5',
91+
'Programming Language :: Python :: 3.6',
92+
],
7893
)

tox.ini

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Tox (https://tox.readthedocs.io/) is a tool for running tests
2+
# in multiple virtualenvs. This configuration file will run the
3+
# test suite on all supported python versions. To use it, "pip install tox"
4+
# and then run "tox" from this directory.
5+
6+
[tox]
7+
envlist = py27, py33, py34, py35, py36, pypy
8+
9+
[testenv]
10+
commands = py.test
11+
deps =
12+
future
13+
pytest

0 commit comments

Comments
 (0)
0