about summary refs log tree commit diff
path: root/pkgs/development/python-modules/ale-py
diff options
context:
space:
mode:
authorBill Huang <bill.huang2001@gmail.com>2022-12-06 04:00:45 +0800
committerGitHub <noreply@github.com>2022-12-05 21:00:45 +0100
commitc8366d7f3e282c46b3dba73c305692089c924d55 (patch)
tree54f8e2c85ca5aae42f4550de07a54edcb60236b2 /pkgs/development/python-modules/ale-py
parent929771b9ed06bc8405647267101fb75dec43cc03 (diff)
python310Packages.ale-py: init at 0.8.0 (#199118)
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
Diffstat (limited to 'pkgs/development/python-modules/ale-py')
-rw-r--r--pkgs/development/python-modules/ale-py/cmake-pybind11.patch18
-rw-r--r--pkgs/development/python-modules/ale-py/default.nix83
2 files changed, 101 insertions, 0 deletions
diff --git a/pkgs/development/python-modules/ale-py/cmake-pybind11.patch b/pkgs/development/python-modules/ale-py/cmake-pybind11.patch
new file mode 100644
index 0000000000000..5bcf5b1d9b2f4
--- /dev/null
+++ b/pkgs/development/python-modules/ale-py/cmake-pybind11.patch
@@ -0,0 +1,18 @@
+diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt
+index 911e280..d484943 100644
+--- a/src/python/CMakeLists.txt
++++ b/src/python/CMakeLists.txt
+@@ -1,12 +1,6 @@
+ find_package(Python3 COMPONENTS Interpreter Development.Module REQUIRED)
+ 
+-include(FetchContent)
+-FetchContent_Declare(
+-    pybind11
+-    GIT_REPOSITORY https://github.com/pybind/pybind11
+-    GIT_TAG v2.10.0)
+-FetchContent_MakeAvailable(pybind11)
+-
++find_package(pybind11 REQUIRED)
+ add_library(ale-py MODULE ale_python_interface.cpp)
+ # Depend on the ALE and pybind11 module
+ target_link_libraries(ale-py PUBLIC ale ale-lib)
diff --git a/pkgs/development/python-modules/ale-py/default.nix b/pkgs/development/python-modules/ale-py/default.nix
new file mode 100644
index 0000000000000..5a2893349eafd
--- /dev/null
+++ b/pkgs/development/python-modules/ale-py/default.nix
@@ -0,0 +1,83 @@
+{ buildPythonPackage
+, SDL2
+, cmake
+, fetchFromGitHub
+, git
+, gym
+, importlib-metadata
+, importlib-resources
+, lib
+, ninja
+, numpy
+, pybind11
+, pytestCheckHook
+, python
+, pythonOlder
+, setuptools
+, stdenv
+, typing-extensions
+, wheel
+, zlib
+}:
+
+buildPythonPackage rec {
+  pname = "ale-py";
+  version = "0.8.0";
+  format = "pyproject";
+
+  src = fetchFromGitHub {
+    owner = "mgbellemare";
+    repo = "Arcade-Learning-Environment";
+    rev = "v${version}";
+    sha256 = "sha256-OPAtCc2RapK1lALTKHd95bkigxcZ9bcONu32I/91HIg=";
+  };
+
+  patches = [
+    # don't download pybind11, use local pybind11
+    ./cmake-pybind11.patch
+  ];
+
+  nativeBuildInputs = [
+    cmake
+    setuptools
+    wheel
+    pybind11
+  ];
+
+  buildInputs = [
+    zlib
+    SDL2
+  ];
+
+  propagatedBuildInputs = [
+    typing-extensions
+    importlib-resources
+    numpy
+  ] ++ lib.optionals (pythonOlder "3.10") [
+    importlib-metadata
+  ];
+
+  checkInputs = [
+    pytestCheckHook
+    gym
+  ];
+
+  postPatch = ''
+    substituteInPlace pyproject.toml \
+      --replace 'dynamic = ["version"]' 'version = "${version}"'
+    substituteInPlace setup.py \
+      --replace 'subprocess.check_output(["git", "rev-parse", "--short", "HEAD"], cwd=here)' 'b"${src.rev}"'
+  '';
+
+  dontUseCmakeConfigure = true;
+
+  pythonImportsCheck = [ "ale_py" ];
+
+  meta = with lib; {
+    description = "a simple framework that allows researchers and hobbyists to develop AI agents for Atari 2600 games";
+    homepage = "https://github.com/mgbellemare/Arcade-Learning-Environment";
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ billhuang ];
+    broken = stdenv.isDarwin; # fails to link with missing library
+  };
+}