|
| 1 | +import sys |
1 | 2 | import platform
|
2 |
| -import struct |
| 3 | + |
3 | 4 |
|
4 | 5 | __version__ = "0.5.1"
|
5 | 6 |
|
6 | 7 |
|
7 | 8 | def get_platform():
|
8 |
| - bits = struct.calcsize("P") * 8 |
9 |
| - if platform.system().lower().startswith("linux"): |
10 |
| - architecture = platform.machine() |
11 |
| - if architecture == "aarch64": |
12 |
| - return "linuxaarch64" |
13 |
| - return "linux{}".format(bits) |
14 |
| - elif platform.system().lower().startswith("freebsd"): |
15 |
| - return "freebsd{}".format(bits) |
16 |
| - elif platform.system().lower().startswith("win"): |
17 |
| - return "win{}".format(bits) |
18 |
| - elif platform.system().lower().startswith("cygwin"): |
19 |
| - return "win{}".format(bits) |
20 |
| - elif platform.system().lower().startswith("darwin"): |
21 |
| - if platform.processor().lower().startswith("arm"): # Apple Silicon |
22 |
| - return "osx-arm{}".format(bits) |
23 |
| - else: |
24 |
| - return "osx-{}".format(bits) |
25 |
| - else: # pragma: no cover |
26 |
| - return None |
| 9 | + # get_os_string and get_arch are taken from wgpu-py |
| 10 | + return _get_os_string() + "-" + _get_arch() |
| 11 | + |
| 12 | + |
| 13 | +def _get_os_string(): |
| 14 | + if sys.platform.startswith("win"): |
| 15 | + return "windows" |
| 16 | + elif sys.platform.startswith("darwin"): |
| 17 | + return "macos" |
| 18 | + elif sys.platform.startswith("linux"): |
| 19 | + return "linux" |
| 20 | + else: |
| 21 | + return sys.platform |
| 22 | + |
| 23 | + |
| 24 | +def _get_arch(): |
| 25 | + # See e.g.: https://stackoverflow.com/questions/45124888 |
| 26 | + is_64_bit = sys.maxsize > 2**32 |
| 27 | + machine = platform.machine() |
| 28 | + |
| 29 | + if machine == "armv7l": |
| 30 | + # Raspberry pi |
| 31 | + detected_arch = "armv7" |
| 32 | + elif is_64_bit and machine.startswith(("arm", "aarch64")): |
| 33 | + # Includes MacOS M1, arm linux, ... |
| 34 | + detected_arch = "aarch64" |
| 35 | + elif is_64_bit: |
| 36 | + detected_arch = "x86_64" |
| 37 | + else: |
| 38 | + detected_arch = "i686" |
| 39 | + return detected_arch |
27 | 40 |
|
28 | 41 |
|
29 | 42 | # The Linux static builds (https://johnvansickle.com/ffmpeg/) are build
|
30 |
| -# for Linux kernels 2.6.32 and up (at the time of writing, ffmpeg v4.1). |
31 |
| -# This corresponds to CentOS 6. This means we should use manylinux2010 and not |
32 |
| -# manylinux1. |
33 |
| -# manylinux1: https://www.python.org/dev/peps/pep-0513 |
34 |
| -# manylinux2010: https://www.python.org/dev/peps/pep-0571 |
| 43 | +# for Linux kernels 3.2.0 and up (at the time of writing, ffmpeg v7.0.2). |
| 44 | +# This corresponds to Ubuntu 12.04 / Debian 7. I'm not entirely sure' |
| 45 | +# what manylinux matches that, but I think manylinux2014 should be safe. |
35 | 46 |
|
36 | 47 |
|
37 | 48 | # Platform string -> ffmpeg filename
|
38 | 49 | FNAME_PER_PLATFORM = {
|
39 |
| - "osx-arm64": "ffmpeg-osx-arm64-v7.0", # Apple Silicon |
40 |
| - "osx64": "ffmpeg-osx-x86-v7.0", # 10.9+ |
41 |
| - "win32": "ffmpeg-win32-v4.2.2.exe", # Windows 7+ |
42 |
| - "win64": "ffmpeg-win64-v4.2.2.exe", |
43 |
| - # "linux32": "ffmpeg-linux32-v4.2.2", |
44 |
| - "linux64": "ffmpeg-linux64-v4.2.2", # Kernel 3.2.0+ |
45 |
| - "linuxaarch64": "ffmpeg-linuxaarch64-v4.2.2", |
| 50 | + "macos-aarch64": "ffmpeg-macos-aarch64-v7.1", |
| 51 | + "macos-x86_64": "ffmpeg-macos-x86_64-v7.1", # 10.9+ |
| 52 | + "windows-x86_64": "ffmpeg-win-x86_64-v7.1.exe", |
| 53 | + "windows-i686": "ffmpeg-win32-v4.2.2.exe", # Windows 7+ |
| 54 | + "linux-aarch64": "ffmpeg-linux-aarch64-v7.0.2", # Kernel 3.2.0+ |
| 55 | + "linux-x86_64": "ffmpeg-linux-x86_64-v7.0.2", |
46 | 56 | }
|
47 | 57 |
|
48 | 58 | osxplats = "macosx_10_9_intel.macosx_10_9_x86_64"
|
49 | 59 | osxarmplats = "macosx_11_0_arm64"
|
50 | 60 |
|
51 | 61 | # Wheel tag -> platform string
|
52 | 62 | WHEEL_BUILDS = {
|
53 |
| - "py3-none-manylinux2010_x86_64": "linux64", |
54 |
| - "py3-none-manylinux2014_aarch64": "linuxaarch64", |
55 |
| - "py3-none-" + osxplats: "osx64", # Apple Intel |
56 |
| - "py3-none-" + osxarmplats: "osx-arm64", # Apple Silicon |
57 |
| - "py3-none-win32": "win32", |
58 |
| - "py3-none-win_amd64": "win64", |
| 63 | + "py3-none-manylinux2014_x86_64": "linux-x86_64", |
| 64 | + "py3-none-manylinux2014_aarch64": "linux-aarch64", |
| 65 | + "py3-none-" + osxplats: "macos-x86_64", |
| 66 | + "py3-none-" + osxarmplats: "macos-aarch64", |
| 67 | + "py3-none-win32": "windows-i686", |
| 68 | + "py3-none-win_amd64": "windows-x86_64", |
59 | 69 | }
|
0 commit comments