Skip to content

Commit

Permalink
Build GoReSym from source on wheel build #18
Browse files Browse the repository at this point in the history
    * Update Makefile to set proper build variables

Signed-off-by: Jono Yang <jyang@nexb.com>
  • Loading branch information
JonoYang committed Nov 3, 2024
1 parent d62b372 commit eac0a64
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 2 deletions.
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ PYTHON_EXE?=python3
VENV=venv
ACTIVATE?=. ${VENV}/bin/activate;

ARCH := $(shell uname -m)
ifeq ($(ARCH),aarch64)
PLAT_NAME := "manylinux2014_aarch64"
GOARCH := "arm64"
else
PLAT_NAME := "manylinux1_x86_64"
GOARCH := "amd64"
endif

dev:
@echo "-> Configure the development envt."
./configure --dev
Expand All @@ -35,7 +44,7 @@ check:
@echo "-> Run pycodestyle (PEP8) validation"
@${ACTIVATE} pycodestyle --max-line-length=100 --exclude=.eggs,venv,lib,thirdparty,docs,migrations,settings.py,.cache .
@echo "-> Run isort imports ordering validation"
@${ACTIVATE} isort --sl --check-only -l 100 setup.py src tests .
@${ACTIVATE} isort --sl --check-only -l 100 setup.py src tests .
@echo "-> Run black validation"
@${ACTIVATE} black --check --check -l 100 src tests setup.py

Expand All @@ -51,4 +60,9 @@ docs:
rm -rf docs/_build/
@${ACTIVATE} sphinx-build docs/ docs/_build/

build:
rm -f src/go_inspector/bin/GoReSym_lin
python setup.py clean --all sdist
GOOS=linux GOARCH=$(GOARCH) python setup.py clean --all bdist_wheel --python-tag py3 --plat-name $(PLAT_NAME)

.PHONY: conf dev check valid black isort clean test docs
25 changes: 25 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
#
# Copyright (c) nexB Inc. http://www.nexb.com/ - All rights reserved.
#

set -e

base_name=GoReSym-3.0.1

cd lib-src/

rm -rf $base_name
tar -xf $base_name.tar.gz

cd $base_name/


echo Build GoReSym
go build && mv GoReSym GoReSym_lin
strip GoReSym_lin
cp GoReSym_lin ../../src/go_inspector/bin/
cd ..
echo Done building GoReSym

rm -rf $base_name/
Binary file added lib-src/GoReSym-3.0.1.tar.gz
Binary file not shown.
27 changes: 26 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
#!/usr/bin/env python

import subprocess
from distutils.command.build import build as distutils_build
from distutils.errors import LibError

import setuptools
from setuptools.command.develop import develop as setuptools_develop


def run_native_build():
exitcode, output = subprocess.getstatusoutput(["./build.sh"])
print(output)
if exitcode:
raise LibError("Unable to build native")


class BuildNative(distutils_build):
def run(self):
self.execute(run_native_build, (), msg="Building native code")
distutils_build.run(self)


class DevelopNative(setuptools_develop):
def run(self):
self.execute(run_rpm_build, (), msg="Building develop native code")
setuptools_develop.run(self)


if __name__ == "__main__":
setuptools.setup()
setuptools.setup(cmdclass={"build": BuildNative, "develop": DevelopNative})

0 comments on commit eac0a64

Please sign in to comment.