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
14 changes: 8 additions & 6 deletions .github/workflows/lint_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ jobs:
name: Check Python linting
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v5
- name: Install the latest version of uv.
uses: astral-sh/setup-uv@v5
with:
python-version: '3.13'
python-version: "3.13"

- uses: actions/checkout@v4
- run: pip install -q uv && uv pip install --system ruff==0.4.3 isort
- run: ruff format --check --diff .
- run: ruff check
- run: isort -c --diff nle/
- run: uv sync
- run: uv run ruff format --check --diff .
- run: uv run ruff check
- run: uv run isort -c --diff nle/
22 changes: 12 additions & 10 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,32 @@ jobs:
os: [ubuntu-latest, macos-latest]
fail-fast: false
steps:
- name: Setup Python ${{ matrix.python-version }} env
uses: actions/setup-python@v5
- name: Install Python ${{ matrix.python-version }} with the latest version of uv.
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}
- name: Ensure latest pip, wheel & setuptools
run: python -m pip install -q --upgrade pip wheel setuptools
- name: Install dependencies
- name: Install the latest version of uv.
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install non-python build dependencies
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt-get update && sudo apt-get install -yq \
apt-transport-https \
bison \
build-essential \
cmake \
flex \
libbz2-dev \
ninja-build \
software-properties-common
fi
- uses: actions/checkout@v4
- name: Install from repo in test mode
run: pip install -e '.[dev]'
- name: Run tests
run: python -m pytest --import-mode=append -svx nle/tests
- name: Install package using uv
run: uv sync
- name: Run tests using uv
run: uv run --no-sync pytest --import-mode=append -svx

test_sdist_3_10:
name: Test sdist on MacOS w/ Py3.10
needs: test_repo
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/test_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Ensure latest pip, wheel & setuptools
run: "python -m pip install -q --upgrade pip wheel setuptools"
- name: Install dependencies
run: |
brew install cmake
- name: Install nle via pip
run: "pip install nle"
- name: Check nethack is installed
Expand Down
84 changes: 64 additions & 20 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,60 @@
[project]
name = "nle"
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"]
dependencies = ["pybind11>=2.2", "numpy>=1.16", "gymnasium==1.2.0"]

[project.license]
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 = ["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",
] }

[project.scripts]
nle-play = "nle.scripts.play:main"
nle-ttyrec = "nle.scripts.ttyrec:main"
nle-ttyplay = "nle.scripts.ttyplay:main"
nle-ttyplay2 = "nle.scripts.ttyplay2:main"
nle-read-tty = "nle.scripts.read_tty:main"

[dependency-groups]
dev = ["nle[dev]"]

[project.optional-dependencies]
agent = ["torch>=1.3.1"]
dev = [
"pre-commit>=2.0.1",
"isort>=5.13.2",
"cmake_format>=0.6.10",
"memory-profiler>=0.60.0",
"pytest>=6.2.5",
"pytest-benchmark>=3.4.1",
"sphinx>=2.4.4",
"sphinx-rtd-theme>=0.4.3",
"setuptools>=69.5.1",
"ruff==0.4.3",
]
all = ["nle[agent,dev]"]

[tool.black]
line-length = 88
target-version = ['py38']
Expand All @@ -18,31 +75,15 @@ skip_glob = "**/__init__.py"

[tool.ruff]
# See https://docs.astral.sh/ruff/rules/.
extend-exclude = [
"third_party",
]
extend-exclude = ["third_party"]
exclude = ["win/rl/nle"]
[tool.ruff.lint]
ignore = [
"B008",
"B905",
"C901",
"E501",
"E731",
]
select = [
"B",
"B9",
"C",
"E",
"F",
"W",
"R",
]
ignore = ["B008", "B905", "C901", "E501", "E731"]
select = ["B", "B9", "C", "E", "F", "W", "R"]
[tool.ruff.lint.flake8-comprehensions]
allow-dict-calls-with-keyword-arguments = true
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"] # unused-import.
"__init__.py" = ["F401"] # unused-import.

[tool.cibuildwheel]
# We need to build wheels for the following Python versions:
Expand All @@ -68,3 +109,6 @@ manylinux-aarch64-image = "manylinux2014"
[tool.cibuildwheel.macos]
# For macOS wheels, we only need to install cmake
before-all = "rm -rf {project}/build {project}/*.so {project}/CMakeCache.txt && brew install cmake"

[tool.pytest.ini_options]
testpaths = ["nle/tests"]
64 changes: 1 addition & 63 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
#
# List of environment variables used:
#
# NLE_PACKAGE_NAME
# Prefix of the generated package (defaults to "nle").
#
# NLE_BUILD_RELEASE
# If set, builds wheel (s)dist such as to prepare it for upload to PyPI.
#
Expand Down Expand Up @@ -71,48 +68,7 @@ def build_extension(self, ext):
sys.exit(1)


packages = [
"nle",
"nle.dataset",
"nle.env",
"nle.nethack",
"nle.agent",
"nle.scripts",
"nle.tests",
]

entry_points = {
"console_scripts": [
"nle-play = nle.scripts.play:main",
"nle-ttyrec = nle.scripts.ttyrec:main",
"nle-ttyplay = nle.scripts.ttyplay:main",
"nle-ttyplay2 = nle.scripts.ttyplay2:main",
"nle-read-tty = nle.scripts.read_tty:main",
]
}


extras_deps = {
"dev": [
"pre-commit>=2.0.1",
"isort>=5.13.2",
"cmake_format>=0.6.10",
"memory-profiler>=0.60.0",
"pytest>=6.2.5",
"pytest-benchmark>=3.4.1",
"sphinx>=2.4.4",
"sphinx-rtd-theme>=0.4.3",
"setuptools>=69.5.1",
"ruff>=0.4.3",
],
"agent": ["torch>=1.3.1"],
}

extras_deps["all"] = [item for group in extras_deps.values() for item in group]


if __name__ == "__main__":
package_name = os.getenv("NLE_PACKAGE_NAME", "nle")
cwd = os.path.dirname(os.path.abspath(__file__))
version = open("version.txt", "r").read().strip()
sha = "Unknown"
Expand All @@ -128,36 +84,18 @@ def build_extension(self, ext):

if sha != "Unknown" and not os.getenv("NLE_RELEASE_BUILD"):
version += "+" + sha[:7]
package_name = setuptools.find_packages()[0]
print("Building wheel {}-{}".format(package_name, version))

version_path = os.path.join(cwd, "nle", "version.py")
with open(version_path, "w") as f:
f.write("__version__ = '{}'\n".format(version))
f.write("git_version = {}\n".format(repr(sha)))

with open("README.md") as f:
long_description = f.read()

setuptools.setup(
name=package_name,
version=version,
description=(
"The NetHack Learning Environment (NLE): "
"a reinforcement learning environment based on NetHack"
),
long_description=long_description,
long_description_content_type="text/markdown",
author="The NLE Dev Team",
url="https://github.com/NetHack-LE/nle",
license="NetHack General Public License",
entry_points=entry_points,
packages=packages,
ext_modules=[setuptools.Extension("nle", sources=[])],
cmdclass={"build_ext": CMakeBuild},
setup_requires=["pybind11>=2.2"],
install_requires=["pybind11>=2.2", "numpy>=1.16", "gymnasium==1.2.0"],
extras_require=extras_deps,
python_requires=">=3.10",
classifiers=[
"License :: OSI Approved :: Nethack General Public License",
"Development Status :: 5 - Production/Stable",
Expand Down
Loading
Loading