about summary refs log tree commit diff
path: root/pkgs/development/python-modules
diff options
context:
space:
mode:
authorDan Haraj <dan@obsidian.systems>2017-11-14 14:34:44 -0500
committerDan Haraj <dan@obsidian.systems>2017-11-14 14:37:53 -0500
commit6a70e7f7c84ed422d5f027f0f4d0d7523ceabb56 (patch)
treedb659e5e0c8d2f2b2b2f3362961f48e1ec56db85 /pkgs/development/python-modules
parentbdce7d3a04ea3ebaebe033da13e3c6651845e45f (diff)
downloadnixlib-6a70e7f7c84ed422d5f027f0f4d0d7523ceabb56.tar
nixlib-6a70e7f7c84ed422d5f027f0f4d0d7523ceabb56.tar.gz
nixlib-6a70e7f7c84ed422d5f027f0f4d0d7523ceabb56.tar.bz2
nixlib-6a70e7f7c84ed422d5f027f0f4d0d7523ceabb56.tar.lz
nixlib-6a70e7f7c84ed422d5f027f0f4d0d7523ceabb56.tar.xz
nixlib-6a70e7f7c84ed422d5f027f0f4d0d7523ceabb56.tar.zst
nixlib-6a70e7f7c84ed422d5f027f0f4d0d7523ceabb56.zip
pysc2: init at 1.2
Diffstat (limited to 'pkgs/development/python-modules')
-rw-r--r--pkgs/development/python-modules/pysc2/default.nix64
-rw-r--r--pkgs/development/python-modules/pysc2/fix-setup-for-py3.patch64
-rw-r--r--pkgs/development/python-modules/pysc2/parameterize-runconfig-sc2path.patch18
3 files changed, 146 insertions, 0 deletions
diff --git a/pkgs/development/python-modules/pysc2/default.nix b/pkgs/development/python-modules/pysc2/default.nix
new file mode 100644
index 000000000000..a2dfd53b7951
--- /dev/null
+++ b/pkgs/development/python-modules/pysc2/default.nix
@@ -0,0 +1,64 @@
+{ buildPythonPackage
+, lib
+, fetchFromGitHub
+, absl-py
+, enum34
+, future
+, futures
+, mock
+, mpyq
+, numpy
+, portpicker
+, protobuf
+, pygame
+, s2clientprotocol
+, six
+, websocket_client
+, sc2-headless
+}:
+
+buildPythonPackage rec {
+  version = "1.2";
+  name = "PySC2-${version}";
+
+  src = fetchFromGitHub {
+    owner = "deepmind";
+    repo = "pysc2";
+    rev = "39f84b01d662eb58b3d95791f59208c210afd4e7";
+    sha256 = "0dfbc2krd2rys1ji75ng2nl0ki8nhnylxljcp287bfb8qyz2m25p";
+  };
+
+  patches = [
+    ./fix-setup-for-py3.patch
+    ./parameterize-runconfig-sc2path.patch
+  ];
+
+  postPatch = ''
+    substituteInPlace "./pysc2/run_configs/platforms.py" \
+      --subst-var-by 'sc2path' '${sc2-headless}'
+  '';
+
+  propagatedBuildInputs = [
+    absl-py
+    enum34
+    future
+    mock
+    mpyq
+    numpy
+    portpicker
+    protobuf
+    pygame
+    s2clientprotocol
+    six
+    websocket_client
+    sc2-headless
+  ];
+
+  meta = {
+    description = "Starcraft II environment and library for training agents.";
+    homepage = "https://github.com/deepmind/pysc2";
+    license = lib.licenses.asl20;
+    platforms = lib.platforms.linux;
+    maintainers = with lib.maintainers; [ danharaj ];
+  };
+}
diff --git a/pkgs/development/python-modules/pysc2/fix-setup-for-py3.patch b/pkgs/development/python-modules/pysc2/fix-setup-for-py3.patch
new file mode 100644
index 000000000000..b1a2b4e2350a
--- /dev/null
+++ b/pkgs/development/python-modules/pysc2/fix-setup-for-py3.patch
@@ -0,0 +1,64 @@
+diff --git a/setup.py b/setup.py
+index 020768f..13c2b67 100755
+--- a/setup.py
++++ b/setup.py
+@@ -17,6 +17,8 @@ from __future__ import absolute_import
+ from __future__ import division
+ from __future__ import print_function
+ 
++import sys
++
+ from setuptools import setup
+ 
+ description = """PySC2 - StarCraft II Learning Environment
+@@ -36,6 +38,27 @@ some initial research results using the environment.
+ Read the README at https://github.com/deepmind/pysc2 for more information.
+ """
+ 
++requires = [
++    'absl-py>=0.1.0',
++    'future',
++    'mock',
++    'mpyq',
++    'numpy>=1.10',
++    'portpicker>=1.2.0',
++    'protobuf>=2.6',
++    'pygame',
++    's2clientprotocol>=3.19.0.58400.0',
++    'six',
++    'websocket-client',
++]
++
++if sys.version_info[0] == 2:
++    requires.append('futures')
++
++if (sys.version_info[0] == 2
++        or (sys.version_info[0] == 3 and sys.version_info[1] < 4)):
++    requires.append('enum34')
++
+ setup(
+     name='PySC2',
+     version='1.2',
+@@ -56,21 +79,7 @@ setup(
+         'pysc2.run_configs',
+         'pysc2.tests',
+     ],
+-    install_requires=[
+-        'absl-py>=0.1.0',
+-        'enum34',
+-        'future',
+-        'futures',
+-        'mock',
+-        'mpyq',
+-        'numpy>=1.10',
+-        'portpicker>=1.2.0',
+-        'protobuf>=2.6',
+-        'pygame',
+-        's2clientprotocol>=3.19.0.58400.0',
+-        'six',
+-        'websocket-client',
+-    ],
++    install_requires=requires,
+     entry_points={
+         'console_scripts': [
+             'pysc2_agent = pysc2.bin.agent:entry_point',
diff --git a/pkgs/development/python-modules/pysc2/parameterize-runconfig-sc2path.patch b/pkgs/development/python-modules/pysc2/parameterize-runconfig-sc2path.patch
new file mode 100644
index 000000000000..be667503d47c
--- /dev/null
+++ b/pkgs/development/python-modules/pysc2/parameterize-runconfig-sc2path.patch
@@ -0,0 +1,18 @@
+diff --git a/pysc2/run_configs/platforms.py b/pysc2/run_configs/platforms.py
+index 5cd84f9..1923cb7 100644
+--- a/pysc2/run_configs/platforms.py
++++ b/pysc2/run_configs/platforms.py
+@@ -119,12 +119,9 @@ class Linux(LocalBase):
+   """Config to run on Linux."""
+ 
+   def __init__(self):
+-    base_dir = os.environ.get("SC2PATH", "~/StarCraftII")
++    base_dir = os.environ.get("SC2PATH", "@sc2path@")
+     base_dir = os.path.expanduser(base_dir)
+     env = copy.deepcopy(os.environ)
+-    env["LD_LIBRARY_PATH"] = ":".join(filter(None, [
+-        os.environ.get("LD_LIBRARY_PATH"),
+-        os.path.join(base_dir, "Libs/")]))
+     super(Linux, self).__init__(base_dir, "SC2_x64", env=env)
+ 
+   @classmethod