diff --git a/.github/workflows/smoke-tests.yml b/.github/workflows/smoke-tests.yml index b1bb21f99..f70625152 100644 --- a/.github/workflows/smoke-tests.yml +++ b/.github/workflows/smoke-tests.yml @@ -40,7 +40,39 @@ on: required: true jobs: + build-c-client: + outputs: + c-client-sha: ${{ steps.get-c-client-sha.outputs.sha }} + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + sparse-checkout: | + aerospike-client-c + + - id: get-c-client-sha + run: echo sha=$(git rev-parse HEAD) >> $GITHUB_OUTPUT + working-directory: aerospike-client-c + + - uses: actions/cache@v5 + id: download-c-client + with: + key: c-client-${{ steps.get-c-client-sha.outputs.sha }} + path: ./libaerospike.a + lookup-only: true + + - name: Install C client build dependencies + if: ${{ steps.download-c-client.outputs.cache-hit != 'true' }} + run: | + sudo apt-get update && + sudo apt-get install -y libc6-dev libssl-dev autoconf automake libtool g++ zlib1g-dev ncurses-dev && + make build && + mv ./target/Linux-x86_64/lib/libaerospike.a .. + working-directory: aerospike-client-c + build: + needs: build-c-client runs-on: ubuntu-22.04 strategy: matrix: @@ -64,6 +96,12 @@ jobs: submodules: recursive fetch-depth: 0 + - uses: actions/cache/restore@v5 + with: + key: c-client-${{ needs.build-c-client.outputs.c-client-sha }} + path: ./libaerospike.a + fail-on-cache-miss: true + - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: python-version: ${{ matrix.py-version }} @@ -83,6 +121,7 @@ jobs: run: python3 -m build env: CFLAGS: '-Werror' + C_CLIENT_SHARED_PATH: ./libaerospike.a - run: echo WHEEL_GH_ARTIFACT_NAME=wheel-${{ matrix.py-version }} >> $GITHUB_ENV diff --git a/setup.py b/setup.py index 4298d9e30..9d6e75d92 100644 --- a/setup.py +++ b/setup.py @@ -29,6 +29,7 @@ import io import xml.etree.ElementTree as ET import glob +from pathlib import Path ################################################################################ # ENVIRONMENT VARIABLES @@ -64,6 +65,7 @@ ################################################################################ include_dirs = ['src/include'] + \ + [f'{AEROSPIKE_C_HOME}/src/include'] + \ [x for x in os.getenv('CPATH', '').split(':') if len(x) > 0] + \ ['/usr/local/opt/openssl/include'] + \ ['aerospike-client-c/modules/common/src/include'] @@ -177,11 +179,23 @@ '/usr/local/opt/openssl/include', ] + +C_CLIENT_SHARED_PATH = os.getenv("C_CLIENT_SHARED_PATH") + if not WINDOWS: - include_dirs.append(AEROSPIKE_C_TARGET + '/include') - extra_objects = extra_objects + [ - AEROSPIKE_C_TARGET + '/lib/libaerospike.a' - ] + if C_CLIENT_SHARED_PATH: + # In this case, no headers will be installed in target directory. + include_dirs.append(AEROSPIKE_C_HOME + '/src/include') + extra_objects.append(C_CLIENT_SHARED_PATH) + # The C client isn't included in the sdist, so we need to explicitly tell linker to find it + # outside of the isolated build environment created by pypa/build + dir_containing_c_client_static_lib = os.path.dirname(os.path.abspath(C_CLIENT_SHARED_PATH)) + library_dirs.append(dir_containing_c_client_static_lib) + else: + include_dirs.append(AEROSPIKE_C_TARGET + '/src/include') + extra_objects = extra_objects + [ + AEROSPIKE_C_TARGET + '/lib/libaerospike.a' + ] else: include_dirs.append(AEROSPIKE_C_TARGET + '/src/include') library_dirs.append(f"{AEROSPIKE_C_TARGET}/vs/packages/aerospike-client-c-dependencies.{c_client_dependencies_version}/build/native/lib/x64/Release") @@ -249,7 +263,8 @@ def compile(): print(cmd, library_dirs, libraries) call(cmd, cwd=CCLIENT_PATH) - self.execute(compile, [], 'Compiling core aerospike-client-c') + if not C_CLIENT_SHARED_PATH: + self.execute(compile, [], 'Compiling core aerospike-client-c') # run original c-extension build code build.run(self)