Skip to content

Commit 73c3bc9

Browse files
committed
One version source
1 parent 02f8a96 commit 73c3bc9

4 files changed

Lines changed: 15 additions & 4 deletions

File tree

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
cmake_minimum_required(VERSION 3.15)
22

3-
project(differintC VERSION 0.0.2.3 LANGUAGES CXX)
3+
file(READ "${PROJECT_VERSION_FILE}" VERSION_CONTENTS)
4+
string(REGEX MATCH "__version__ *= *[\"']([^\"']+)[\"']" _ ${VERSION_CONTENTS})
5+
set(PYTHON_VERSION_STRING "${CMAKE_MATCH_1}")
6+
project(differintC VERSION ${PYTHON_VERSION_STRING} LANGUAGES CXX)
47

58
# Set compiler optimization flags
69
if(MSVC)

differintC/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,4 @@ def _load_dll():
7777
from ._differintC import * # type: ignore # Directly import from site-packages
7878

7979
# Add version attribute
80-
__version__ = "0.0.2.3"
80+
from ._version import __version__

differintC/_version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "0.0.2.3" # <-- ANY PEP 440 version string allowed

pyproject.toml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ build-backend = "scikit_build_core.build"
1010

1111
[project]
1212
name = "differintC"
13-
version = "0.0.2.3"
13+
dynamic = ["version"]
1414
description = "Fast C++ implementation of fractional calculus operators via pybind11"
1515
authors = [{ name = "Parsa Roshanak" }]
1616
license = { text = "GPL-3.0-or-later" } # Changed to GPL for compatibility with fftw
@@ -37,6 +37,12 @@ Homepage = "https://github.com/iparsw/differintC"
3737
Repository = "https://github.com/iparsw/differintC"
3838
Issues = "https://github.com/iparsw/differintC/issues"
3939

40+
[tool.scikit-build.metadata.version]
41+
provider = "scikit_build_core.metadata.regex"
42+
input = "differintC/_version.py"
43+
regex = "^__version__\\s*=\\s*['\"](?P<value>[^'\"]+)['\"]"
44+
45+
4046
[tool.scikit-build]
4147
wheel.packages = ["differintC"]
4248
build-dir = "build"
@@ -79,6 +85,7 @@ exclude = [
7985
[tool.scikit-build.cmake]
8086
args = [
8187
"-DFFTW_ROOT=thirdparty/fftw",
82-
"-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL"
88+
"-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL",
89+
"-DPROJECT_VERSION_FILE=differintC/_version.py",
8390
]
8491

0 commit comments

Comments
 (0)