Skip to content

Commit 31a583c

Browse files
MementoRCofek
andauthored
FEAT: Transition to scikit-build-core CMake-based build process (#162)
Co-authored-by: Ofek Lev <[email protected]>
1 parent 07d332e commit 31a583c

36 files changed

+662
-1111
lines changed

Diff for: .github/workflows/build.yml

+8-34
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ concurrency:
1616

1717
env:
1818
COINCURVE_UPSTREAM_REF: 1ad5185cd42c0636104129fcc9f6a4bf9c67cc40
19-
COINCURVE_IGNORE_SYSTEM_LIB: '1'
20-
# Only 'SHARED' is recognized, any other string means 'not SHARED'
21-
COINCURVE_SECP256K1_BUILD: 'STATIC'
19+
COINCURVE_IGNORE_SYSTEM_LIB: 'ON'
20+
COINCURVE_SECP256K1_STATIC: 'ON'
21+
COINCURVE_CROSS_HOST: ''
2222
CIBW_ENVIRONMENT_PASS_LINUX: >
2323
COINCURVE_UPSTREAM_REF
2424
COINCURVE_IGNORE_SYSTEM_LIB
25-
COINCURVE_SECP256K1_BUILD
25+
COINCURVE_SECP256K1_STATIC
26+
COINCURVE_CROSS_HOST
2627
CIBW_PROJECT_REQUIRES_PYTHON: '>=3.8'
2728
CIBW_BEFORE_ALL_MACOS: ./.github/scripts/install-macos-build-deps.sh
2829
CIBW_TEST_REQUIRES: pytest pytest-benchmark
@@ -68,7 +69,7 @@ jobs:
6869
run: tox -e lint,typing
6970

7071
- name: Run tests
71-
run: tox -e ${PYTHON_VERSION}
72+
run: tox -e ${PYTHON_VERSION} -vvv
7273

7374
- name: Run benchmarks
7475
run: tox -e bench
@@ -149,40 +150,14 @@ jobs:
149150
uses: pypa/[email protected]
150151
env:
151152
CIBW_ARCHS_WINDOWS: 'AMD64'
152-
CIBW_BEFORE_ALL: choco install -y --no-progress --no-color cmake>=3.28 pkgconfiglite
153+
CIBW_BEFORE_ALL: choco install -y --no-progress --no-color cmake>=3.28
153154

154155
- uses: actions/upload-artifact@v4
155156
with:
156157
name: artifact-windows-wheels-x86_64
157158
path: wheelhouse/*.whl
158159
if-no-files-found: error
159160

160-
windows-wheels-x86:
161-
name: Build Windows wheels x86
162-
needs:
163-
- test
164-
runs-on: windows-latest
165-
166-
steps:
167-
- uses: actions/checkout@v4
168-
169-
- uses: actions/setup-python@v5
170-
with:
171-
python-version: '3.12'
172-
173-
- name: Build wheels
174-
uses: pypa/[email protected]
175-
env:
176-
COINCURVE_CROSS_HOST: 'x86'
177-
CIBW_ARCHS_WINDOWS: 'x86'
178-
CIBW_BEFORE_ALL: choco install -y --no-progress --no-color cmake>=3.28 pkgconfiglite
179-
180-
- uses: actions/upload-artifact@v4
181-
with:
182-
name: artifact-windows-wheels-x86
183-
path: wheelhouse/*.whl
184-
if-no-files-found: error
185-
186161
windows-wheels-arm:
187162
name: Build Windows wheels for ARM64
188163
needs:
@@ -197,7 +172,7 @@ jobs:
197172
env:
198173
COINCURVE_CROSS_HOST: 'arm64'
199174
CIBW_ARCHS_WINDOWS: 'ARM64'
200-
CIBW_BEFORE_ALL: choco install -y --no-progress --no-color cmake>=3.28 pkgconfiglite
175+
CIBW_BEFORE_ALL: choco install -y --no-progress --no-color cmake>=3.28
201176

202177
- uses: actions/upload-artifact@v4
203178
with:
@@ -262,7 +237,6 @@ jobs:
262237
- macos-wheels-x86_64
263238
- macos-wheels-arm
264239
- windows-wheels-x86_64
265-
- windows-wheels-x86
266240
- windows-wheels-arm
267241
- sdist
268242
- linux-wheels-arm

Diff for: .github/workflows/verify_conda_build.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ concurrency:
1616

1717
env:
1818
COINCURVE_UPSTREAM_REF: __no_upstream__
19-
COINCURVE_IGNORE_SYSTEM_LIB: '0'
20-
# conda-forge only has SHARED libsecp256k1
21-
COINCURVE_SECP256K1_BUILD: 'SHARED'
19+
COINCURVE_IGNORE_SYSTEM_LIB: 'OFF'
20+
COINCURVE_SECP256K1_STATIC: 'OFF'
21+
COINCURVE_CROSS_HOST: ''
2222
CIBW_ENVIRONMENT_PASS_LINUX: >
2323
COINCURVE_UPSTREAM_REF
2424
COINCURVE_IGNORE_SYSTEM_LIB
25-
COINCURVE_SECP256K1_BUILD
25+
COINCURVE_SECP256K1_STATIC
26+
COINCURVE_CROSS_HOST
2627
CIBW_PROJECT_REQUIRES_PYTHON: '>=3.8'
2728
CIBW_BEFORE_ALL_MACOS: ./.github/scripts/install-macos-build-deps.sh
2829
CIBW_TEST_REQUIRES: pytest pytest-benchmark
@@ -34,7 +35,6 @@ env:
3435
assert a.ecdh(b.public_key.format())==b.ecdh(a.public_key.format())
3536
" &&
3637
python -m pytest {project}
37-
CIBW_TEST_SKIP: "*-macosx_arm64"
3838
CIBW_SKIP: >
3939
pp*
4040
@@ -63,7 +63,7 @@ jobs:
6363
run: tox -e lint,typing
6464

6565
- name: Run tests
66-
run: LD_LIBRARY_PATH=$CONDA_PREFIX/lib tox -e ${PYTHON_VERSION}
66+
run: LD_LIBRARY_PATH=$CONDA_PREFIX/lib tox -e ${PYTHON_VERSION} -vvv
6767

6868
- name: Run benchmarks
6969
run: LD_LIBRARY_PATH=$CONDA_PREFIX/lib tox -e bench

Diff for: .gitignore

-5
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,3 @@
1010
/build
1111
/dist
1212
/site
13-
/wheelhouse
14-
/pip-wheel-metadata
15-
16-
/src/coincurve/_libsecp256k1.py
17-
/src/coincurve/libsecp256k1.dll

Diff for: CMakeLists.txt

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
cmake_minimum_required(VERSION 3.26)
2+
3+
project(${SKBUILD_PROJECT_NAME}
4+
VERSION ${SKBUILD_PROJECT_VERSION}
5+
LANGUAGES C
6+
)
7+
8+
# Path to custom CMake functions
9+
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
10+
11+
# Name of the vendored library CMake target
12+
include(SetDefaultVendoredLibrary)
13+
SetDefaultVendoredLibrary()
14+
15+
set(CFFI_INPUT_LIBRARY ${VENDORED_LIBRARY_CMAKE_TARGET})
16+
17+
# Set the output directories for the generated C code and headers
18+
set(CFFI_C_CODE_DIR ${PROJECT_BINARY_DIR}/_gen_c_file)
19+
set(CFFI_C_CODE "${CFFI_INPUT_LIBRARY}_cffi_bindings.c")
20+
set(CFFI_HEADERS_DIR ${PROJECT_BINARY_DIR}/_gen_cffi_headers)
21+
22+
# Shared object that wraps the CFFI binding of the vendored library
23+
set(CFFI_OUTPUT_LIBRARY "_${VENDORED_LIBRARY_PKG_CONFIG}")
24+
25+
# Setting python for the host system (before change in CMAKE_SYSTEM_PROCESSOR)
26+
find_package(Python 3 REQUIRED COMPONENTS Interpreter Development.Module Development.SABIModule)
27+
28+
include(SetCrossCompilerGithubActions)
29+
SetCrossCompilerGithubActions()
30+
31+
# Add the subdirectories. Append CONDA to the PKG_CONFIG_PATH
32+
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
33+
set(PKG_CONFIG_ARGN "--dont-define-prefix")
34+
endif()
35+
find_package(PkgConfig REQUIRED)
36+
37+
# Set VENDORED_AS_SYSTEM_LIB to true if the vendored library is installed as a system library
38+
include(SetSystemLibIfExists)
39+
SetSystemLibIfExists()
40+
41+
add_subdirectory(cm_vendored_library)
42+
add_subdirectory(cm_library_cffi_headers)
43+
add_subdirectory(cm_library_c_binding)
44+
add_subdirectory(cm_python_module)
45+
46+
# Configure installation of the shared library ${CFFI_OUTPUT_LIBRARY} in the package
47+
install(TARGETS ${CFFI_OUTPUT_LIBRARY} LIBRARY DESTINATION ${SKBUILD_PLATLIB_DIR}/${SKBUILD_PROJECT_NAME})

Diff for: MANIFEST.in

-5
This file was deleted.

Diff for: _cffi_build/secp256k1.h

-171
This file was deleted.

Diff for: _cffi_build/secp256k1_ecdh.h

-16
This file was deleted.

0 commit comments

Comments
 (0)