-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
63 lines (50 loc) · 1.82 KB
/
setup.py
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import platform
import subprocess
import setuptools
from setuptools.command.build_py import build_py
from setuptools.command.build_ext import build_ext
class PoseidonExtension(setuptools.Extension):
def __init__(self):
self.name = "poseidon"
setuptools.Extension.__init__(self, self.name, sources=[])
class BuildPy(build_py):
def run(self):
self.run_command("build_ext")
return super().run()
class BuildPoseidon(build_ext):
already_built = False
def build_extension(self, ext):
if self.already_built:
return
if platform.system() == "Windows":
self._build_extension_windows()
else:
self._build_extension_mac_linux()
self.already_built = True
def _build_extension_windows(self):
with subprocess.Popen(["powershell.exe", ".\\build.ps1"]) as process:
process.wait()
if process.returncode != 0:
raise Exception("Build returned a non-zero code")
def _build_extension_mac_linux(self):
subprocess.run("chmod a+x ./build.sh && ./build.sh", shell=True, check=True)
if __name__ == "__main__":
with open("README.rst", encoding="utf-8") as f:
long_description = f.read()
setuptools.setup(
name="poseidon_py",
version="0.1.5",
description="Python implementation of Poseidon hash",
long_description=long_description,
author="drknzz",
author_email="[email protected]",
url="https://github.com/drknzz/poseidon-py.git",
ext_modules=[PoseidonExtension()],
cmdclass={
"build_py": BuildPy,
"build_ext": BuildPoseidon,
},
python_requires=">=3.8",
packages=["poseidon_py"],
package_data={"poseidon_py": ["../lib_pos.*"]},
)