Skip to content
Open
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
69 changes: 69 additions & 0 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Build

on:
push:
branches:
- master
pull_request:

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-13, macos-14, macos-latest]

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Build wheels
uses: pypa/cibuildwheel@v2.21.1
env:
CIBW_ARCHS_LINUX: auto
CIBW_ARCHS_WINDOWS: all

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

make_sdist:
name: Make SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Build SDist
run: pipx run build --sdist

- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz

upload_all:
needs: [build_wheels, make_sdist]
environment: pypi
permissions:
id-token: write
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
with:
pattern: cibw-*
path: dist
merge-multiple: true

- uses: pypa/gh-action-pypi-publish@release/v1
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "tkdnd"]
path = tkdnd
url = https://github.com/petasis/tkdnd
87 changes: 87 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
cmake_minimum_required(VERSION 3.5)

# ===========================================================================
# Project Information
# ===========================================================================
project(
tkdnd
LANGUAGES C
VERSION 0.14)

# ===========================================================================
# Locate Tcl/Tk
# ===========================================================================
if(MSVC)
find_package(TCL QUIET)
if(NOT TCL_FOUND)
include(FetchContent)
FetchContent_Declare(
cpython-tcltk-win32
GIT_REPOSITORY https://github.com/python/cpython-bin-deps
GIT_TAG tcltk)
FetchContent_MakeAvailable(cpython-tcltk-win32)

if(cpython-tcltk-win32_POPULATED)
if(MSVC_C_ARCHITECTURE_ID STREQUAL "ARM64")
set(CMAKE_PREFIX_PATH
${CMAKE_PREFIX_PATH};${cpython-tcltk-win32_SOURCE_DIR}/arm64)
elseif(MSVC_C_ARCHITECTURE_ID STREQUAL "x64")
set(CMAKE_PREFIX_PATH
${CMAKE_PREFIX_PATH};${cpython-tcltk-win32_SOURCE_DIR}/amd64)
elseif(MSVC_C_ARCHITECTURE_ID STREQUAL "X86")
set(CMAKE_PREFIX_PATH
${CMAKE_PREFIX_PATH};${cpython-tcltk-win32_SOURCE_DIR}/win32)
else()
message(
WARNING
"No Tcl/Tk prebuilt binaries from CPython could be found for your platform (MSVC ${MSVC_C_ARCHITECTURE_ID})."
"If the build fails, Ensure a MSVC-built Tcl/Tk is available on CMAKE_PREFIX_PATH."
)
endif()
endif()
endif()
endif()

find_package(TCL REQUIRED)
find_package(TclStub REQUIRED)

# ===========================================================================
# Target: tkdnd shared library
# ===========================================================================
#configure_file(tkdnd/generic/tkImgSVG.c
# ${CMAKE_CURRENT_BINARY_DIR}/tkImgSVG.c)
#add_library(tkdnd SHARED ${CMAKE_CURRENT_BINARY_DIR}/tkdnd)

file(GLOB tkdnd_SRC
"tkdnd/*.h"
"tkdnd/*.cpp"
"tkdnd/*.c"
)

add_library(tkdnd SHARED ${tkdnd_SRC})

target_link_libraries(tkdnd PRIVATE ${TCL_STUB_LIBRARY})
target_link_libraries(tkdnd PRIVATE ${TK_STUB_LIBRARY})

target_compile_definitions(tkdnd PRIVATE -DUSE_TCL_STUBS)
target_compile_definitions(tkdnd PRIVATE -DUSE_TK_STUBS)
target_compile_definitions(tkdnd PRIVATE -DPACKAGE_NAME="${CMAKE_PROJECT_NAME}")
target_compile_definitions(tkdnd
PRIVATE -DPACKAGE_VERSION="${CMAKE_PROJECT_VERSION}")
target_include_directories(tkdnd PRIVATE ${TCL_INCLUDE_PATH})
target_include_directories(tkdnd PRIVATE ${TK_INCLUDE_PATH})

block()
set(PACKAGE_NAME ${CMAKE_PROJECT_NAME})
set(PACKAGE_VERSION ${CMAKE_PROJECT_VERSION})
set(PKG_LIB_FILE
${CMAKE_SHARED_LIBRARY_PREFIX}tkdnd${CMAKE_SHARED_LIBRARY_SUFFIX})
configure_file(tkdnd/pkgIndex.tcl.in pkgIndex.tcl @ONLY)
endblock()

if(WIN32)
install(TARGETS tkdnd RUNTIME DESTINATION tkdnd)
else()
install(TARGETS tkdnd LIBRARY DESTINATION tkdnd)
endif()
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgIndex.tcl DESTINATION tkdnd)
24 changes: 24 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[build-system]
requires = ["scikit-build-core"]
build-backend = "scikit_build_core.build"

[project]
name = "tkdnd"
version = "0.14.0"
description = "DnD support for Tkinter"
author = "The tkdnd authors"
url = "https://github.com/rdbende/tktkinterDnD"

[tool.cibuildwheel]
skip = ["cp36-*", "cp37-*", "cp38-*", "pp*"]

[tool.cibuildwheel.linux]
before-all = "yum install -y tcl-devel tk-devel"

[[tool.cibuildwheel.overrides]]
select = "*-musllinux*"
before-all = "apk add tcl-dev tk-dev"

[tool.cibuildwheel.macos]
# https://github.com/actions/runner-images/issues/9441#issuecomment-1976928303
before-all = "brew install tcl-tk"
1 change: 1 addition & 0 deletions tkdnd
Submodule tkdnd added at 61813a
Loading