Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c5ec11f
Use ruff rather than black and isort for linting
jbcoe Jan 1, 2026
5035aea
Use force_single_line for import linting with ruff
jbcoe Jan 30, 2026
1222668
Use scikit-build and drop setup.py
jbcoe Jan 30, 2026
dd784c3
Derive version from Git tags
jbcoe Jan 31, 2026
38f5d31
De-pip test-and-deploy script
jbcoe Feb 3, 2026
aee6506
Use uv for test-and-deploy script
jbcoe Feb 3, 2026
509c65b
Create venv with uv before uv pip install
jbcoe Feb 3, 2026
3c29f19
Create venv with uv before using a wheel
jbcoe Feb 3, 2026
9b763a0
Remove commented use of __version__
jbcoe Feb 3, 2026
4f775ef
Use uv minimally for CI
jbcoe Feb 3, 2026
4f4b9f1
Generate nle/version.py so that __version__ is still defined
jbcoe Feb 4, 2026
d6ba28d
generate typestubs
jbcoe Feb 8, 2026
6e8891e
Use Python not uv to install typestubs. Update build-requirements to …
jbcoe Feb 11, 2026
ab15096
Get CI scripts from main as they are unassociated with typestub gener…
jbcoe Feb 11, 2026
ecde6bb
No need for uv from within CMake
jbcoe Feb 22, 2026
c5c863a
restore file
jbcoe Mar 6, 2026
3dba5cd
Fix comment
jbcoe Mar 6, 2026
0520e3f
Use an isolated uv venv with build deps installed for cmake CI build
jbcoe Mar 6, 2026
6f181cc
FInd Python earlier
jbcoe Mar 6, 2026
84191d3
Merge branch 'main' into jbcoe/generate-typestubs
jbcoe Mar 18, 2026
8998c1d
Use FindPython from pybind11
jbcoe Mar 18, 2026
1d2bd70
Revert unintended change
jbcoe Mar 18, 2026
2b5546c
Revert "Revert unintended change"
jbcoe Mar 18, 2026
98a723d
Robust FindPython for CMake
jbcoe Mar 18, 2026
fd8c640
Re-find python
jbcoe Mar 18, 2026
21ce9d7
Python::Interpreter is a CMake imported executable target — when used…
jbcoe Mar 18, 2026
cabe0f1
Cleaner but still broken build
jbcoe Mar 19, 2026
a6ee360
Undo ineffective changes
jbcoe Mar 19, 2026
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
17 changes: 15 additions & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,21 @@ jobs:
libbz2-dev \
ninja-build \
software-properties-common
- name: Install Python 3.12 with the latest version of uv.
uses: astral-sh/setup-uv@v7
with:
python-version: '3.12'
- uses: actions/checkout@v4
- name: Create venv and install build dependencies
run: |
uv venv --isolated
source .venv/bin/activate
uv pip install scikit-build-core~=0.10 numpy pybind11-stubgen pybind11~=2.2 setuptools-scm~=9.2.2
- name: Check CMake configure
run: cmake -B build -G Ninja
run: |
source .venv/bin/activate
cmake -B build -G Ninja
- name: CMake build
run: cmake --build build
run: |
source .venv/bin/activate
cmake --build build
35 changes: 35 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ message(STATUS "HACKDIR set to: ${HACKDIR}")
set(VARDIR ${HACKDIR})
set(INSTDIR ${HACKDIR})

# Use FindPython in PyBind11 to find Python.
set(PYBIND11_FINDPYTHON NEW)
# pybind11 via FetchContent
include(FetchContent)
FetchContent_Declare(
Expand All @@ -77,6 +79,7 @@ FetchContent_Declare(
GIT_TAG v3.0.1
EXCLUDE_FROM_ALL)
FetchContent_MakeAvailable(pybind11)
message(STATUS "Python_EXECUTABLE is set to: ${Python_EXECUTABLE}")

# de-boost-ified version of boost.context via FetchContent
FetchContent_Declare(
Expand Down Expand Up @@ -222,15 +225,47 @@ set_target_properties(_pyconverter PROPERTIES CXX_STANDARD 14)
target_include_directories(
_pyconverter PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/third_party/converter)

set(STUB_DIR ${CMAKE_CURRENT_BINARY_DIR}/stubs)
set_directory_properties(PROPERTIES ADDITIONAL_CLEAN_FILES "${STUB_DIR}")
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/stubs/nle/_pyconverter.pyi
COMMAND ${Python_EXECUTABLE} -m pybind11_stubgen _pyconverter --output-dir
${STUB_DIR}
WORKING_DIRECTORY $<TARGET_FILE_DIR:_pyconverter>
DEPENDS _pyconverter
COMMENT "Generating type stubs ..."
VERBATIM)

add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/stubs/nle/_pynethack/__init__.pyi
COMMAND ${Python_EXECUTABLE} -m pybind11_stubgen _pynethack --output-dir
${STUB_DIR} --ignore-unresolved-names game_end_types
WORKING_DIRECTORY $<TARGET_FILE_DIR:_pynethack>
DEPENDS _pynethack
COMMENT "Generating type stubs ..."
VERBATIM)

add_custom_target(
my_module_stubs ALL
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/stubs/nle/_pynethack/__init__.pyi
${CMAKE_CURRENT_BINARY_DIR}/stubs/nle/_pyconverter.pyi)

set(TILE_FILES "win/share/monsters.txt" "win/share/objects.txt"
"win/share/other.txt")

install(FILES ${TILE_FILES} DESTINATION ${INSTDIR}/tiles)

# Only install if we are building as part of a Python project.
if(DEFINED SKBUILD_PROJECT_VERSION)
install(
TARGETS _pynethack _pyconverter nethack
RUNTIME DESTINATION ${PYTHON_PACKAGE_NAME}
LIBRARY DESTINATION ${PYTHON_PACKAGE_NAME}
ARCHIVE DESTINATION ${PYTHON_PACKAGE_NAME})

install(
DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/stubs/"
DESTINATION ${PYTHON_PACKAGE_NAME}
FILES_MATCHING
PATTERN "*.pyi")
endif()
Empty file added nle/typed.py
Empty file.
9 changes: 8 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,16 @@ file = "LICENSE"
[project.urls]
Homepage = "https://github.com/NetHack-LE/nle"


[build-system]
# Lock build-deps as uv does not yet support locking of build deps: astral-sh/uv#5190
requires = ["scikit-build-core~=0.10", "pybind11~=2.2", "setuptools-scm~=9.2.2"]
requires = [
"scikit-build-core~=0.10",
"numpy",
"pybind11-stubgen",
"pybind11~=2.2",
"setuptools-scm~=9.2.2",
]
build-backend = "scikit_build_core.build"

[tool.scikit-build]
Expand Down
Loading