From 6a70e7f7c84ed422d5f027f0f4d0d7523ceabb56 Mon Sep 17 00:00:00 2001 From: Dan Haraj Date: Tue, 14 Nov 2017 14:34:44 -0500 Subject: pysc2: init at 1.2 --- pkgs/development/python-modules/pysc2/default.nix | 64 ++++++++++++++++++++++ .../python-modules/pysc2/fix-setup-for-py3.patch | 64 ++++++++++++++++++++++ .../pysc2/parameterize-runconfig-sc2path.patch | 18 ++++++ pkgs/top-level/python-packages.nix | 2 + 4 files changed, 148 insertions(+) create mode 100644 pkgs/development/python-modules/pysc2/default.nix create mode 100644 pkgs/development/python-modules/pysc2/fix-setup-for-py3.patch create mode 100644 pkgs/development/python-modules/pysc2/parameterize-runconfig-sc2path.patch (limited to 'pkgs') 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 diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 8931f6b346fb..f0d78dd4891b 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -270,6 +270,8 @@ in { pythonPackages = self; }; + pysc2 = callPackage ../development/python-modules/pysc2 { }; + pyscard = callPackage ../development/python-modules/pyscard { inherit (pkgs.darwin.apple_sdk.frameworks) PCSC; }; pyside = callPackage ../development/python-modules/pyside { }; -- cgit 1.4.1