Skip to content

Commit 8045e9b

Browse files
getzzesbraz
authored andcommitted
Switch to pyproject + pdm, add Python 3.13, drop 3.7 and 3.8
Build wheel with bundled libmediainfo for MacOS arm64 and for Linux (x86_64 and arm64). Instead of installing MediaInfo via apt to run tests, use the AWS Lambda library file that we bundle into Linux wheels, this simplifies the CI code. Fixes: #127 Fixes: #128 Fixes: #140
1 parent f692ad1 commit 8045e9b

File tree

8 files changed

+134
-129
lines changed

8 files changed

+134
-129
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
build
77
dist
88
docs/_build
9+
.pdm*

README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ pymediainfo
1919

2020
This small package is a wrapper around the MediaInfo library.
2121

22-
It works on Linux, Mac OS X and Windows and is tested with Python 3.7 to 3.12 and PyPy3.
22+
It works on Linux, Mac OS X and Windows and is tested with Python 3.9 to 3.13 and PyPy3.
2323

2424
See https://pymediainfo.readthedocs.io/ for more information.

appveyor.yml

+44-39
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
environment:
22
LINUX_IMAGE: &linux_image Ubuntu2204
3-
MACOS_IMAGE: &macos_image macos-catalina
3+
MACOS_IMAGE: &macos_image macos-monterey
44
WINDOWS_IMAGE: &windows_image Visual Studio 2022
5-
LIBZEN_VERSION: 0.4.41
65
MEDIAINFO_VERSION: 24.11
7-
UBUNTU_VERSION: 22.04
6+
# Python 3.13 is not available everywhere yet, see https://github.com/appveyor/ci/issues/3927
7+
# Because of this, we can only deploy on 3.12
88
QA_PYTHON_VERSION: 3.12
9-
# Python 3.12 is not available everywhere yet, see https://github.com/appveyor/ci/issues/3879
10-
# Because of this, we can only deploy on 3.11
11-
DEPLOY_TOXENV: py311
9+
DEPLOY_TOXENV: py312
1210
PYPY_URL: https://downloads.python.org/pypy/pypy3.10-v7.3.13-linux64.tar.bz2
1311
# Work around https://github.com/tox-dev/tox/issues/1550
1412
PYTHONIOENCODING: utf-8
@@ -20,10 +18,6 @@ environment:
2018
APPVEYOR_BUILD_WORKER_IMAGE: *linux_image
2119
- TOXENV: pypy3
2220
APPVEYOR_BUILD_WORKER_IMAGE: *linux_image
23-
- TOXENV: py37
24-
APPVEYOR_BUILD_WORKER_IMAGE: *linux_image
25-
- TOXENV: py38
26-
APPVEYOR_BUILD_WORKER_IMAGE: *linux_image
2721
- TOXENV: py39
2822
APPVEYOR_BUILD_WORKER_IMAGE: *linux_image
2923
- TOXENV: py310
@@ -32,26 +26,16 @@ environment:
3226
APPVEYOR_BUILD_WORKER_IMAGE: *linux_image
3327
- TOXENV: py312
3428
APPVEYOR_BUILD_WORKER_IMAGE: *linux_image
35-
- TOXENV: py38
36-
APPVEYOR_BUILD_WORKER_IMAGE: *macos_image
29+
- TOXENV: py313
30+
APPVEYOR_BUILD_WORKER_IMAGE: *linux_image
3731
- TOXENV: py39
3832
APPVEYOR_BUILD_WORKER_IMAGE: *macos_image
3933
- TOXENV: py310
4034
APPVEYOR_BUILD_WORKER_IMAGE: *macos_image
4135
- TOXENV: py311
4236
APPVEYOR_BUILD_WORKER_IMAGE: *macos_image
43-
- TOXENV: py37
44-
PYTHON: "C:/Python37"
45-
APPVEYOR_BUILD_WORKER_IMAGE: *windows_image
46-
- TOXENV: py37
47-
PYTHON: "C:/Python37-x64"
48-
APPVEYOR_BUILD_WORKER_IMAGE: *windows_image
49-
- TOXENV: py38
50-
PYTHON: "C:/Python38"
51-
APPVEYOR_BUILD_WORKER_IMAGE: *windows_image
52-
- TOXENV: py38
53-
PYTHON: "C:/Python38-x64"
54-
APPVEYOR_BUILD_WORKER_IMAGE: *windows_image
37+
- TOXENV: py312
38+
APPVEYOR_BUILD_WORKER_IMAGE: *macos_image
5539
- TOXENV: py39
5640
PYTHON: "C:/Python39"
5741
APPVEYOR_BUILD_WORKER_IMAGE: *windows_image
@@ -76,6 +60,12 @@ environment:
7660
- TOXENV: py312
7761
PYTHON: "C:/Python312-x64"
7862
APPVEYOR_BUILD_WORKER_IMAGE: *windows_image
63+
- TOXENV: py313
64+
PYTHON: "C:/Python313"
65+
APPVEYOR_BUILD_WORKER_IMAGE: *windows_image
66+
- TOXENV: py313
67+
PYTHON: "C:/Python313-x64"
68+
APPVEYOR_BUILD_WORKER_IMAGE: *windows_image
7969
for:
8070
-
8171
matrix:
@@ -85,6 +75,7 @@ for:
8575
- "SET PATH=%PYTHON%;%PYTHON%/Scripts;%PATH%"
8676
- "python --version"
8777
- "IF %PYTHON:~-4% == -x64 (SET ARCH=x64) ELSE (SET ARCH=i386)"
78+
- "IF %PYTHON:~-4% == -x64 (SET PLATFORM_WHEEL=win_amd64) ELSE (SET PLATFORM_WHEEL=win32)"
8879
- ps: "Start-FileDownload https://mediaarea.net/download/binary/mediainfo/${Env:MEDIAINFO_VERSION}/MediaInfo_CLI_${Env:MEDIAINFO_VERSION}_Windows_${Env:ARCH}.zip"
8980
- ps: "unzip -o MediaInfo_CLI_${Env:MEDIAINFO_VERSION}_Windows_${Env:ARCH}.zip LIBCURL.DLL"
9081
- ps: "Start-FileDownload https://mediaarea.net/download/binary/libmediainfo0/${Env:MEDIAINFO_VERSION}/MediaInfo_DLL_${Env:MEDIAINFO_VERSION}_Windows_${Env:ARCH}_WithoutInstaller.7z"
@@ -100,8 +91,9 @@ for:
10091
deploy_script:
10192
- ps: |
10293
If (($env:APPVEYOR_REPO_TAG -eq "true") -and ($env:TOXENV -eq $env:DEPLOY_TOXENV)) {
103-
pip install twine wheel
104-
python setup.py bdist_wheel
94+
pip install twine wheel pdm
95+
pdm build --no-sdist
96+
wheel tags --remove --platform-tag=${Env:PLATFORM_WHEEL} dist/*-py3-none-any.whl
10597
Invoke-Expression "twine upload --skip-existing dist/*.whl"
10698
}
10799
-
@@ -125,8 +117,9 @@ for:
125117
if [[ $APPVEYOR_REPO_TAG == "true" && $TOXENV == $DEPLOY_TOXENV ]]; then
126118
mv MediaInfoLib/libmediainfo.0.dylib pymediainfo
127119
mv MediaInfoLib/License.html docs
128-
pip install twine wheel
129-
python setup.py bdist_wheel
120+
pip install twine wheel pdm
121+
pdm build --no-sdist
122+
wheel tags --remove --platform-tag=macosx-10.10-x86_64-macosx-11-universal2 dist/*-py3-none-any.whl
130123
twine upload --skip-existing dist/*.whl
131124
fi
132125
-
@@ -151,28 +144,40 @@ for:
151144
fi
152145
# "python -m pip" will work with the unpacked PyPy too, "pip" won't
153146
python -m pip install tox
154-
pushd /tmp
155-
libzen_deb=libzen0v5_${LIBZEN_VERSION}-1_amd64.xUbuntu_${UBUNTU_VERSION}.deb
156-
mediainfo_deb=libmediainfo0v5_${MEDIAINFO_VERSION}-1_amd64.xUbuntu_${UBUNTU_VERSION}.deb
157-
curl -O "https://mediaarea.net/download/binary/libzen0/${LIBZEN_VERSION}/${libzen_deb}"
158-
curl -O "https://mediaarea.net/download/binary/libmediainfo0/${MEDIAINFO_VERSION}/${mediainfo_deb}"
159-
sudo apt-get -y install libmms0
160-
sudo dpkg -i "${libzen_deb}" "${mediainfo_deb}"
161-
popd
147+
curl -O https://mediaarea.net/download/binary/libmediainfo0/${MEDIAINFO_VERSION}/MediaInfo_DLL_${MEDIAINFO_VERSION}_Lambda_x86_64.zip
148+
unzip MediaInfo_DLL_${MEDIAINFO_VERSION}_Lambda_x86_64.zip -d x86_64
149+
curl -O https://mediaarea.net/download/binary/libmediainfo0/${MEDIAINFO_VERSION}/MediaInfo_DLL_${MEDIAINFO_VERSION}_Lambda_arm64.zip
150+
unzip MediaInfo_DLL_${MEDIAINFO_VERSION}_Lambda_arm64.zip -d arm64
162151
fi
163152
build: off
164153
test_script: |
165154
if [[ $TOXENV =~ doc.* ]]; then
166155
TOX_PARALLEL_NO_SPINNER=1 tox -p
167156
else
157+
# Use the previously downloaded library
158+
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:x86_64/lib/"
168159
# We want to see the progression of the tests so we can't run
169160
# tox environments in parallel
170161
tox
171162
fi
172163
deploy_script: |
173164
set -eo pipefail
174165
if [[ $APPVEYOR_REPO_TAG == "true" && $TOXENV == $DEPLOY_TOXENV ]]; then
175-
pip install twine
176-
python setup.py sdist
177-
twine upload --skip-existing dist/*.gz
166+
pip install twine wheel pdm
167+
# source distribution
168+
pdm build --no-wheel
169+
170+
# wheels
171+
mv x86_64/LICENSE docs
172+
# wheel x86_64
173+
cp x86_64/lib/libmediainfo.so.0 pymediainfo/libmediainfo.so.0
174+
pdm build --no-sdist
175+
wheel tags --remove --platform-tag=manylinux_2_34-x86_64 dist/*-py3-none-any.whl
176+
# wheel arm64
177+
mv -f arm64/lib/libmediainfo.so.0 pymediainfo/libmediainfo.so.0
178+
pdm build --no-sdist
179+
wheel tags --remove --platform-tag=manylinux_2_34-arm64 dist/*-py3-none-any.whl
180+
181+
# upload
182+
twine upload --skip-existing dist/*.gz dist/*.whl
178183
fi

pyproject.toml

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# https://packaging.python.org/en/latest/specifications/pyproject-toml/
2+
[build-system]
3+
requires = ["pdm-backend", "wheel>=0.42"]
4+
build-backend = "pdm.backend"
5+
6+
[project]
7+
name = "pymediainfo"
8+
description = "A Python wrapper for the mediainfo library."
9+
authors = [
10+
{name = "Louis Sautier", email = "sautier.louis@gmail.com"},
11+
]
12+
readme = "README.rst"
13+
license = {text = "MIT"}
14+
classifiers = [
15+
"Development Status :: 5 - Production/Stable",
16+
"License :: OSI Approved :: MIT License",
17+
"Operating System :: MacOS :: MacOS X",
18+
"Operating System :: Microsoft :: Windows",
19+
"Operating System :: POSIX :: Linux",
20+
"Programming Language :: Python :: 3 :: Only",
21+
"Programming Language :: Python :: 3.9",
22+
"Programming Language :: Python :: 3.10",
23+
"Programming Language :: Python :: 3.11",
24+
"Programming Language :: Python :: 3.12",
25+
"Programming Language :: Python :: 3.13",
26+
"Programming Language :: Python :: Implementation :: CPython",
27+
"Programming Language :: Python :: Implementation :: PyPy",
28+
]
29+
dynamic = ["version"]
30+
requires-python = ">=3.9"
31+
dependencies = [
32+
]
33+
34+
[project.optional-dependencies]
35+
tests = [
36+
"pytest>=6",
37+
"pytest-cov",
38+
"pytest-xdist",
39+
]
40+
docs = [
41+
"alabaster",
42+
"setuptools_scm",
43+
"sphinx",
44+
]
45+
dev = [
46+
"ipython",
47+
"mypy>=1.0",
48+
"black",
49+
"isort",
50+
"flake8",
51+
"pylint",
52+
]
53+
54+
[project.urls]
55+
Homepage = "https://github.com/sbraz/pymediainfo"
56+
Documentation = "https://pymediainfo.readthedocs.io/"
57+
Bugs = "https://github.com/sbraz/pymediainfo/issues"
58+
59+
60+
# https://pdm-project.org/latest/
61+
[tool.pdm.version]
62+
source = "scm"
63+
64+
[tool.pdm.build]
65+
source-includes = ["scripts/", "tests/"]
66+
67+
[tool.pdm.scripts.types]
68+
help = "Check type hints"
69+
cmd = "mypy --install-types --non-interactive --config-file=pyproject.toml {args:src tests}"
70+
71+
72+
# https://mypy.readthedocs.io/en/stable/config_file.html
73+
[tool.mypy]
74+
# global-only flags
75+
pretty = true
76+
show_error_codes = true
77+
78+
[[tool.mypy.overrides]]
79+
module = ["pymediainfo.*"]
80+
strict = true
81+
82+
83+
[tool.pytest.ini_options]
84+
addopts = "-vv -r a"

scripts/demo.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python3
2+
# ruff: noqa: T201
23
"""
34
a demo that shows how to call pymediainfo
45
"""

setup.cfg

-13
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,3 @@ all_files = 1
55

66
[upload_sphinx]
77
upload-dir = docs/_build/html
8-
9-
[metadata]
10-
long_description = file: README.rst
11-
long_description_content_type = text/x-rst; charset=UTF-8
12-
13-
[aliases]
14-
test = pytest
15-
16-
[tool:pytest]
17-
addopts = -vv -r a
18-
19-
[bdist_wheel]
20-
universal = 1

setup.py

-74
This file was deleted.

tox.ini

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[tox]
22
envlist =
3-
py37
4-
py38
53
py39
64
py310
75
py311
6+
py312
7+
py313
88
pypy3
99
black
1010
flake8
@@ -24,6 +24,7 @@ commands =
2424
deps =
2525
setuptools_scm
2626
sphinx
27+
alabaster
2728
commands = sphinx-build -d "{toxworkdir}/docs_doctree" docs "{toxworkdir}/docs_out" --color -W {posargs}
2829

2930
[testenv:black]

0 commit comments

Comments
 (0)