Skip to content

Latest commit

 

History

History
127 lines (72 loc) · 3.65 KB

INSTALL.win.rst

File metadata and controls

127 lines (72 loc) · 3.65 KB

Windows

Tested on Windows 8.1, Windows 10 1809 and Windows 10 20H2 (all amd64)

Build Requirements

Ensure that every requirement is on the system path and Windows can find it:

> where cmake
C:\Program Files\CMake\bin\cmake.exe
> where ninja
C:\Windows\System32\ninja.exe
> where git
C:\Program Files\Git\cmd\git.exe
C:\Program Files\Git\mingw64\bin\git.exe
> where nasm
C:\Program Files\NASM\nasm.exe
> where python
C:\Python39\python.exe
> where pip
C:\Python39\Scripts\pip.exe

Your paths can be different but if you get INFO: Could not find files for the given pattern(s). that means this executable is not in path.

Build Steps

Warning: The build steps are tested only on amd64 (x86_64) architecture.
  1. Open the Native Tools Command Prompt for VS 2019

    It will open command line window but from it you will be able to compile code.

  2. Create a folder just to have everything in the same place:

    • mkdir C:\python-avif
    • cd C:\python-avif
  3. Now you can clone the repositories:

    • git clone https://github.com/Julian/avif.git
    • git clone https://github.com/AOMediaCodec/libavif.git

    The directory with python module will now appear as avif and the official avif implementation written in c will be called libavif

  4. You will also need to clone and compile the AOM repository.

    It can be done using script included in libavif\ext directory:

    • cd libavif\ext
    • aom.cmd
    • cd ..
  5. After that you can configure libavif with AOM support:

    • Ensure that you are in the main libavif directory (cd should give C:\python-avif\libavif)
    • cd cmake
    • cmake .. -DAVIF_CODEC_AOM=ON -DAVIF_LOCAL_AOM=ON
  6. Now open a new Native Tools Command Prompt for VS 2019 window as Administrator.

  7. Change current directory to cmake in this window too, then compile and install the project.

    • cd C:\python-avif\libavif\cmake
    • msbuild INSTALL.vcxproj /p:Configuration=Release
  8. After the installation is complete, C:\Program Files (x86)\libavif folder should be created and you will find there all necessary libavif resources. You can close the window that you opened as Administrator and continue in the first window.

  9. Then you can change directory to this project and change INCLUDE variable.

    • cd C:\python-avif\avif
    • set INCLUDE=%INCLUDE%;C:\Program Files (x86)\libavif\include

    You should also copy avif.lib file to project's directory:

    • xcopy "C:\Program Files (x86)\libavif\lib\avif.lib" .
  10. Now you can install the avif Python package:

    $ python -m pip install .
  11. In order to import the library you should copy avif.dll (that you can find in C:\Program Files (x86)\libavif\bin) to the installed module directory. You can use pip show avif to know where the module is installed.

    In my case it says: ... Location: c:\python39\lib\site-packages\avif-0.0.0-py3.9-win-amd64.egg ...

    Then you can copy the .dll:

    • xcopy "C:\Program Files (x86)\libavif\bin\avif.dll" "c:\python39\lib\site-packages\avif-0.0.0-py3.9-win-amd64.egg"
  12. You should now be able to import the library without any errors!

    >>> import avif

    You can also run the examples.