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
4 changes: 2 additions & 2 deletions .github/actions/build-gk/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ runs:
id: restore_gk_pkg
uses: actions/cache/restore@v4
with:
key: gk-tarballs-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.github/workflows/run-tests.yaml', '.github/actions/**', 'conda-recipe/**', 'src/**', 'genome_kit/**', 'setup.py', 'setup/**', 'tests/**') }}
key: gk-tarballs-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.github/workflows/run-tests.yaml', '.github/actions/**', 'conda-recipe/**', 'CMakeLists.txt', 'pyproject.toml', 'src/**', 'genome_kit/**', 'tests/**') }}
path: |
~/conda-bld

Expand Down Expand Up @@ -101,6 +101,6 @@ runs:
id: save_gk_pkg
uses: actions/cache/save@v4
with:
key: gk-tarballs-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.github/workflows/run-tests.yaml', '.github/actions/**', 'conda-recipe/**', 'src/**', 'genome_kit/**', 'setup.py', 'setup/**', 'tests/**') }}
key: gk-tarballs-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.github/workflows/run-tests.yaml', '.github/actions/**', 'conda-recipe/**', 'CMakeLists.txt', 'pyproject.toml', 'src/**', 'genome_kit/**', 'tests/**') }}
path: |
~/conda-bld
56 changes: 55 additions & 1 deletion .github/actions/curl-meta-yaml/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ runs:
curl -s -L -o conda-recipe/meta.yaml https://raw.githubusercontent.com/conda-forge/genomekit-feedstock/main/recipe/meta.yaml
fi

export GK_VERSION=$(grep "version = " setup.py | awk -F'"' '{print $2}')
export GK_VERSION=$(grep -E "^version = " pyproject.toml | head -1 | awk -F'"' '{print $2}')

export OS_TYPE=$(uname)
if [[ "$OS_TYPE" == "Darwin" ]]; then
Expand All @@ -38,5 +38,59 @@ runs:
# set the version to the local release-please version (for docs and docker publish)
$SED_CMD "s/{% set version = \"[^\"]*\" %}/{% set version = \"${GK_VERSION}\" %}/" conda-recipe/meta.yaml

python3 - <<'PY'
from pathlib import Path

meta = Path("conda-recipe/meta.yaml")
text = meta.read_text()
pip_install = "{{ PYTHON }} -m pip install --no-deps --ignore-installed ."
pip_install_no_isolation = "{{ PYTHON }} -m pip install --no-deps --ignore-installed --no-build-isolation ."
if pip_install in text:
text = text.replace(pip_install, pip_install_no_isolation)
elif pip_install_no_isolation not in text:
raise SystemExit("Unable to find GenomeKit pip install command in conda-recipe/meta.yaml")

def add_requirement(text, section, requirement):
lines = text.splitlines()
section_start = None
section_end = None

in_requirements = False
for i, line in enumerate(lines):
if line == "requirements:":
in_requirements = True
continue
if not in_requirements:
continue
if line and not line.startswith(" "):
break
if line == f" {section}:":
section_start = i
for j in range(i + 1, len(lines)):
next_line = lines[j]
if next_line.startswith(" ") and not next_line.startswith(" "):
section_end = j
break
if next_line and not next_line.startswith(" "):
section_end = j
break
else:
section_end = len(lines)
break

if section_start is None or section_end is None:
raise SystemExit(f"Unable to find requirements.{section} in conda-recipe/meta.yaml")
if any(line.strip() == f"- {requirement}" for line in lines[section_start + 1:section_end]):
return text

lines.insert(section_end, f" - {requirement}")
return "\n".join(lines) + ("\n" if text.endswith("\n") else "")

text = add_requirement(text, "build", "cmake")
text = add_requirement(text, "build", "ninja")
text = add_requirement(text, "host", "scikit-build-core")
meta.write_text(text)
PY

head -10 conda-recipe/meta.yaml
set +x
23 changes: 12 additions & 11 deletions .github/workflows/build-wheels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ jobs:
id: restore_linux_wheels
uses: actions/cache/restore@v4
with:
key: linux-wheels-${{ matrix.arch }}-${{ hashFiles('.github/workflows/build-wheels.yaml', '.github/actions/**', 'src/**', 'genome_kit/**', 'pyproject.toml', 'setup.py', 'setup/**') }}
# setup.py/setup/ were removed; wheel build config now lives in pyproject.toml and CMakeLists.txt.
key: linux-wheels-${{ matrix.arch }}-${{ hashFiles('.github/workflows/build-wheels.yaml', '.github/actions/**', 'CMakeLists.txt', 'pyproject.toml', 'src/**', 'genome_kit/**') }}
path: wheelhouse/*.whl

# skip remaining steps on cache hit
Expand Down Expand Up @@ -77,7 +78,7 @@ jobs:
name: cache linux wheels
uses: actions/cache/save@v4
with:
# hashFiles() would produce a different key due to setup/*.pyc files created
# Reuse the restore primary key so saved wheels match the restore key.
key: ${{ steps.restore_linux_wheels.outputs.cache-primary-key }}
path: wheelhouse/*.whl

Expand All @@ -93,7 +94,7 @@ jobs:
id: restore_macos_wheels
uses: actions/cache/restore@v4
with:
key: macos-wheels-${{ hashFiles('.github/workflows/build-wheels.yaml', '.github/actions/**', 'src/**', 'genome_kit/**', 'pyproject.toml', 'setup.py', 'setup/**') }}
key: macos-wheels-${{ hashFiles('.github/workflows/build-wheels.yaml', '.github/actions/**', 'CMakeLists.txt', 'pyproject.toml', 'src/**', 'genome_kit/**') }}
path: wheelhouse/*.whl

# skip remaining steps on cache hit
Expand All @@ -120,7 +121,7 @@ jobs:
name: cache macos wheels
uses: actions/cache/save@v4
with:
# hashFiles() would produce a different key due to setup/*.pyc files created
# Reuse the restore primary key so saved wheels match the restore key.
key: ${{ steps.restore_macos_wheels.outputs.cache-primary-key }}
path: wheelhouse/*.whl

Expand Down Expand Up @@ -151,7 +152,7 @@ jobs:
- name: Download built wheels
uses: actions/cache/restore@v4
with:
key: macos-wheels-${{ hashFiles('.github/workflows/build-wheels.yaml', '.github/actions/**', 'src/**', 'genome_kit/**', 'pyproject.toml', 'setup.py', 'setup/**') }}
key: macos-wheels-${{ hashFiles('.github/workflows/build-wheels.yaml', '.github/actions/**', 'CMakeLists.txt', 'pyproject.toml', 'src/**', 'genome_kit/**') }}
path: wheelhouse/*.whl
fail-on-cache-miss: true

Expand Down Expand Up @@ -193,23 +194,23 @@ jobs:
# id: restore_linux_intel_wheels
# uses: actions/cache/restore@v4
# with:
# key: linux-wheels-x86_64-${{ hashFiles('.github/workflows/build-wheels.yaml', '.github/actions/**', 'src/**', 'genome_kit/**', 'pyproject.toml', 'setup.py', 'setup/**') }}
# key: linux-wheels-x86_64-${{ hashFiles('.github/workflows/build-wheels.yaml', '.github/actions/**', 'CMakeLists.txt', 'pyproject.toml', 'src/**', 'genome_kit/**') }}
# path: wheelhouse/*.whl
# fail-on-cache-miss: true
#
# - name: Restore the linux arm wheels cache
# id: restore_linux_arm_wheels
# uses: actions/cache/restore@v4
# with:
# key: linux-wheels-aarch64-${{ hashFiles('.github/workflows/build-wheels.yaml', '.github/actions/**', 'src/**', 'genome_kit/**', 'pyproject.toml', 'setup.py', 'setup/**') }}
# key: linux-wheels-aarch64-${{ hashFiles('.github/workflows/build-wheels.yaml', '.github/actions/**', 'CMakeLists.txt', 'pyproject.toml', 'src/**', 'genome_kit/**') }}
# path: wheelhouse/*.whl
# fail-on-cache-miss: true
#
# - name: Restore the macos wheels cache
# id: restore_macos_wheels
# uses: actions/cache/restore@v4
# with:
# key: macos-wheels-${{ hashFiles('.github/workflows/build-wheels.yaml', '.github/actions/**', 'src/**', 'genome_kit/**', 'pyproject.toml', 'setup.py', 'setup/**') }}
# key: macos-wheels-${{ hashFiles('.github/workflows/build-wheels.yaml', '.github/actions/**', 'CMakeLists.txt', 'pyproject.toml', 'src/**', 'genome_kit/**') }}
# path: wheelhouse/*.whl
# fail-on-cache-miss: true
#
Expand Down Expand Up @@ -246,23 +247,23 @@ jobs:
id: restore_linux_intel_wheels
uses: actions/cache/restore@v4
with:
key: linux-wheels-x86_64-${{ hashFiles('.github/workflows/build-wheels.yaml', '.github/actions/**', 'src/**', 'genome_kit/**', 'pyproject.toml', 'setup.py', 'setup/**') }}
key: linux-wheels-x86_64-${{ hashFiles('.github/workflows/build-wheels.yaml', '.github/actions/**', 'CMakeLists.txt', 'pyproject.toml', 'src/**', 'genome_kit/**') }}
path: wheelhouse/*.whl
fail-on-cache-miss: true

- name: Restore the linux arm wheels cache
id: restore_linux_arm_wheels
uses: actions/cache/restore@v4
with:
key: linux-wheels-aarch64-${{ hashFiles('.github/workflows/build-wheels.yaml', '.github/actions/**', 'src/**', 'genome_kit/**', 'pyproject.toml', 'setup.py', 'setup/**') }}
key: linux-wheels-aarch64-${{ hashFiles('.github/workflows/build-wheels.yaml', '.github/actions/**', 'CMakeLists.txt', 'pyproject.toml', 'src/**', 'genome_kit/**') }}
path: wheelhouse/*.whl
fail-on-cache-miss: true

- name: Restore the macos wheels cache
id: restore_macos_wheels
uses: actions/cache/restore@v4
with:
key: macos-wheels-${{ hashFiles('.github/workflows/build-wheels.yaml', '.github/actions/**', 'src/**', 'genome_kit/**', 'pyproject.toml', 'setup.py', 'setup/**') }}
key: macos-wheels-${{ hashFiles('.github/workflows/build-wheels.yaml', '.github/actions/**', 'CMakeLists.txt', 'pyproject.toml', 'src/**', 'genome_kit/**') }}
path: wheelhouse/*.whl
fail-on-cache-miss: true

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dockerize.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
id: restore_gk_pkg
uses: actions/cache/restore@v4
with:
key: gk-tarballs-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.github/workflows/run-tests.yaml', '.github/actions/**', 'conda-recipe/**', 'src/**', 'genome_kit/**', 'setup.py', 'setup/**', 'tests/**') }}
key: gk-tarballs-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.github/workflows/run-tests.yaml', '.github/actions/**', 'conda-recipe/**', 'CMakeLists.txt', 'pyproject.toml', 'src/**', 'genome_kit/**', 'tests/**') }}
path: |
~/conda-bld
fail-on-cache-miss: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
id: restore_gk_pkg
uses: actions/cache/restore@v4
with:
key: gk-tarballs-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.github/workflows/run-tests.yaml', '.github/actions/**', 'conda-recipe/**', 'src/**', 'genome_kit/**', 'setup.py', 'setup/**', 'tests/**') }}
key: gk-tarballs-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.github/workflows/run-tests.yaml', '.github/actions/**', 'conda-recipe/**', 'CMakeLists.txt', 'pyproject.toml', 'src/**', 'genome_kit/**', 'tests/**') }}
path: |
~/conda-bld
fail-on-cache-miss: true
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
- ".github/workflows/**"
- "conda-recipe/**"
- "genome_kit/**"
- "setup.py"
- "setup/**"
- "CMakeLists.txt"
- "pyproject.toml"
- "src/**"
- "tests/**"

Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
id: restore_gk_pkg
uses: actions/cache/restore@v4
with:
key: gk-tarballs-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.github/workflows/run-tests.yaml', '.github/actions/**', 'conda-recipe/**', 'src/**', 'genome_kit/**', 'setup.py', 'setup/**', 'tests/**') }}
key: gk-tarballs-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.github/workflows/run-tests.yaml', '.github/actions/**', 'conda-recipe/**', 'CMakeLists.txt', 'pyproject.toml', 'src/**', 'genome_kit/**', 'tests/**') }}
path: |
~/conda-bld
fail-on-cache-miss: true
Expand Down Expand Up @@ -131,4 +131,4 @@ jobs:
fi
conda mambabuild --croot /tmp/conda-bld -t "${files[@]}" --extra-deps "${extra_deps[@]}"
conda clean -it
set +x
set +x
110 changes: 103 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,120 @@
cmake_minimum_required(VERSION 3.21)
project(GenomeKit)
project(GenomeKit LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

file(GLOB SOURCES CONFIGURE_DEPENDS src/*.cpp src/*.h)
file(GLOB GK_PY_EXTENSION_SOURCES CONFIGURE_DEPENDS src/*.cpp)
file(GLOB GK_HEADERS CONFIGURE_DEPENDS src/*.h)

find_package(Python COMPONENTS Interpreter Development.Module NumPy REQUIRED)
find_package(ZLIB REQUIRED)

if(NOT MSVC)
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
endif()
endif()

Python_add_library(_cxx MODULE WITH_SOABI ${GK_PY_EXTENSION_SOURCES} ${GK_HEADERS})
target_include_directories(_cxx PRIVATE src "${CMAKE_CURRENT_BINARY_DIR}/gen")
target_link_libraries(_cxx PRIVATE Python::Module Python::NumPy ZLIB::ZLIB)
target_compile_definitions(_cxx PRIVATE GKPY_LIBNAME=genome_kit)
set_target_properties(_cxx PROPERTIES
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
)

if(MSVC)
target_compile_definitions(_cxx PRIVATE _CRT_SECURE_NO_WARNINGS)
target_compile_options(_cxx PRIVATE
/permissive-
/Zc:__cplusplus
/Zc:strictStrings-
/Zc:preprocessor
/W3
/EHsc
/wd5033
$<$<CONFIG:Debug>:/GS>
$<$<CONFIG:Debug>:/Zi>
$<$<CONFIG:Debug>:/Od>
$<$<NOT:$<CONFIG:Debug>>:/GL>
$<$<NOT:$<CONFIG:Debug>>:/Gy>
$<$<NOT:$<CONFIG:Debug>>:/Oy>
$<$<NOT:$<CONFIG:Debug>>:/Oi>
)
target_link_options(_cxx PRIVATE
$<$<CONFIG:Debug>:/DEBUG>
$<$<NOT:$<CONFIG:Debug>>:/LTCG>
"/PDB:$<TARGET_FILE_DIR:_cxx>/_cxx.pdb"
)
else()
target_compile_definitions(_cxx PRIVATE _FILE_OFFSET_BITS=64)
target_compile_options(_cxx PRIVATE
-Wall
-Wno-write-strings
-Wno-invalid-offsetof
)
target_link_options(_cxx PRIVATE
$<$<NOT:$<CONFIG:Debug>>:-Wl,-S>
$<$<NOT:$<CONFIG:Debug>>:-Wl,-x>
)
if(APPLE)
if(DEFINED ENV{MACOSX_DEPLOYMENT_TARGET})
set(GENOMEKIT_MACOSX_DEPLOYMENT_TARGET "$ENV{MACOSX_DEPLOYMENT_TARGET}")
else()
set(GENOMEKIT_MACOSX_DEPLOYMENT_TARGET "10.15")
endif()
if(DEFINED ENV{CONDA_BUILD_SYSROOT})
set(GENOMEKIT_MACOS_SYSROOT "$ENV{CONDA_BUILD_SYSROOT}")
elseif(CMAKE_OSX_SYSROOT)
set(GENOMEKIT_MACOS_SYSROOT "${CMAKE_OSX_SYSROOT}")
else()
execute_process(
COMMAND xcrun --sdk macosx --show-sdk-path
OUTPUT_VARIABLE GENOMEKIT_MACOS_SYSROOT
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
endif()
target_compile_definitions(_cxx PRIVATE _LIBCPP_DISABLE_AVAILABILITY)
target_compile_options(_cxx PRIVATE
"-mmacosx-version-min=${GENOMEKIT_MACOSX_DEPLOYMENT_TARGET}"
-stdlib=libc++
-Wshorten-64-to-32
-Wsign-compare
-Wconditional-uninitialized
-Wuninitialized
-Wno-unknown-warning-option
)
target_link_options(_cxx PRIVATE
"-mmacosx-version-min=${GENOMEKIT_MACOSX_DEPLOYMENT_TARGET}"
)
if(GENOMEKIT_MACOS_SYSROOT)
target_compile_options(_cxx PRIVATE "-isysroot${GENOMEKIT_MACOS_SYSROOT}")
target_link_options(_cxx PRIVATE "-isysroot${GENOMEKIT_MACOS_SYSROOT}")
endif()
endif()
endif()

install(TARGETS _cxx DESTINATION genome_kit)

FILE(GLOB SOURCES src/*.cpp src/*.h)
if(DEFINED ENV{IN_CLION})
execute_process(
COMMAND $ENV{CONDA_PREFIX}/bin/python -c "import sys; print('{}.{}'.format(sys.version_info.major, sys.version_info.minor), end='')"
OUTPUT_VARIABLE PYTHON_VERSION
)

# Don't really need this lib (handled by setup.py), but required for CLion's search etc.
# Don't really need this lib for packaging, but required for CLion's search etc.
# NOTE: Set env vars IN_CLION=1;CONDA_PREFIX=$HOME/conda/envs/genomekit_dev in CLion CMake preferences.
# include numpy, Python.h
include_directories(
$ENV{CONDA_PREFIX}/lib/python${PYTHON_VERSION}/site-packages/numpy/core/include/
$ENV{CONDA_PREFIX}/include/python${PYTHON_VERSION}/
)
find_package(ZLIB)
add_library(gkdev ${SOURCES})
target_link_libraries(gkdev ZLIB::ZLIB)
target_compile_definitions(gkdev PRIVATE -D_FILE_OFFSET_BITS=64 -DGKPY_LIBNAME=$ENV{CONDA_PREFIX}/lib -D_WANT_MAIN=1)
Expand All @@ -27,12 +124,11 @@ endif()
set(NON_PY_SOURCES ${SOURCES})
list(FILTER NON_PY_SOURCES EXCLUDE REGEX "py_.*")

add_executable(main ${NON_PY_SOURCES})
add_executable(main EXCLUDE_FROM_ALL ${NON_PY_SOURCES})
target_compile_definitions(main PRIVATE -D_FILE_OFFSET_BITS=64 -D_FILE_ABS_PATH='\"${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp\"' -D_WANT_MAIN=1)
set_target_properties(main PROPERTIES LINKER_LANGUAGE CXX)
find_package(ZLIB)
target_link_libraries(main ZLIB::ZLIB)

include(CTest)
add_test(main unittestbuild/main)
add_test(NAME main COMMAND main)
set_tests_properties(main PROPERTIES WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

10 changes: 5 additions & 5 deletions docs-src/develop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ Build the package in development mode::

pip install -e .

This builds the C++ extension and copies it into
your source tree (``genome_kit/_cxx.so``).
It also ensures that ``import genome_kit`` works from any directory
by linking your source tree from python's ``site-packages``.
This builds the C++ extension with CMake through scikit-build-core and installs
an editable wheel. Python files are loaded from your source tree, while the
compiled extension is loaded from the editable build output.

.. note:: Windows Prerequisites

Expand Down Expand Up @@ -63,7 +62,8 @@ In the CMake settings, set the following environment variables::
Making changes
--------------

If the C/C++ code changed, you must re-run the ``develop`` command::
If the C/C++ code or build configuration changed, you must re-run the editable
install command::

pip install -e .

Expand Down
Loading