summaryrefslogtreecommitdiff
path: root/wrappers/python/setup.py
diff options
context:
space:
mode:
authorStevenWdV <stevenwdv@gmail.com>2022-01-24 14:59:25 +0100
committerStevenWdV <stevenwdv@gmail.com>2022-01-24 16:24:57 +0100
commite544c6fa9e15e7277da79e2464243e90b2706b8c (patch)
treede6613747e0e34a799089d4677f9833a85748712 /wrappers/python/setup.py
parentaab2e4b966c82b67eb0e204060e5ea6cd4ea15cf (diff)
Cleanup
Added variables to Makefiles to specify custom exports/ directory; Split exception classes in Java & C#; Added more comments; Renamed library and Go package; Removed real (pure) tests; Added generate_lib.ps1 to generate import .lib for Windows (Swift); Moved built Go libraries to exports/lib/; Switch to hopefully faster Swift GitHub Action.
Diffstat (limited to 'wrappers/python/setup.py')
-rwxr-xr-xwrappers/python/setup.py25
1 files changed, 19 insertions, 6 deletions
diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py
index db254aa..9e7bde4 100755
--- a/wrappers/python/setup.py
+++ b/wrappers/python/setup.py
@@ -1,17 +1,20 @@
#!/usr/bin/env python3
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
+_libname = "eduvpn_common"
+
def getlibpath(plat_name: str) -> typing.Union[str, None]:
+ """Get library path for plat_name relative to exports/lib/ folder."""
+
_plat_map = defaultdict(lambda: plat_name, {
"win32": "win-x86",
})
@@ -47,12 +50,21 @@ def getlibpath(plat_name: str) -> typing.Union[str, None]:
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]}"
+ f"{_lib_prefixes[processed_os]}{_libname}{_lib_suffixes[processed_os]}"
+# Adapted from https://stackoverflow.com/a/51794740
# 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):
+ user_options = _bdist_wheel.user_options + [
+ ("exports-lib-path=", None, "path to exports/lib directory"),
+ ]
+
+ def initialize_options(self):
+ super().initialize_options()
+ self.exports_lib_path = "../../exports/lib" # default
+
def run(self):
self.plat_name_supplied = True # Force use platform
@@ -63,9 +75,10 @@ class bdist_wheel(_bdist_wheel):
print(f"Building wheel for platform {self.plat_name}")
- shutil.copy2(f"../../exports/{libpath}", "eduvpncommon/lib/")
+ # setuptools will only use paths inside the package for package_data, so we copy the library
+ tmp_lib = shutil.copy2(f"{self.exports_lib_path}/{libpath}", "eduvpncommon/lib/")
_bdist_wheel.run(self)
- os.remove(f"eduvpncommon/lib/{pathlib.Path(libpath).name}")
+ os.remove(tmp_lib)
setup(
@@ -73,6 +86,6 @@ setup(
version="0.1.0",
packages=["eduvpncommon"],
python_requires=">=3.6",
- package_data={"eduvpncommon": ["lib/*eduvpn_verify*"]},
+ package_data={"eduvpncommon": [f"lib/*{_libname}*"]},
cmdclass={"bdist_wheel": bdist_wheel},
)