Skip to content

Video editing with Python

Migrate Windows workflow to Github Actions (#1597)

Álvaro Mondéjar2978db735a33
diff --git a/.github/workflows/test_suite.yml b/.github/workflows/test_suite.yml
index f1ed1ce2..9ca45411 100644
--- a/.github/workflows/test_suite.yml
+++ b/.github/workflows/test_suite.yml
@@ -54,67 +54,83 @@ jobs:
brew install imagemagick
# needed for installing matplotlib
brew install pkg-config
- python -m pip install --upgrade wheel
- python -m pip install --upgrade setuptools
+ python -m pip install --upgrade wheel setuptools coveralls
python -m pip install ".[test, optional]"
- name: Test with pytest
run: |
- pythonw -m pytest tests/ --doctest-modules -v
-
-
-# TODO Re-enable when ImageMagick is fixed or removed
-# windows:
-# runs-on: windows-latest
-# strategy:
-# matrix:
-# python-version: [3.6, 3.7, 3.8]
-# fail-fast: false
-# steps:
-# - uses: actions/checkout@v2
-# - name: Set up Python ${{ matrix.python-version }}
-# uses: actions/setup-python@v2
-# with:
-# python-version: ${{ matrix.python-version }}
-# - name: Python Version Info
-# shell: cmd
-# run: |
-# python --version
-# which python
-# python -m site --user-site
-#
-# - name: Install Dependencies
-# shell: cmd
-# run: |
-# python find_latest_imagemagick_version.py > temp.txt
-# set /p IMAGE_MAGICK_VERSION=<temp.txt
-#
-# echo %IMAGE_MAGICK_VERSION%
-# echo https://imagemagick.org/download/binaries/ImageMagick-%IMAGE_MAGICK_VERSION%-%ARCH%-static.exe
-# :: Download ImageMagick installer (which also installs ffmpeg.)
-# :: From http://ftp.fifi.org/ImageMagick/binaries/
-# :: Might need to be updated from time to time
-# :: Versions >=7.0 have problems - executables changed names.
-# :: Assume 64-bit. Need to change to x86 for 32-bit.
-# curl https://imagemagick.org/download/binaries/ImageMagick-%IMAGE_MAGICK_VERSION%-x64-static.exe -o ImageMagick.exe
-#
-# :: Install ImageMagick, telling InnoSetup to not open a window and change default install dir
-# ImageMagick.exe /SILENT /SP /DIR="%IMAGE_MAGICK_INSTALL_DIR%"
-#
-# :: Inspect contents and set env vars
-# dir "%IMAGE_MAGICK_INSTALL_DIR%"
-# set IMAGEMAGICK_BINARY="%IMAGE_MAGICK_INSTALL_DIR%//convert.exe"
-# echo %IMAGEMAGICK_BINARY%
-# set FMPEG_BINARY="%IMAGE_MAGICK_INSTALL_DIR%//ffmpeg.exe"
-# echo %FMPEG_BINARY%
-#
-# python -m pip install --upgrade wheel
-# python -m pip install --upgrade setuptools
-# python -m pip install ".[test]"
-#
-# - name: PyTest
-# run: |
-# pytest
+ pythonw -m pytest tests/ --doctest-modules -v --cov moviepy --cov-report term-missing
+
+ - name: Coveralls
+ run: coveralls
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ COVERALLS_SERVICE_NAME: github
+
+
+ windows:
+ runs-on: windows-latest
+ strategy:
+ matrix:
+ python-version: [3.6, 3.7, 3.8, 3.9]
+ fail-fast: false
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up Python ${{ matrix.python-version }}
+ uses: actions/setup-python@v2
+ with:
+ python-version: ${{ matrix.python-version }}
+
+ - name: Get ImageMagick installer from cache
+ id: imagemagick-installer-cache
+ uses: actions/cache@v2
+ with:
+ path: |
+ ImageMagick.exe
+ key: ${{ runner.os }}-6.9.12-13-Q16
+
+ - name: Download ImageMagick installer
+ shell: cmd
+ if: steps.imagemagick-installer-cache.outputs.cache-hit != 'true'
+ run: |
+ echo https://download.imagemagick.org/ImageMagick/download/binaries/ImageMagick-6.9.12-13-Q16-x86-static.exe
+ curl https://download.imagemagick.org/ImageMagick/download/binaries/ImageMagick-6.9.12-13-Q16-x86-static.exe -o ImageMagick.exe
+
+ - name: Install ImageMagick
+ id: imagemagick-install
+ shell: cmd
+ run: |
+ set IMAGEMAGICK_INSTALL_DIR=%CD%\imagemagick
+ mkdir %IMAGEMAGICK_INSTALL_DIR%
+ echo %IMAGEMAGICK_INSTALL_DIR%
+
+ ImageMagick.exe /SILENT /SP /DIR=%IMAGEMAGICK_INSTALL_DIR%
+ dir imagemagick
+
+ move imagemagick\ffmpeg.exe ffmpeg.exe
+ move imagemagick\convert.exe convert.exe
+
+ del /F ImageMagick.exe
+
+ - name: Install Python dependencies
+ run: |
+ python -m pip install --upgrade wheel setuptools coveralls
+ python -m pip install ".[test]"
+
+ - name: Check third party dependencies
+ run: |
+ python moviepy\config.py
+
+ - name: PyTest
+ shell: cmd
+ run: |
+ python -m pytest --cov moviepy --cov-report term-missing
+
+ - name: Coveralls
+ run: coveralls
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ COVERALLS_SERVICE_NAME: github
linux:
runs-on: ubuntu-latest
@@ -143,6 +159,7 @@ jobs:
if: ${{ matrix.python-version == '3.7' }}
run: |
python -m pip install ".[test, doc]"
+ python -m pip install python-dotenv
- name: Install test and optional requirements
if: ${{ matrix.python-version != '3.7' }}
diff --git a/README.rst b/README.rst
index 416169ff..79c9e935 100644
--- a/README.rst
+++ b/README.rst
@@ -10,9 +10,6 @@ MoviePy
.. image:: https://img.shields.io/github/workflow/status/Zulko/moviepy/Run%20Test%20Suite?logo=github
:target: https://github.com/Zulko/moviepy/actions?query=workflow%3A%22Run+Test+Suite%22
:alt: Build status on gh-actions
-.. image:: https://ci.appveyor.com/api/projects/status/github/zulko/moviepy?svg=true
- :target: https://ci.appveyor.com/project/Zulko/moviepy
- :alt: Build status on appveyor
.. image:: https://img.shields.io/coveralls/github/Zulko/moviepy/master?logo=coveralls
:target: https://coveralls.io/github/Zulko/moviepy?branch=master
:alt: Code coverage from coveralls.io
diff --git a/appveyor.yml b/appveyor.yml
deleted file mode 100644
index daa77a8b..00000000
--- a/appveyor.yml
+++ /dev/null
@@ -1,78 +0,0 @@
-image: Visual Studio 2017
-
-environment:
- global:
- IMAGE_MAGICK_INSTALL_DIR: c://ImageMagick
- matrix:
- - PYTHON: "C:\\Python36-x64"
- PYTHON_ARCH: "64"
- ARCH: x64
-
- - PYTHON: "C:\\Python37-x64"
- PYTHON_ARCH: "64"
- ARCH: x64
-
-install:
- # If there is a newer build queued for the same PR, cancel this one.
- # The AppVeyor 'rollout builds' option is supposed to serve the same
- # purpose but it is problematic because it tends to cancel builds pushed
- # directly to master instead of just PR builds (or the converse).
- # credits: JuliaLang developers.
- - ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
- https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
- Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
- throw "There are newer queued builds for this pull request, failing early." }
-
- # Prepend desired Python to the PATH of this build (this cannot be
- # done from inside the powershell script as it would require to restart
- # the parent CMD process).
- - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
-
- - python -m pip install --upgrade pip --user
-
- # Find latest image magick version by parsing website
-
- - python find_latest_imagemagick_version.py > temp.txt
- - set /p IMAGE_MAGICK_VERSION=<temp.txt
-
- - echo %IMAGE_MAGICK_VERSION%
- # Download ImageMagick installer (which also installs ffmpeg.)
- # From http://ftp.fifi.org/ImageMagick/binaries/
- # Might need to be updated from time to time
- # Versions >=7.0 have problems - executables changed names.
- # Assume 64-bit. Need to change to x86 for 32-bit.
- - curl https://download.imagemagick.org/ImageMagick/download/binaries/ImageMagick-%IMAGE_MAGICK_VERSION%-%ARCH%-static.exe -o ImageMagick.exe
-
- # Install ImageMagick, telling InnoSetup to not open a window and change default install dir
- - ImageMagick.exe /SILENT /SP /DIR="%IMAGE_MAGICK_INSTALL_DIR%"
-
- # Inspect contents and set env vars
- - dir "%IMAGE_MAGICK_INSTALL_DIR%"
- - set IMAGEMAGICK_BINARY=%IMAGE_MAGICK_INSTALL_DIR%//convert.exe
- - echo %IMAGEMAGICK_BINARY%
- - set FMPEG_BINARY="%IMAGE_MAGICK_INSTALL_DIR%//ffmpeg.exe"
- - echo %FMPEG_BINARY%
-
-build_script:
- # Install all dependencies, including dev dependencies
- - pip install ".[test, optional]"
-
-test_script:
- - pytest
-
-# TODO: Support the post-test generation of binaries - Pending a version number that is supported (e.g. 0.3.0)
-#
-# after_test:
-#
-# # If tests are successful, create binary packages for the project.
-# - "%CMD_IN_ENV% python c:\\projects\\moviepy\\setup.py bdist_wheel"
-# - "%CMD_IN_ENV% python c:\\projects\\moviepy\\setup.py bdist_wininst"
-# - "%CMD_IN_ENV% python c:\\projects\\moviepy\\setup.py bdist_msi"
-# - ps: "ls dist"
-#
-# artifacts:
-# # Archive the generated packages in the ci.appveyor.com build report.
-# - path: dist\*
-#
-# on_success:
-# - TODO: upload the content of dist/*.whl to a public wheelhouse
diff --git a/moviepy/config.py b/moviepy/config.py
index 0ca48728..f5e74838 100644
--- a/moviepy/config.py
+++ b/moviepy/config.py
@@ -19,6 +19,8 @@ except ImportError:
FFMPEG_BINARY = os.getenv("FFMPEG_BINARY", "ffmpeg-imageio")
IMAGEMAGICK_BINARY = os.getenv("IMAGEMAGICK_BINARY", "auto-detect")
+IS_POSIX_OS = os.name == "posix"
+
def try_cmd(cmd):
"""TODO: add documentation"""
@@ -43,7 +45,7 @@ elif FFMPEG_BINARY == "auto-detect":
if try_cmd(["ffmpeg"])[0]:
FFMPEG_BINARY = "ffmpeg"
- elif try_cmd(["ffmpeg.exe"])[0]:
+ elif not IS_POSIX_OS and try_cmd(["ffmpeg.exe"])[0]:
FFMPEG_BINARY = "ffmpeg.exe"
else:
FFMPEG_BINARY = "unset"
@@ -76,11 +78,13 @@ if IMAGEMAGICK_BINARY == "auto-detect":
except Exception:
IMAGEMAGICK_BINARY = "unset"
- elif try_cmd(["convert"])[0]:
- IMAGEMAGICK_BINARY = "convert"
-
- else:
- IMAGEMAGICK_BINARY = "unset"
+ if IMAGEMAGICK_BINARY in ["unset", "auto-detect"]:
+ if try_cmd(["convert"])[0]:
+ IMAGEMAGICK_BINARY = "convert"
+ elif not IS_POSIX_OS and try_cmd(["convert.exe"])[0]:
+ IMAGEMAGICK_BINARY = "convert.exe"
+ else:
+ IMAGEMAGICK_BINARY = "unset"
else:
if not os.path.exists(IMAGEMAGICK_BINARY):
raise IOError(f"ImageMagick binary cannot be found at {IMAGEMAGICK_BINARY}")