Skip to content

Commit

Permalink
Setup dynamic generation of Python version file from pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
althonos committed Sep 3, 2024
1 parent b41d3b3 commit 97b1535
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 14 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ jobs:
env:
CIBW_ARCHS: aarch64
CIBW_BUILD: ${{ matrix.python-tag }}
CIBW_BEFORE_BUILD: pip install cython
CIBW_BUILD_VERBOSITY: 2
CIBW_TEST_COMMAND: python -m unittest pyrodigal.tests -vv
CIBW_TEST_REQUIRES: importlib-resources
Expand Down Expand Up @@ -75,7 +74,6 @@ jobs:
env:
CIBW_ARCHS: x86_64
CIBW_BUILD: ${{ matrix.python-tag }}
CIBW_BEFORE_BUILD: pip install cython
CIBW_BUILD_VERBOSITY: 2
CIBW_TEST_COMMAND: python -m unittest pyrodigal.tests -vv
CIBW_TEST_REQUIRES: importlib-resources
Expand Down Expand Up @@ -112,7 +110,6 @@ jobs:
env:
CIBW_ARCHS: x86_64
CIBW_BUILD: ${{ matrix.python-tag }}
CIBW_BEFORE_BUILD: pip install cython
CIBW_BUILD_VERBOSITY: 2
CIBW_TEST_COMMAND: python -m unittest pyrodigal.tests -vv
CIBW_TEST_REQUIRES: importlib-resources
Expand Down Expand Up @@ -143,7 +140,6 @@ jobs:
env:
CIBW_ARCHS: arm64
CIBW_BUILD: ${{ matrix.python-tag }}
CIBW_BEFORE_BUILD: pip install cython
CIBW_BUILD_VERBOSITY: 2
CIBW_TEST_COMMAND: python -m unittest pyrodigal.tests -vv
CIBW_TEST_REQUIRES: importlib-resources
Expand Down Expand Up @@ -181,7 +177,6 @@ jobs:
env:
CIBW_ARCHS: AMD64
CIBW_BUILD: ${{ matrix.python-tag }}
CIBW_BEFORE_BUILD: pip install cython
CIBW_BUILD_VERBOSITY: 2
CIBW_TEST_COMMAND: python -m unittest pyrodigal.tests -vv
CIBW_TEST_REQUIRES: importlib-resources
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ backup
src/pyrodigal/lib.c
src/pyrodigal/lib.h
src/pyrodigal/*.html
src/pyrodigal/_version.py

### Cython ###

Expand Down
9 changes: 1 addition & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
cmake_minimum_required(VERSION 3.20)

if(DEFINED SKBUILD_PROJECT_NAME)
project(${SKBUILD_PROJECT_NAME} VERSION ${SKBUILD_PROJECT_VERSION})
else()
project(pyncbitk)
endif()

enable_language(C)
project(${SKBUILD_PROJECT_NAME} VERSION ${SKBUILD_PROJECT_VERSION} LANGUAGES C)

set(BUILD_SHARED_LIBS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ build-dir = "build/{build_type}"
editable.rebuild = true
editable.verbose = false

[[tool.scikit-build.generate]]
path = "src/pyrodigal/_version.py"
template = '__version__ = ${version}'
location = 'source'

[[tool.scikit-build.overrides]]
if.state = "editable"
cmake.build-type = "Debug"
Expand Down
1 change: 0 additions & 1 deletion src/pyrodigal/_version.py

This file was deleted.

2 changes: 2 additions & 0 deletions src/pyrodigal/lib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ except ImportError:

# --- Globals ----------------------------------------------------------------

__version__: str

_TARGET_CPU: str
_AVX512_RUNTIME_SUPPORT: bool
_AVX2_RUNTIME_SUPPORT: bool
Expand Down
1 change: 1 addition & 0 deletions src/scripts/cmake/CythonExtension.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ set(CYTHON_DIRECTIVES
-E TARGET_CPU=${CMAKE_SYSTEM_PROCESSOR}
-E TARGET_SYSTEM="linux"
-E PYPY=$<IF:$<STREQUAL:${Python_INTERPRETER_ID},PyPy>,True,False>
-E PROJECT_VERSION=${CMAKE_PROJECT_VERSION}
)

if(${CMAKE_BUILD_TYPE} STREQUAL Debug)
Expand Down

0 comments on commit 97b1535

Please sign in to comment.