Skip to content

Commit 1336b7a

Browse files
authored
Merge pull request #4 from cropsinsilico/rename
Rename
2 parents 4dc838b + 5e06b40 commit 1336b7a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+485
-249
lines changed

.github/workflows/conda_recipe.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Test of conda recipe build
2+
'on':
3+
push:
4+
branches-ignore:
5+
- gh-pages
6+
tags:
7+
- '*'
8+
schedule:
9+
- cron: 0 10 * * 1
10+
jobs:
11+
build_conda_recipe:
12+
runs-on: ${{ matrix.os }}
13+
defaults:
14+
run:
15+
shell: bash -el {0}
16+
strategy:
17+
matrix:
18+
os: [ubuntu-latest, macos-latest, windows-latest]
19+
python-version: ["3.11"]
20+
builder: [conda, rattler]
21+
fail-fast: false
22+
steps:
23+
- name: Check out repository code
24+
uses: actions/checkout@v5
25+
with:
26+
submodules: true
27+
28+
###################################
29+
# CONDA SETUP
30+
###################################
31+
- name: Set up MSVC Compiler on windows
32+
uses: ilammy/msvc-dev-cmd@v1
33+
if: matrix.os == 'windows-latest'
34+
- name: Set up miniconda test environment
35+
uses: conda-incubator/setup-miniconda@v3
36+
with:
37+
activate-environment: ""
38+
auto-activate-base: true
39+
auto-update-conda: true
40+
channels: conda-forge
41+
channel-priority: strict
42+
miniforge-version: latest
43+
conda-remove-defaults: true
44+
- name: Install conda-build
45+
if: matrix.builder == 'conda'
46+
run: |
47+
conda info
48+
conda list
49+
conda install conda-build cmake numpy -y
50+
- name: Install rattler-build
51+
if: matrix.builder == 'rattler'
52+
run: |
53+
conda info
54+
conda list
55+
conda install rattler-build -y
56+
- name: Check conda installation
57+
run: |
58+
conda info
59+
conda list
60+
- name: Build conda recipe (using conda-build)
61+
if: matrix.builder == 'conda'
62+
run: |
63+
conda-build --no-anaconda-upload --output-folder $HOME/local_channel/ --python ${{ matrix.python-version }} recipe/
64+
- name: Build conda recipe (using rattler-build)
65+
if: matrix.builder == 'rattler'
66+
run: |
67+
rattler-build build --recipe "conda.recipe/recipe.yaml" --output-dir $HOME/local_channel/ --variant python=${{ matrix.python-version }}
68+
# - name: Build conda recipe (using rattler-build action)
69+
# uses: prefix-dev/rattler-build-action@v0.2.34
70+
# if: matrix.builder == 'rattler'
71+
# with:
72+
# upload-artifact: false
73+
# build-args: --output-dir $HOME/local_channel/ --variant python=${{ matrix.python-version }}

.github/workflows/main.yml

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ jobs:
123123
name: Set up QEMU
124124

125125
- name: Build wheels
126-
uses: pypa/cibuildwheel@v3.1.4
126+
uses: pypa/cibuildwheel@v3.2.0
127127
env:
128128
CIBW_ARCHS_LINUX: ${{ matrix.arch }}
129129
CIBW_ARCHS_MACOS: ${{ matrix.arch }}
@@ -143,26 +143,23 @@ jobs:
143143
name: wheels-for-${{ matrix.os }}-${{ matrix.arch }}
144144
path: ./wheelhouse/*.whl
145145

146-
# upload_wheels:
147-
# name: Upload wheels to PyPI
148-
# needs: build_wheels
149-
# runs-on: ubuntu-latest
146+
upload_wheels:
147+
name: Upload wheels to PyPI
148+
needs: build_wheels
149+
runs-on: ubuntu-latest
150+
environment: pypi
151+
permissions:
152+
id-token: write
150153

151154
# Upload to PyPI on every tag starting with 'v'
152-
# FIXME: for some reason, the job is skipped, although the configuration is
153-
# almost identical to the one I use on pglast... let's try to temporarily
154-
# remove the condition
155-
# langmm: Disabled until name change for fork
156-
## if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
157-
158-
# steps:
159-
# - uses: actions/download-artifact@v4
160-
# with:
161-
# path: dist
162-
# pattern: wheels-for-*
163-
# merge-multiple: true
164-
165-
# - uses: pypa/gh-action-pypi-publish@release/v1
166-
# with:
167-
# user: __token__
168-
# password: ${{ secrets.PYPI_API_TOKEN }}
155+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
156+
157+
steps:
158+
- uses: actions/download-artifact@v4
159+
with:
160+
path: dist
161+
pattern: wheels-for-*
162+
merge-multiple: true
163+
164+
- name: Publish package distributions to PyPI
165+
uses: pypa/gh-action-pypi-publish@release/v1

CMakeLists.txt

Lines changed: 56 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,48 @@
1-
cmake_minimum_required(VERSION 3.16)
2-
set(YGGDRASIL_REQUIRE_SKBUILD ON)
1+
cmake_minimum_required(VERSION 3.15)
2+
if(NOT PROJECT_NAME)
3+
if(NOT SKBUILD)
4+
message(FATAL_ERROR "Must be built via scikit-build-core")
5+
endif()
6+
PROJECT(${SKBUILD_PROJECT_NAME} VERSION "${SKBUILD_PROJECT_VERSION}")
7+
endif()
8+
9+
set(PYRJ_ALTERNATE_MODULE "yggdrasil_rapidjson" CACHE STRING "Name of the Python module that should be built")
10+
311
set(CMAKE_VERBOSE_MAKEFILE ON)
4-
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ygg_options.cmake)
512

6-
if (NOT DEFAULT_RAPIDJSON_INCLUDE_DIRS)
7-
cmake_path(APPEND CMAKE_CURRENT_SOURCE_DIR rapidjson include
8-
OUTPUT_VARIABLE DEFAULT_RAPIDJSON_INCLUDE_DIRS)
9-
endif()
13+
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ygg_options.cmake)
1014

1115
find_package(
1216
${PYTHON_PREFIX} COMPONENTS
13-
Interpreter Development.Module NumPy REQUIRED)
14-
if (${PYTHON_PREFIX}_VERSION VERSION_LESS "3.7.0")
15-
message(FATAL_ERROR "Only Python 3.7+ is supported.")
17+
Interpreter Development.Module NumPy REQUIRED
18+
)
19+
if (${PYTHON_PREFIX}_VERSION VERSION_LESS "3.9.0")
20+
message(FATAL_ERROR "Only Python 3.9+ is supported.")
1621
endif()
1722

23+
set(PYRJ_TARGET "yggdrasil_python_rapidjson")
1824
set(PYRJ_SRC "${CMAKE_CURRENT_SOURCE_DIR}/rapidjson.cpp")
1925

2026
if (PYRJ_ALTERNATE_MODULE)
27+
if (NOT PYRJ_LIBNAME)
28+
string(FIND ${PYRJ_ALTERNATE_MODULE} "." IDX_LIBNAME REVERSE)
29+
message(STATUS "IDX_LIBNAME = ${IDX_LIBNAME}")
30+
if(IDX_LIBNAME EQUAL -1)
31+
set(PYRJ_LIBNAME "${PYRJ_ALTERNATE_MODULE}")
32+
else()
33+
string(
34+
SUBSTRING ${PYRJ_ALTERNATE_MODULE} (IDX_LIBNAME + 1) -1
35+
PYRJ_LIBNAME
36+
)
37+
endif()
38+
endif()
2139
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/replace_module.cmake"
2240
[=[
2341
file(READ "${SOURCE}" TEXT)
2442
string(REPLACE "\"rapidjson\"" "\"${PYRJ_ALTERNATE_MODULE}\"" TEXT "${TEXT}")
2543
string(REPLACE "\"rapidjson." "\"${PYRJ_ALTERNATE_MODULE}." TEXT "${TEXT}")
44+
string(REPLACE ":rapidjson." ":${PYRJ_ALTERNATE_MODULE}." TEXT "${TEXT}")
45+
string(REPLACE "PyInit_rapidjson" "PyInit_${PYRJ_LIBNAME}" TEXT "${TEXT}")
2646
file(WRITE "${TARGET}" "${TEXT}")
2747
]=])
2848

@@ -42,46 +62,59 @@ if (PYRJ_ALTERNATE_MODULE)
4262
"-DSOURCE=${src}"
4363
"-DTARGET=${dst}"
4464
"-DPYRJ_ALTERNATE_MODULE=${PYRJ_ALTERNATE_MODULE}"
65+
"-DPYRJ_LIBNAME=${PYRJ_LIBNAME}"
4566
-P "${CMAKE_CURRENT_BINARY_DIR}/replace_module.cmake"
4667
DEPENDS "${src}" "${CMAKE_CURRENT_BINARY_DIR}/replace_module.cmake")
4768
endforeach()
4869
set(PYRJ_SRC "${CMAKE_CURRENT_BINARY_DIR}/rapidjson.cpp")
4970
add_custom_target(alt_rapidjson DEPENDS ${ALT_PYRJ_CPP})
5071
endif()
5172

73+
if (NOT PYRJ_LIBNAME)
74+
set(PYRJ_LIBNAME "rapidjson")
75+
endif()
76+
77+
message(STATUS "PYRJ_ALTERNATE_MODULE = ${PYRJ_ALTERNATE_MODULE}")
78+
message(STATUS "PYRJ_LIBNAME = ${PYRJ_LIBNAME}")
79+
message(STATUS "PYRJ_TARGET = ${PYRJ_TARGET}")
80+
5281
if (PYTHON_PREFIX STREQUAL "Python")
53-
Python_add_library(rapidjson MODULE ${PYRJ_SRC})
82+
Python_add_library(${PYRJ_TARGET} MODULE ${PYRJ_SRC})
5483
else()
55-
Python3_add_library(rapidjson MODULE ${PYRJ_SRC})
84+
Python3_add_library(${PYRJ_TARGET} MODULE ${PYRJ_SRC})
5685
endif()
86+
set_target_properties(
87+
${PYRJ_TARGET} PROPERTIES OUTPUT_NAME ${PYRJ_LIBNAME}
88+
)
5789

5890
if (PYRJ_ALTERNATE_MODULE)
59-
add_dependencies(rapidjson alt_rapidjson)
91+
add_dependencies(${PYRJ_TARGET} alt_rapidjson)
6092
target_include_directories(
61-
rapidjson PUBLIC
62-
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
93+
${PYRJ_TARGET} PUBLIC
94+
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
95+
)
6396
endif()
6497

65-
target_include_directories(rapidjson PUBLIC ${RAPIDJSON_INCLUDE_DIRS})
66-
target_link_libraries(rapidjson PUBLIC ${PYTHON_PREFIX}::NumPy)
98+
target_include_directories(${PYRJ_TARGET} PUBLIC ${RAPIDJSON_INCLUDE_DIRS})
99+
target_link_libraries(${PYRJ_TARGET} PUBLIC ${PYTHON_PREFIX}::NumPy)
67100

68101
target_compile_options(
69-
rapidjson PUBLIC
102+
${PYRJ_TARGET} PUBLIC
70103
-DRAPIDJSON_YGGDRASIL
71104
-DRAPIDJSON_YGGDRASIL_PYTHON
72105
-DRAPIDJSON_HAS_STDSTRING
73106
-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION
74107
-D_USE_MATH_DEFINES)
75108
if (RAPIDJSON_EXACT_VERSION)
76109
target_compile_options(
77-
rapidjson PUBLIC
110+
${PYRJ_TARGET} PUBLIC
78111
"-DRAPIDJSON_EXACT_VERSION=${RAPIDJSON_EXACT_VERSION}")
79112
endif()
80113
if (ASAN_COMPILE_FLAGS)
81-
target_compile_options(rapidjson PUBLIC ${ASAN_COMPILE_FLAGS})
114+
target_compile_options(${PYRJ_TARGET} PUBLIC ${ASAN_COMPILE_FLAGS})
82115
endif()
83116
if (ASAN_LINK_FLAGS)
84-
target_link_options(rapidjson PUBLIC ${ASAN_LINK_FLAGS})
117+
target_link_options(${PYRJ_TARGET} PUBLIC ${ASAN_LINK_FLAGS})
85118
endif()
86119

87120
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
@@ -114,14 +147,14 @@ if (EXISTS RAPIDJSON_EXACT_VERSION_FILE)
114147
file(READ ${RAPIDJSON_EXACT_VERSION_FILE} RAPIDJSON_EXACT_VERSION)
115148
string(STRIP ${RAPIDJSON_EXACT_VERSION} RAPIDJSON_EXACT_VERSION)
116149
target_compile_options(
117-
rapidjson PUBLIC
150+
${PYRJ_TARGET} PUBLIC
118151
"-DRAPIDJSON_EXACT_VERSION=${RAPIDJSON_EXACT_VERSION}")
119152
endif()
120153

121154
if (NOT ${PYTHON_PREFIX}_INSTALL_DIR)
122155
set(${PYTHON_PREFIX}_INSTALL_DIR ".")
123156
endif()
124157

125-
install(TARGETS rapidjson
158+
install(TARGETS ${PYRJ_TARGET}
126159
LIBRARY DESTINATION ${${PYTHON_PREFIX}_INSTALL_DIR}
127160
RUNTIME DESTINATION ${${PYTHON_PREFIX}_INSTALL_DIR})

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ help::
3333

3434
.PHONY: build
3535
build: virtualenv rapidjson_exact_version.txt
36-
$(PYTHON) setup.py build_ext --inplace
36+
$(PYTHON) -m pip install . -e
3737

3838
help::
3939
@printf "clean\n\tremove rebuildable stuff\n"

0 commit comments

Comments
 (0)