Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a download script for the bundled library #141

Open
wants to merge 1 commit into
base: wheels
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 52 additions & 72 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,30 +70,22 @@ for:
-
matrix:
only:
- APPVEYOR_BUILD_WORKER_IMAGE: *windows_image
- APPVEYOR_BUILD_WORKER_IMAGE: *windows_image
install:
- "SET PATH=%PYTHON%;%PYTHON%/Scripts;%PATH%"
- "python --version"
- "IF %PYTHON:~-4% == -x64 (SET ARCH=x64) ELSE (SET ARCH=i386)"
- "IF %PYTHON:~-4% == -x64 (SET PLATFORM_WHEEL=win_amd64) ELSE (SET PLATFORM_WHEEL=win32)"
- ps: "Start-FileDownload https://mediaarea.net/download/binary/mediainfo/${Env:MEDIAINFO_VERSION}/MediaInfo_CLI_${Env:MEDIAINFO_VERSION}_Windows_${Env:ARCH}.zip"
- ps: "unzip -o MediaInfo_CLI_${Env:MEDIAINFO_VERSION}_Windows_${Env:ARCH}.zip LIBCURL.DLL"
- ps: "Start-FileDownload https://mediaarea.net/download/binary/libmediainfo0/${Env:MEDIAINFO_VERSION}/MediaInfo_DLL_${Env:MEDIAINFO_VERSION}_Windows_${Env:ARCH}_WithoutInstaller.7z"
- ps: "7z -y x MediaInfo_DLL_${Env:MEDIAINFO_VERSION}_Windows_${Env:ARCH}_WithoutInstaller.7z MediaInfo.dll Developers/License.html"
# Required for tests to pass with tox, Windows looks for DLLs in PATH
- ps: "Copy-Item -Path MediaInfo.dll -Destination ${Env:PYTHON}"
- "move MediaInfo.dll pymediainfo"
- "move Developers\\License.html docs"
- "pip install tox"
build: off
- "pip install pdm tox"
- "pdm install --no-self"
build_script:
- ps: |
IF %PYTHON:~-4% == -x64 (SET ARCH=x86_64) ELSE (SET ARCH=i386)
pdm run build_win32_${Env:ARCH}
test_script:
- "tox"
deploy_script:
- ps: |
If (($env:APPVEYOR_REPO_TAG -eq "true") -and ($env:TOXENV -eq $env:DEPLOY_TOXENV)) {
pip install twine wheel pdm
pdm build --no-sdist
wheel tags --remove --platform-tag=${Env:PLATFORM_WHEEL} dist/*-py3-none-any.whl
pip install twine wheel
Invoke-Expression "twine upload --skip-existing dist/*.whl"
}
-
Expand All @@ -104,80 +96,68 @@ for:
set -eo pipefail
PYTHON_VERSION="$(sed -E 's/^py(3)(.*)$/\1.\2/' <<< "$TOXENV")"
source "${HOME}/venv${PYTHON_VERSION}/bin/activate"
pip install tox
curl https://mediaarea.net/download/binary/libmediainfo0/${MEDIAINFO_VERSION}/MediaInfo_DLL_${MEDIAINFO_VERSION}_Mac_x86_64+arm64.tar.bz2 \
| tar xj MediaInfoLib/libmediainfo.0.dylib MediaInfoLib/License.html
pip install pdm tox
pdm install --no-self
build_script: |
pdm run build_darwin
# Required for tests to pass with tox
cp MediaInfoLib/libmediainfo.0.dylib /usr/local/lib/
build: off
cp src/pymediainfo/libmediainfo.0.dylib /usr/local/lib/
test_script:
- "tox"
deploy_script: |
set -eo pipefail
if [[ $APPVEYOR_REPO_TAG == "true" && $TOXENV == $DEPLOY_TOXENV ]]; then
mv MediaInfoLib/libmediainfo.0.dylib pymediainfo
mv MediaInfoLib/License.html docs
pip install twine wheel pdm
pdm build --no-sdist
wheel tags --remove --platform-tag=macosx-10.10-x86_64-macosx-11-universal2 dist/*-py3-none-any.whl
pip install twine wheel
twine upload --skip-existing dist/*.whl
fi
-
matrix:
only:
- APPVEYOR_BUILD_WORKER_IMAGE: *linux_image
- TOXENV: /^py.*/
install: |
set -eo pipefail
if [[ $TOXENV =~ doc.* ]]; then
source "${HOME}/venv${QA_PYTHON_VERSION}/bin/activate"
pip install tox
if [[ $TOXENV == pypy3 ]]; then
pushd /tmp
curl -sS "$PYPY_URL" | tar xj
PATH="$(pwd)/$(basename "$PYPY_URL" | sed -E 's/\.tar\.[^.]+$//')/bin/:$PATH"
python -m ensurepip
popd
else
if [[ $TOXENV == pypy3 ]]; then
pushd /tmp
curl -sS "$PYPY_URL" | tar xj
PATH="$(pwd)/$(basename "$PYPY_URL" | sed -E 's/\.tar\.[^.]+$//')/bin/:$PATH"
python -m ensurepip
popd
else
PYTHON_VERSION="$(sed -E 's/^py(3)(.*)$/\1.\2/' <<< "$TOXENV")"
source "${HOME}/venv${PYTHON_VERSION}/bin/activate"
fi
# "python -m pip" will work with the unpacked PyPy too, "pip" won't
python -m pip install tox
curl -O https://mediaarea.net/download/binary/libmediainfo0/${MEDIAINFO_VERSION}/MediaInfo_DLL_${MEDIAINFO_VERSION}_Lambda_x86_64.zip
unzip MediaInfo_DLL_${MEDIAINFO_VERSION}_Lambda_x86_64.zip -d x86_64
curl -O https://mediaarea.net/download/binary/libmediainfo0/${MEDIAINFO_VERSION}/MediaInfo_DLL_${MEDIAINFO_VERSION}_Lambda_arm64.zip
unzip MediaInfo_DLL_${MEDIAINFO_VERSION}_Lambda_arm64.zip -d arm64
PYTHON_VERSION="$(sed -E 's/^py(3)(.*)$/\1.\2/' <<< "$TOXENV")"
source "${HOME}/venv${PYTHON_VERSION}/bin/activate"
fi
build: off
# "python -m pip" will work with the unpacked PyPy too, "pip" won't
python -m pip install pdm tox
pdm install --no-self
build_script: |
# wheel for arm64
pdm run build_linux_arm64
# wheel for x86_64
pdm run build_linux_x86_64

test_script: |
if [[ $TOXENV =~ doc.* ]]; then
TOX_PARALLEL_NO_SPINNER=1 tox -p
else
# Use the previously downloaded library
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:x86_64/lib/"
# We want to see the progression of the tests so we can't run
# tox environments in parallel
tox
fi
# Use the previously downloaded library
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:x86_64/lib/"
# We want to see the progression of the tests so we can't run
# tox environments in parallel
tox
deploy_script: |
set -eo pipefail
if [[ $APPVEYOR_REPO_TAG == "true" && $TOXENV == $DEPLOY_TOXENV ]]; then
pip install twine wheel pdm
# source distribution
pdm build --no-wheel

# wheels
mv x86_64/LICENSE docs
# wheel x86_64
cp x86_64/lib/libmediainfo.so.0 pymediainfo/libmediainfo.so.0
pdm build --no-sdist
wheel tags --remove --platform-tag=manylinux_2_34-x86_64 dist/*-py3-none-any.whl
# wheel arm64
mv -f arm64/lib/libmediainfo.so.0 pymediainfo/libmediainfo.so.0
pdm build --no-sdist
wheel tags --remove --platform-tag=manylinux_2_34-arm64 dist/*-py3-none-any.whl

# upload
pip install twine
pdm run clean_library
pdm build
twine upload --skip-existing dist/*.gz dist/*.whl
fi
-
matrix:
only:
- APPVEYOR_BUILD_WORKER_IMAGE: *linux_image
- TOXENV: /docs.*/
install: |
set -eo pipefail
source "${HOME}/venv${QA_PYTHON_VERSION}/bin/activate"
pip install tox
build: off
test_script: |
TOX_PARALLEL_NO_SPINNER=1 tox -p
84 changes: 84 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,97 @@ Bugs = "https://github.com/sbraz/pymediainfo/issues"
[tool.pdm.version]
source = "scm"

[tool.pdm.dev-dependencies]
download_library = ["wheel>=0.44", "requests", "tqdm"]

[tool.pdm.build]
source-includes = ["scripts/", "tests/"]

[tool.pdm.scripts.types]
help = "Check type hints"
cmd = "mypy --install-types --non-interactive --config-file=pyproject.toml {args:src tests}"

[tool.pdm.scripts.docs]
help = "Build and test documentation"
composite = [
"sphinx-build -W --keep-going --color -b html docs docs/_build",
"sphinx-build -W --keep-going --color -b linkcheck docs docs/_build",
# "sphinx-build -W --keep-going --color -b doctest docs docs/_build",
]

[tool.pdm.scripts.test-nocov]
help = "Run tests without coverage"
cmd = "pytest {args:-n auto}"

[tool.pdm.scripts.test]
help = "Run tests with coverage"
cmd = "pytest --cov --cov-report=term-missing --cov-config=pyproject.toml {args:-n auto}"

[tool.pdm.scripts.download_library]
help = "Download mediainfo library"
cmd = "python scripts/download_library.py {args:-c --auto}"

[tool.pdm.scripts.clean_library]
help = "Clean mediainfo library"
cmd = "python scripts/download_library.py -c"

[tool.pdm.scripts.tag_wheel]
help = "Tag the wheel for a specific platform"
shell = "python -m wheel tags --remove --platform-tag={args} dist/*-py3-none-any.whl 2> /dev/null"

[tool.pdm.scripts.build_linux_x86_64]
help = "Build wheel with bundled library for Linux x86_64"
composite = [
"download_library -c -p linux -a x86_64",
"pdm build --no-sdist",
"tag_wheel manylinux_2_34-x86_64",
]

[tool.pdm.scripts.build_linux_arm64]
help = "Build wheel with bundled library for Linux arm64"
composite = [
"download_library -c -p linux -a arm64",
"pdm build --no-sdist",
"tag_wheel manylinux_2_34-arm64",
]

[tool.pdm.scripts.build_win32_x86_64]
help = "Build wheel with bundled library for Windows x64"
composite = [
"download_library -c -p win32 -a x86_64",
"pdm build --no-sdist",
"tag_wheel win_amd64",
]

[tool.pdm.scripts.build_win32_i386]
help = "Build wheel with bundled library for Windows x32"
composite = [
"download_library -c -p win32 -a i386",
"pdm build --no-sdist",
"tag_wheel win32",
]

[tool.pdm.scripts.build_darwin]
help = "Build wheel with bundled library for MacOS x86_64 and arm64"
composite = [
"download_library -c -p darwin -a x86_64",
"pdm build --no-sdist",
"tag_wheel macosx-10.10-x86_64-macosx-11-universal2",
]

[tool.pdm.scripts.build_all]
help = "Build all the wheels with bundled library and the sdist and wheel without library"
composite = [
"build_linux_arm64",
"build_linux_x86_64",
"build_linux_win32_x86_64",
"build_linux_win32_i386",
"build_linux_darwin",
# remove any library before building sdist and barebone wheel
"clean_library",
"pdm build",
]


# https://mypy.readthedocs.io/en/stable/config_file.html
[tool.mypy]
Expand Down
4 changes: 1 addition & 3 deletions scripts/demo.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env python3
# ruff: noqa: T201
"""
a demo that shows how to call pymediainfo
"""
"""A demo that shows how to call pymediainfo."""

import sys
from pprint import pprint
Expand Down
Loading