summaryrefslogtreecommitdiff
path: root/wrappers/python/setup.py
blob: d729da6ef054eb960a6e76add827080099d47cd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python3

import os
import pathlib
import shutil
import sys

from setuptools import setup
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel

# 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:
            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/")
        _bdist_wheel.run(self)
        os.remove(f"eduvpncommon/lib/{pathlib.Path(libpath[self.plat_name]).name}")


setup(
    name="eduvpncommon",
    version="0.1.0",
    packages=["eduvpncommon"],
    python_requires=">=3.6",
    package_data={"eduvpncommon": ["lib/*eduvpn_verify*"]},
    cmdclass={"bdist_wheel": bdist_wheel},
)