Skip to content

Video editing with Python

Update #530 - Split reqs and add setup.py handling

Mark Beacome78928e63cb0
diff --git a/.gitignore b/.gitignore
index 4afc3b27..805b40e9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,6 +10,7 @@
dist
build
eggs
+.eggs
parts
bin
var
@@ -53,3 +54,7 @@ nosetests.xml
# Tests
tests/media
+media/
+
+# Documentation
+docs/build/
diff --git a/README.rst b/README.rst
index 5c22a709..6298968d 100644
--- a/README.rst
+++ b/README.rst
@@ -60,6 +60,10 @@ If you have neither ``setuptools`` nor ``ez_setup`` installed, the command above
Optional but useful dependencies
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+You can install ``moviepy`` with all dependencies via:
+
+ $ (sudo) pip install moviepy[optional]
+
ImageMagick_ is not strictly required, but needed if you want to incorporate texts. It can also be used as a backend for GIFs, though you can also create GIFs with MoviePy without ImageMagick.
Once you have installed ImageMagick, it will be automatically detected by MoviePy, **except on Windows!** Windows users, before installing MoviePy by hand, need to edit ``moviepy/config_defaults.py`` to provide the path to the ImageMagick binary, which is called `convert`. It should look like this ::
@@ -74,11 +78,12 @@ For advanced image processing, you will need one or several of the following pac
- Scipy_ (for tracking, segmenting, etc.) can be used to resize video clips if PIL and OpenCV are not installed.
- `Scikit Image`_ may be needed for some advanced image manipulation.
- `OpenCV 2.4.6`_ or a more recent version (one that provides the package ``cv2``) may be needed for some advanced image manipulation.
+- `Matplotlib`_
Once you have installed it, ImageMagick will be automatically detected by MoviePy, (except for windows users and Ubuntu 16.04LTS users).
For Windows users, before installing MoviePy by hand, go into the ``moviepy/config_defaults.py`` file and provide the path to the ImageMagick binary called `convert`. It should look like this ::
-
+
IMAGEMAGICK_BINARY = "C:\\Program Files\\ImageMagick_VERSION\\convert.exe"
For Ubuntu 16.04LTS users, after installing MoviePy on the terminal, IMAGEMAGICK will not be detected by moviepy. This bug can be fixed. Modify the file in this directory: /etc/ImageMagick-6/policy.xml, comment out the statement <!-- <policy domain="path" rights="none" pattern="@*" /> -->.
@@ -88,6 +93,24 @@ PyGame_ is needed for video and sound previews (useless if you intend to work wi
For instance, using the method ``clip.resize`` requires that at least one of Scipy, PIL, Pillow or OpenCV is installed.
+Documentation
+-------------
+
+The documentation can be generated and viewed via:
+
+ $ cd docs/
+ $ make clean html
+ $ open build/html/index.html
+
+
+Running Tests
+-------------
+
+The testing suite can be executed via:
+
+ $ python setup.py test
+
+
Contribute
----------
@@ -130,6 +153,7 @@ Maintainers
.. _tqdm: https://github.com/noamraph/tqdm
.. _ffmpeg: http://www.ffmpeg.org/download.html
.. _ImageMagick: http://www.imagemagick.org/script/index.php
+.. _`Matplotlib`: https://matplotlib.org/
.. People
.. _Zulko: https://github.com/Zulko
diff --git a/docs/Makefile b/docs/Makefile
index c077a760..5c6c2d7c 100644
--- a/docs/Makefile
+++ b/docs/Makefile
@@ -2,10 +2,10 @@
#
# You can set these variables from the command line.
-SPHINXOPTS =
+SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
-BUILDDIR = ../../docs
+BUILDDIR = build
PDFBUILDDIR = /tmp
PDF = ../manual.pdf
diff --git a/docs/makehtml.sh b/docs/makehtml.sh
index 6f848c3c..3bde8ca0 100755
--- a/docs/makehtml.sh
+++ b/docs/makehtml.sh
@@ -1,8 +1,9 @@
-make html
+#!/bin/sh
+make clean html
# open generated HTML files
if [[ $(uname) == 'Darwin' ]]; then
- open '../../docs/html/index.html' -a Firefox
+ open 'build/html/index.html' -a Firefox
elif [[ $(uname) == 'Linux' ]]; then
- firefox ../../docs/html/index.html
+ firefox build/html/index.html
fi
diff --git a/requirements/base.txt b/requirements/base.txt
new file mode 100644
index 00000000..e27389ea
--- /dev/null
+++ b/requirements/base.txt
@@ -0,0 +1,4 @@
+imageio==2.1.2
+numpy==1.12.1
+decorator==4.0.11
+tqdm==4.11.2
diff --git a/requirements_docs.txt b/requirements/docs.txt
similarity index 73%
rename from requirements_docs.txt
rename to requirements/docs.txt
index d0375d93..1ba3f427 100644
--- a/requirements_docs.txt
+++ b/requirements/docs.txt
@@ -1,6 +1,5 @@
+-r optional.txt
Sphinx>=1.5.2
sphinx_rtd_theme>=0.1.10b0
numpydoc>=0.6.0
pygame==1.9.3
-scipy==0.19.0
-tqdm==4.11.2
\ No newline at end of file
diff --git a/requirements/optional.txt b/requirements/optional.txt
new file mode 100644
index 00000000..731e0252
--- /dev/null
+++ b/requirements/optional.txt
@@ -0,0 +1,4 @@
+-r base.txt
+scikit-image==0.13.0
+scipy==0.19.0
+matplotlib==2.0.0
diff --git a/requirements/test.txt b/requirements/test.txt
new file mode 100644
index 00000000..ee2ac7aa
--- /dev/null
+++ b/requirements/test.txt
@@ -0,0 +1,4 @@
+-r optional.txt
+nose==1.3.7
+pytest==3.0.7
+sklearn==0.18.1
diff --git a/setup.py b/setup.py
index ac0a4918..d8f9bf60 100644
--- a/setup.py
+++ b/setup.py
@@ -2,28 +2,91 @@
# This will try to import setuptools. If not here, it will reach for the embedded
# ez_setup (or the ez_setup package). If none, it fails with a message
+import sys
+from codecs import open
+
try:
- from setuptools import setup
+ from setuptools import find_packages, setup
+ from setuptools.command.test import test as TestCommand
except ImportError:
try:
import ez_setup
ez_setup.use_setuptools()
except ImportError:
- raise ImportError("MoviePy could not be installed, probably because"
- " neither setuptools nor ez_setup are installed on this computer."
- "\nInstall ez_setup ([sudo] pip install ez_setup) and try again.")
+ raise ImportError('MoviePy could not be installed, probably because'
+ ' neither setuptools nor ez_setup are installed on this computer.'
+ '\nInstall ez_setup ([sudo] pip install ez_setup) and try again.')
+
+
+class PyTest(TestCommand):
+ """Handle test execution from setup."""
+
+ user_options = [('pytest-args=', 'a', "Arguments to pass into py.test")]
+
+ def initialize_options(self):
+ """Initialize the PyTest options."""
+ TestCommand.initialize_options(self)
+ self.pytest_args = []
+
+ def finalize_options(self):
+ """Finalize the PyTest options."""
+ TestCommand.finalize_options(self)
+ self.test_args = []
+ self.test_suite = True
+
+ def run_tests(self):
+ """Run the PyTest testing suite."""
+ try:
+ import pytest
+ except ImportError:
+ raise ImportError('Running tests requires additional dependencies.'
+ '\nPlease run (pip install -r requirements/test.txt)')
+
+ errno = pytest.main(self.pytest_args)
+ sys.exit(errno)
-from setuptools import setup, find_packages
exec(open('moviepy/version.py').read()) # loads __version__
-setup(name='moviepy',
+requires = ['numpy', 'decorator', 'imageio', 'tqdm']
+test_requirements = ['pytest>=2.8.0', 'nose', 'sklearn']
+optional_requirements = ['scikit-image', 'scipy']
+
+with open('README.rst', 'r', 'utf-8') as f:
+ readme = f.read()
+
+setup(
+ name='moviepy',
version=__version__,
author='Zulko 2017',
description='Video editing with Python',
- long_description=open('README.rst').read(),
- url='http://zulko.github.io/moviepy/',
+ long_description=readme,
+ url='https://zulko.github.io/moviepy/',
license='MIT License',
- keywords="video editing audio compositing ffmpeg",
- packages= find_packages(exclude='docs'),
- install_requires= ['numpy', 'decorator', 'imageio', 'tqdm'])
+ classifiers=(
+ 'Development Status :: 5 - Production/Stable',
+ 'Intended Audience :: Developers',
+ 'Natural Language :: English',
+ 'License :: OSI Approved :: MIT License',
+ 'Programming Language :: Python',
+ 'Programming Language :: Python :: 2.6',
+ 'Programming Language :: Python :: 2.7',
+ 'Programming Language :: Python :: 3',
+ 'Programming Language :: Python :: 3.3',
+ 'Programming Language :: Python :: 3.4',
+ 'Programming Language :: Python :: 3.5',
+ 'Programming Language :: Python :: 3.6',
+ 'Topic :: Multimedia',
+ 'Topic :: Multimedia :: Sound/Audio',
+ 'Topic :: Multimedia :: Sound/Audio :: Analysis',
+ 'Topic :: Multimedia :: Video',
+ 'Topic :: Multimedia :: Video :: Capture',
+ 'Topic :: Multimedia :: Video :: Conversion',
+ ),
+ keywords='video editing audio compositing ffmpeg',
+ packages=find_packages(exclude='docs'),
+ cmdclass={'test': PyTest},
+ tests_require=test_requirements,
+ install_requires=requires,
+ extras_require={'optional': optional_requirements}
+)