From 0fb94ef0d86e6947d44831e3c67060f6bc4f3694 Mon Sep 17 00:00:00 2001 From: Samuel Ainsworth Date: Sun, 8 Jan 2023 04:18:18 +0000 Subject: [PATCH] python3Packages.nocturne: init at unstable-2022-10-15 --- .../python-modules/nocturne/default.nix | 61 +++++++++++++++++++ .../nocturne/dependencies.patch | 27 ++++++++ 2 files changed, 88 insertions(+) create mode 100644 pkgs/development/python-modules/nocturne/default.nix create mode 100644 pkgs/development/python-modules/nocturne/dependencies.patch diff --git a/pkgs/development/python-modules/nocturne/default.nix b/pkgs/development/python-modules/nocturne/default.nix new file mode 100644 index 00000000000..42424f1dacc --- /dev/null +++ b/pkgs/development/python-modules/nocturne/default.nix @@ -0,0 +1,61 @@ +{ buildPythonPackage +, cmake +, fetchFromGitHub +, gtest +, hydra-core +, lib +, nlohmann_json +, pybind11 +, PyVirtualDisplay +, sfml +, substituteAll +}: + +buildPythonPackage rec { + pname = "nocturne"; + version = "unstable-2022-10-15"; + format = "setuptools"; + + src = fetchFromGitHub { + owner = "facebookresearch"; + repo = pname; + rev = "ae0a4e361457caf6b7e397675cc86f46161405ed"; + hash = "sha256-pFVbl4m7qX1mJgleNabRboS9klDDsbzUa4PYL5+Jupc="; + }; + + # Simulate the git submodules but with nixpkgs dependencies + postUnpack = '' + rm -rf $sourceRoot/third_party/* + ln -s ${nlohmann_json.src} $sourceRoot/third_party/json + ln -s ${pybind11.src} $sourceRoot/third_party/pybind11 + ''; + + patches = [ + (substituteAll { + src = ./dependencies.patch; + gtest_src = gtest.src; + }) + ]; + + nativeBuildInputs = [ cmake ]; + dontUseCmakeConfigure = true; + + buildInputs = [ sfml ]; + + # hydra-core and PyVirtualDisplay are not declared as dependences but they are requirements + propagatedBuildInputs = [ hydra-core PyVirtualDisplay ]; + + # Test suite requires hydra-submitit-launcher which is not packaged as of 2022-01-02 + doCheck = false; + + pythonImportsCheck = [ + "nocturne" + ]; + + meta = with lib; { + description = "A data-driven, fast driving simulator for multi-agent coordination under partial observability"; + homepage = "https://github.com/facebookresearch/nocturne"; + license = licenses.mit; + maintainers = with maintainers; [ samuela ]; + }; +} diff --git a/pkgs/development/python-modules/nocturne/dependencies.patch b/pkgs/development/python-modules/nocturne/dependencies.patch new file mode 100644 index 00000000000..18843ff6309 --- /dev/null +++ b/pkgs/development/python-modules/nocturne/dependencies.patch @@ -0,0 +1,27 @@ +diff --git a/nocturne/cpp/CMakeLists.txt b/nocturne/cpp/CMakeLists.txt +index c67815f..e1f825b 100644 +--- a/nocturne/cpp/CMakeLists.txt ++++ b/nocturne/cpp/CMakeLists.txt +@@ -62,8 +62,7 @@ include(FetchContent) + + FetchContent_Declare( + googletest +- GIT_REPOSITORY https://github.com/google/googletest.git +- GIT_TAG main ++ SOURCE_DIR @gtest_src@ + ) + + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) +diff --git a/setup.py b/setup.py +index 4863ae6..b5d3545 100644 +--- a/setup.py ++++ b/setup.py +@@ -92,6 +92,8 @@ def main(): + # with open("./requirements.txt", "r") as f: + # requires = f.read().splitlines() + setup( ++ # Adding `packages=` is necessary to get `python setup.py install` to work ++ packages=["nocturne", "cfgs"], + ext_modules=[CMakeExtension("nocturne", "./nocturne")], + cmdclass=dict(build_ext=CMakeBuild), + )