Skip to content
Merged
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
8 changes: 4 additions & 4 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ jobs:
with:
python-version: '3.10'
- name: Ensure latest pip, wheel & setuptools
run: python -m pip install -q --upgrade pip wheel setuptools
run: python -m pip install -q --upgrade pip build
- uses: actions/checkout@v4
- name: Generate sdist
run: |
NLE_RELEASE_BUILD=1 python setup.py sdist
NLE_RELEASE_BUILD=1 python -m build --sdist --outdir dist
- name: Install from sdist
run: |
SDISTNAME=$(ls dist/)
Expand All @@ -74,11 +74,11 @@ jobs:
with:
python-version: 3.13
- name: Ensure latest pip, wheel & setuptools
run: python -m pip install -q --upgrade pip wheel setuptools
run: python -m pip install -q --upgrade pip build
- uses: actions/checkout@v4
- name: Generate sdist
run: |
NLE_RELEASE_BUILD=1 python setup.py sdist
NLE_RELEASE_BUILD=1 python -m build --sdist --outdir dist
- name: Install from sdist
run: |
SDISTNAME=$(ls dist/)
Expand Down
30 changes: 20 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
cmake_minimum_required(VERSION 3.28)
file(STRINGS "version.txt" NLE_VERSION)
# Remove any rcXX suffix from the version number as CMake doesn't like it
string(REGEX REPLACE "rc[0-9+]$" "" CMAKE_NLE_VERSION ${NLE_VERSION})
if(NOT DEFINED NLE_VERSION)
if(DEFINED SKBUILD_PROJECT_VERSION)
set(NLE_VERSION ${SKBUILD_PROJECT_VERSION})
else()
set(NLE_VERSION "0.0.0") # Unversioned.
endif()
endif()

# Extract version number (major.minor.patch) as CMake doesn't like rc/dev
# suffixes
string(REGEX MATCH "^[0-9]+(\\.[0-9]+)*" CMAKE_NLE_VERSION "${NLE_VERSION}")
project(nle VERSION ${CMAKE_NLE_VERSION})

if(CMAKE_BUILD_TYPE MATCHES Debug)
Expand Down Expand Up @@ -36,13 +44,6 @@ message(STATUS "Building nle backend version: ${CMAKE_NLE_VERSION}")

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# We use this to decide where the root of the nle/ package is. Normally it
# shouldn't be needed, but sometimes (e.g. when using setuptools) we are
# generating some of the files outside of the original package path.
set(PYTHON_SRC_PARENT
${nle_SOURCE_DIR}
CACHE STRING "Directory containing the nle package files")

set(HACKDIR
"$ENV{HOME}/nethackdir.nle"
CACHE STRING "Configuration files for nethack")
Expand Down Expand Up @@ -202,3 +203,12 @@ target_link_libraries(_pyconverter PUBLIC converter)
set_target_properties(_pyconverter PROPERTIES CXX_STANDARD 14)
target_include_directories(
_pyconverter PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/third_party/converter)

# 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})
endif()
8 changes: 1 addition & 7 deletions nle/nethack/nethack.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Copyright (c) Facebook, Inc. and its affiliates.
import importlib.resources
import os
import shutil
import sys
Expand All @@ -12,6 +11,7 @@
from nle import _pynethack

DLPATH = os.path.join(os.path.dirname(_pynethack.__file__), "libnethack.so")
HACKDIR = os.path.join(os.path.dirname(_pynethack.__file__), "nethackdir")

DUNGEON_SHAPE = (_pynethack.nethack.ROWNO, _pynethack.nethack.COLNO - 1)
BLSTATS_SHAPE = (_pynethack.nethack.NLE_BLSTATS_SIZE,)
Expand Down Expand Up @@ -67,12 +67,6 @@
"time",
)

try:
HACKDIR = str(importlib.resources.files("nle") / "nethackdir")
except AttributeError: # No files() function in Python 3.8.
with importlib.resources.path("nle", "nethackdir") as path:
HACKDIR = str(path)

TTYREC_VERSION = 3


Expand Down
44 changes: 30 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
[project]
name = "nle"
dynamic = ["version"]
description = "The NetHack Learning Environment (NLE): a reinforcement learning environment based on NetHack"
readme = "README.md"
authors = [{ name = "The NLE Dev Team" }]
requires-python = ">=3.10"
dynamic = ["classifiers", "version"]
classifiers = [
"License :: OSI Approved :: Nethack General Public License",
"Development Status :: 5 - Production/Stable",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: C",
"Programming Language :: C++",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Games/Entertainment",
]
dependencies = ["pybind11>=2.2", "numpy>=1.16", "gymnasium==1.2.0"]

[project.license]
Expand All @@ -15,19 +30,20 @@ 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 = ["cmake~=4.2.1", "pybind11~=2.2", "setuptools~=80.9.0"]
build-backend = "setuptools.build_meta"

[tool.setuptools.packages]
find = { include = [
"nle",
"nle.dataset",
"nle.env",
"nle.nethack",
"nle.agent",
"nle.scripts",
"nle.tests",
] }
requires = ["scikit-build-core~=0.10", "pybind11~=2.2", "setuptools-scm~=9.2.2"]
build-backend = "scikit_build_core.build"

[tool.scikit-build]
cmake.build-type = "Release"
cmake.args = ["-DHACKDIR=nle/nethackdir", "-DPYTHON_PACKAGE_NAME=nle"]
minimum-version = "build-system.requires"
metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
generate = [
{ path = "nle/version.py", template = '__version__ = "${version}"' },
]

[tool.setuptools_scm]
# This section is necessary to activate setuptools-scm, but can be empty

[project.scripts]
nle-play = "nle.scripts.play:main"
Expand Down
115 changes: 0 additions & 115 deletions setup.py

This file was deleted.

1 change: 0 additions & 1 deletion version.txt

This file was deleted.

Loading