Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .github/workflows/python-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ jobs:

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.12.1
run: python3 -m pip install cibuildwheel==2.12.1

- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse wrappers/python
run: python3 -m cibuildwheel --output-dir wheelhouse wrappers/python
env:
CIBW_BUILD: cp39-* cp310-* cp311-*
CIBW_SKIP: "*musllinux*"
Expand All @@ -53,10 +55,12 @@ jobs:

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Build sdist
working-directory: wrappers/python
run: python setup.py sdist
run: python3 setup.py sdist

- uses: actions/upload-artifact@v3
with:
Expand Down
49 changes: 8 additions & 41 deletions wrappers/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.15)
project(ZXingPython)

set (pybind11_git_repo https://github.com/pybind/pybind11.git)
set (pybind11_git_rev v2.10.2)
set (pybind11_git_rev v2.10.4)

# check if we are called from the top-level ZXing project
get_directory_property(hasParent PARENT_DIRECTORY)
Expand All @@ -14,50 +14,17 @@ if (NOT hasParent)
option (BUILD_SHARED_LIBS "Link python module to shared lib" OFF)
option (BUILD_WRITERS "Build with writer support (encoders)" ON)
option (BUILD_READERS "Build with reader support (decoders)" ON)

# build the main library
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../../core)
# In development mode, when the whole zxing-cpp directory is checked out, build against head code.
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../core ZXing EXCLUDE_FROM_ALL)

include(${CMAKE_CURRENT_SOURCE_DIR}/../../zxing.cmake)
zxing_add_package(pybind11 pybind11 ${pybind11_git_repo} ${pybind11_git_rev})
set(BUILD_DEPENDENCIES "AUTO")
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/core)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/core ZXing EXCLUDE_FROM_ALL)
include(${CMAKE_CURRENT_SOURCE_DIR}/zxing.cmake)
else()
# we don't have access to the top-level cmake helpers -> simply fetch it unconditional
include(FetchContent)
FetchContent_Declare (pybind11
GIT_REPOSITORY ${pybind11_git_repo}
GIT_TAG ${pybind11_git_rev})
FetchContent_MakeAvailable (pybind11)

# Building from python source distribution (which does not include the whole repository but only python part)
# so we need to get c++ source git to build the python extension. The python distribution version (given in
# VERSION_INFO), matches the c++ version the distribution must build against ; hence the checkout of
# related tag.
find_package (Git REQUIRED)
execute_process(
COMMAND ${GIT_EXECUTABLE} ls-remote https://github.com/zxing-cpp/zxing-cpp.git tags/*
RESULT_VARIABLE RESULT
OUTPUT_VARIABLE OUTPUT)
string (FIND "${OUTPUT}" "refs/tags/v${VERSION_INFO}\n" FOUND_IDX)
if (FOUND_IDX LESS 0)
# Version not found in tags (suppose we are preparing future version), use master branch
FetchContent_Declare(zxing-cpp
GIT_REPOSITORY https://github.com/zxing-cpp/zxing-cpp.git)
else()
FetchContent_Declare(zxing-cpp
GIT_REPOSITORY https://github.com/zxing-cpp/zxing-cpp.git
GIT_TAG v${VERSION_INFO})
endif()
if(NOT zxing-cpp_POPULATED)
FetchContent_Populate(zxing-cpp)
add_subdirectory(${zxing-cpp_SOURCE_DIR}/core ZXing EXCLUDE_FROM_ALL)
endif()
message(FATAL_ERROR "Unable to locate zxing source code")
endif()
else()
zxing_add_package(pybind11 pybind11 ${pybind11_git_repo} ${pybind11_git_rev})
endif()

zxing_add_package(pybind11 pybind11 ${pybind11_git_repo} ${pybind11_git_rev})

# build the python module
pybind11_add_module(zxingcpp zxing.cpp)
target_link_libraries(zxingcpp PRIVATE ZXing::ZXing)
Expand Down
6 changes: 4 additions & 2 deletions wrappers/python/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
include CMakeLists.txt
include zxing.cpp
global-include CMakeLists.txt
include zxing.cpp
include zxing.cmake
graft core/
1 change: 1 addition & 0 deletions wrappers/python/core
3 changes: 2 additions & 1 deletion wrappers/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ requires = [
"setuptools>=42",
"setuptools_scm",
"wheel",
"cmake>=3.14",
"cmake>=3.15",
"pybind11[global]",
]
build-backend = "setuptools.build_meta"
1 change: 1 addition & 0 deletions wrappers/python/zxing.cmake