Skip to content

Commit 592cb11

Browse files
committed
CI fixes for whl
1 parent 6f74fe2 commit 592cb11

2 files changed

Lines changed: 26 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ jobs:
123123
CIBW_BEFORE_ALL_LINUX: |
124124
curl -sSL https://go.dev/dl/go${{ env.GO_VERSION }}.linux-amd64.tar.gz -o /tmp/go.tar.gz
125125
tar -C /opt -xzf /tmp/go.tar.gz
126-
CIBW_ENVIRONMENT_LINUX: PATH=/opt/go/bin:$PATH
126+
CIBW_ENVIRONMENT_LINUX: PATH=/opt/go/bin:$PATH CGO_ENABLED=1
127127
run: python -m cibuildwheel python --output-dir dist
128128

129129
- name: Upload wheel artifacts

python/setup.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929
def build_go_library():
3030
"""Build the Go shared library"""
3131
print("Building Go shared library...")
32-
32+
3333
# Change to the project root directory
3434
project_root = Path(__file__).parent.parent
3535
os.chdir(project_root)
36-
36+
3737
# Build the shared library
3838
output_path = f"python/spl_toolkit/libspl_toolkit{SHARED_EXT}"
3939
cmd = [
@@ -42,10 +42,18 @@ def build_go_library():
4242
"-o", output_path,
4343
"./pkg/bindings",
4444
]
45-
45+
46+
env = os.environ.copy()
47+
# Ensure CGO is enabled for c-shared builds
48+
env.setdefault("CGO_ENABLED", "1")
49+
4650
try:
47-
result = subprocess.run(cmd, check=True, capture_output=True, text=True)
48-
print("Go library built successfully")
51+
result = subprocess.run(cmd, check=True, capture_output=True, text=True, env=env)
52+
# Verify output file exists
53+
if not Path(output_path).exists():
54+
print(f"Go build reported success but output not found: {output_path}")
55+
return False
56+
print("Go library built successfully:", output_path)
4957
return True
5058
except subprocess.CalledProcessError as e:
5159
print(f"Failed to build Go library: {e}")
@@ -70,6 +78,16 @@ def run(self):
7078
print("You may need to build it manually with: go build -buildmode=c-shared -o python/spl_toolkit/libspl_toolkit.so ./pkg/bindings")
7179

7280
from wheel.bdist_wheel import bdist_wheel
81+
from setuptools.command.build_py import build_py as _build_py
82+
83+
class build_py_go(_build_py):
84+
def run(self):
85+
# Build the Go shared library before packaging Python modules
86+
require_build = os.environ.get("CIBUILDWHEEL") == "1" or os.environ.get("FORCE_BUILD_GO") == "1"
87+
success = build_go_library()
88+
if not success and require_build:
89+
raise RuntimeError("Failed to build Go shared library during wheel build. See logs above.")
90+
super().run()
7391

7492
class bdist_wheel_plat(bdist_wheel):
7593
def finalize_options(self):
@@ -128,7 +146,8 @@ def finalize_options(self):
128146
include_package_data=True,
129147
zip_safe=False, # Due to shared library
130148
cmdclass={
131-
# Mark wheel as non-pure so it gets a platform tag
149+
# Ensure Go library is built and mark wheel as non-pure
150+
"build_py": build_py_go,
132151
"bdist_wheel": bdist_wheel_plat,
133152
},
134153
keywords="splunk spl query parser field mapping analysis",

0 commit comments

Comments
 (0)