go-org-py
This commit is contained in:
commit
48bddd4a93
9 changed files with 394 additions and 0 deletions
37
setup.py
Normal file
37
setup.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
from setuptools import setup
|
||||
from setuptools.command.build_py import build_py
|
||||
|
||||
ROOT = Path(__file__).resolve().parent
|
||||
PKG_DIR = ROOT / "go_org_py"
|
||||
BUILD_DIR = ROOT / "gopy_build"
|
||||
|
||||
|
||||
class GopyHook(build_py):
|
||||
def run(self):
|
||||
self._run_gopy()
|
||||
subprocess.run(["ls", "-la"], check=True)
|
||||
super().run()
|
||||
|
||||
def _run_gopy(self):
|
||||
BUILD_DIR.mkdir(exist_ok=True)
|
||||
env = os.environ.copy()
|
||||
env["CGO_CFLAGS"] = "-std=gnu11 -O2"
|
||||
|
||||
subprocess.check_call(
|
||||
["gopy", "build", "-output", str(BUILD_DIR), "-vm", "python3", "."],
|
||||
env=env,
|
||||
cwd=Path(__file__).resolve().parent,
|
||||
)
|
||||
|
||||
shutil.copy2(BUILD_DIR / "convert.py", PKG_DIR)
|
||||
shutil.copy2(BUILD_DIR / "go.py", PKG_DIR)
|
||||
for lib in BUILD_DIR.glob("*/go_*.so"):
|
||||
shutil.copy2(lib, PKG_DIR / lib.name)
|
||||
|
||||
|
||||
setup(cmdclass={"build_py": GopyHook}, include_package_data=True)
|
Loading…
Add table
Add a link
Reference in a new issue