summaryrefslogtreecommitdiff
path: root/wrappers/python
diff options
context:
space:
mode:
Diffstat (limited to 'wrappers/python')
-rw-r--r--wrappers/python/eduvpncommon/discovery.py2
-rwxr-xr-xwrappers/python/setup.py64
2 files changed, 48 insertions, 18 deletions
diff --git a/wrappers/python/eduvpncommon/discovery.py b/wrappers/python/eduvpncommon/discovery.py
index ae5e2fe..f7a312e 100644
--- a/wrappers/python/eduvpncommon/discovery.py
+++ b/wrappers/python/eduvpncommon/discovery.py
@@ -63,7 +63,7 @@ class VerifyError(Exception):
def verify(signature: bytes, signed_json: bytes, expected_file_name: str, min_sign_time: int) -> None:
"""
Verifies the signature on the JSON server_list.json/organization_list.json file.
- If the function returns the signature is valid for the given file type.
+ If the function returns, the signature is valid for the given file type.
:param signature: .minisig signature file contents.
:param signed_json: Signed .json file contents.
diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py
index d729da6..db254aa 100755
--- a/wrappers/python/setup.py
+++ b/wrappers/python/setup.py
@@ -3,39 +3,69 @@
import os
import pathlib
import shutil
-import sys
+import typing
+from collections import defaultdict
+import sys
from setuptools import setup
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel
+
+def getlibpath(plat_name: str) -> typing.Union[str, None]:
+ _plat_map = defaultdict(lambda: plat_name, {
+ "win32": "win-x86",
+ })
+
+ plat_split = _plat_map[plat_name].split("-", 1)
+ if len(plat_split) != 2:
+ return None
+ plat_os, plat_arch = plat_split
+
+ _os_map = defaultdict(lambda: plat_os, {
+ "win": "windows",
+ })
+ _lib_prefixes = defaultdict(lambda: "lib", {
+ "windows": "",
+ })
+ _lib_suffixes = defaultdict(lambda: ".so", {
+ "windows": ".dll",
+ "darwin": ".dylib",
+ })
+ _arch_map = defaultdict(lambda: plat_arch, {
+ "aarch64_be": "arm64",
+ "aarch64": "arm64",
+ "armv8b": "arm64",
+ "armv8l": "arm64",
+ "x86": "386",
+ "x86pc": "386",
+ "i86pc": "386",
+ "i386": "386",
+ "i686": "386",
+ "x86_64": "amd64",
+ "i686-64": "amd64",
+ })
+
+ processed_os = _os_map[plat_os]
+ return f"{processed_os}/{_arch_map[plat_arch]}/" \
+ f"{_lib_prefixes[processed_os]}eduvpn_verify{_lib_suffixes[processed_os]}"
+
+
# You would say there would be a better way to do all of this, but I couldn't find it
class bdist_wheel(_bdist_wheel):
def run(self):
self.plat_name_supplied = True # Force use platform
- libpath = {
- # TODO arm may be incorrect; also add more
- "win-amd64": "windows/amd64/eduvpn_verify.dll",
- "win32": "windows/386/eduvpn_verify.dll",
- "win-arm32": "windows/arm/eduvpn_verify.dll",
- "win-arm64": "windows/arm64/eduvpn_verify.dll",
- "linux-x86_64": "linux/amd64/libeduvpn_verify.so",
- "linux-i386": "linux/386/libeduvpn_verify.so",
- "linux-i686": "linux/386/libeduvpn_verify.so",
- "linux-arm": "linux/arm/libeduvpn_verify.so",
- "linux-aarch64": "linux/arm64/libeduvpn_verify.so",
- }
-
- if self.plat_name not in libpath:
+ libpath = getlibpath(self.plat_name)
+ if not libpath:
print(f"Unknown platform: {self.plat_name}")
sys.exit(1)
print(f"Building wheel for platform {self.plat_name}")
- shutil.copy2(f"../../exports/{libpath[self.plat_name]}", "eduvpncommon/lib/")
+ shutil.copy2(f"../../exports/{libpath}", "eduvpncommon/lib/")
_bdist_wheel.run(self)
- os.remove(f"eduvpncommon/lib/{pathlib.Path(libpath[self.plat_name]).name}")
+ os.remove(f"eduvpncommon/lib/{pathlib.Path(libpath).name}")
setup(