Browse Source

build: update python package configure

master
Dnomd343 4 weeks ago
parent
commit
7dea98a702
  1. 54
      CMakeLists.txt
  2. 47
      src/core_ffi/python_ffi/packing/pyproject.toml
  3. 18
      src/core_ffi/python_ffi/packing/setup.py

54
CMakeLists.txt

@ -3,16 +3,26 @@ project(klotski)
# ------------------------------------------------------------------------------------ #
option(KLSK_ENABLE_LTO "Enable LTO optimisation of the project." OFF)
option(KLSK_SHARED_LIB "Build klotski core as a dynamic library." OFF)
option(KLSK_ENABLE_TESTING "Enable testing of the klotski project." ON)
option(KLSK_ENABLE_BENCHMARK "Enable benchmark of the klotski project." ON)
option(KLSK_ENABLE_LTO "Enable LTO optimisation of the project." ON)
#option(KLSK_SHARED_LIB "Build klotski core as a dynamic library." OFF)
option(KLSK_ENABLE_TESTING "Enable testing of the klotski project." OFF)
option(KLSK_ENABLE_BENCHMARK "Enable benchmark of the klotski project." OFF)
option(KLSK_C_FFI "" ON)
option(KLSK_PYTHON_FFI "" ON)
option(KLSK_RUST_FFI "" ON)
option(KLSK_C_FFI "" OFF)
option(KLSK_RUST_FFI "" OFF)
option(KLSK_PYTHON_FFI "" OFF)
# ------------------------------------------------------------------------------------ #
if (KLSK_DEV_MODE)
set(KLSK_C_FFI ON)
set(KLSK_RUST_FFI ON)
set(KLSK_PYTHON_FFI ON)
set(KLSK_ENABLE_LTO ON)
set(KLSK_ENABLE_TESTING ON)
set(KLSK_ENABLE_BENCHMARK ON)
endif()
# ------------------------------------------------------------------------------------------- #
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
@ -20,17 +30,19 @@ endif()
add_compile_options(-Wall -Wextra -g)
# TODO: enabled by LTO option
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_compile_options(-flto=full)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
add_compile_options(-flto=full)
else ()
#add_compile_options(-flto) # TODO: only for g++
endif ()
# TODO: for python-ffi
if (SKBUILD)
if (KLSK_ENABLE_LTO)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
message(STATUS "klotski enable LTO for clang")
add_compile_options(-flto=full)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# add_compile_options(-flto=auto)
else()
message(FATAL_ERROR "unsupported compiler") # TODO: add MSVC support
endif()
endif()
# TODO: add `KLSK_ENABLE_PIC` option
if (SKBUILD) # for python-ffi
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
@ -38,7 +50,7 @@ get_filename_component(KLSK_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR} ABSOLUTE)
include(third_party/ThirdParty.cmake)
# ------------------------------------------------------------------------------------ #
# ------------------------------------------------------------------------------------------- #
#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
@ -51,4 +63,4 @@ include(third_party/ThirdParty.cmake)
add_subdirectory(src)
# ------------------------------------------------------------------------------------ #
# ------------------------------------------------------------------------------------------- #

47
src/core_ffi/python_ffi/packing/pyproject.toml

@ -6,3 +6,50 @@ requires = [
"ninja",
]
build-backend = "setuptools.build_meta"
[project]
name = "py-klotski"
version = "0.0.2"
requires-python = ">=3.7"
description = "Klotski multifunctional engine with high performance"
readme = "README.md"
license = {text = "BSD-3-Clause"}
authors = [{name = "Dnomd343", email = "dnomd343@gmail.com"}]
maintainers = [
{name = "Dnomd343", email = "dnomd343@gmail.com"}
]
classifiers = [
"Development Status :: 2 - Pre-Alpha",
"License :: OSI Approved :: BSD License",
"Topic :: Games/Entertainment",
"Topic :: Software Development",
"Topic :: Scientific/Engineering",
"Intended Audience :: Education",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
# TODO: add Windows support
"Operating System :: MacOS",
"Operating System :: POSIX",
"Programming Language :: C++",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3 :: Only",
]
[project.urls]
# TODO: add `Homepage` and `Documentation`
Source = "https://github.com/dnomd343/klotski.git"
Tracker = "https://github.com/dnomd343/klotski/issues"
Changelog = "https://github.com/dnomd343/klotski/blob/master/CHANGELOG.md"

18
src/core_ffi/python_ffi/packing/setup.py

@ -1,22 +1,14 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from skbuild import setup
setup(
name='py-klotski',
version='0.0.1',
description='Klotski multifunctional engine with high performance',
author='Dnomd343',
author_email='dnomd343@gmail.com',
license='BSD-3-Clause',
url='https://github.com/dnomd343/klotski',
packages=['klotski'],
package_dir={'': 'src'},
cmake_install_dir='src/klotski',
cmake_args=[
'-DKLSK_ENABLE_TESTING:BOOL=OFF',
'-DKLSK_ENABLE_BENCHMARK:BOOL=OFF',
'-DKLSK_C_FFI:BOOL=OFF',
'-DKLSK_RUST_FFI:BOOL=OFF',
'-DKLSK_ENABLE_LTO:BOOL=ON',
'-DKLSK_PYTHON_FFI:BOOL=ON',
],
python_requires=">=3.7",
]
)

Loading…
Cancel
Save