Merge pull request #30552 from obsidiansystems/pysc2-init

pysc2: init at 1.2

Changed files
+285 -1
lib
pkgs
applications
science
machine-learning
sc2-headless
development
top-level
+1
lib/maintainers.nix
···
DamienCassou = "Damien Cassou <damien@cassou.me>";
danbst = "Danylo Hlynskyi <abcz2.uprola@gmail.com>";
dancek = "Hannu Hartikainen <hannu.hartikainen@gmail.com>";
+
danharaj = "Dan Haraj <dan@obsidian.systems>";
danielfullmer = "Daniel Fullmer <danielrf12@gmail.com>";
dasuxullebt = "Christoph-Simon Senjak <christoph.senjak@googlemail.com>";
david50407 = "David Kuo <me@davy.tw>";
+6 -1
pkgs/applications/science/machine-learning/sc2-headless/default.nix
···
{ stdenv
+
, callPackage
, lib
, fetchurl
, unzip
···
by setting nixpkgs config option 'sc2-headless.accept_license = true;'
''
else assert licenseAccepted;
-
stdenv.mkDerivation rec {
+
let maps = callPackage ./maps.nix {};
+
in stdenv.mkDerivation rec {
version = "3.17";
name = "sc2-headless-${version}";
···
mkdir -p $out
cp -r . "$out"
rm -r $out/Libs
+
+
cp -r "${maps.minigames}"/* "$out"/Maps/
'';
preFixup = ''
···
url = "https://blzdistsc2-a.akamaihd.net/AI_AND_MACHINE_LEARNING_LICENSE.html";
free = false;
};
+
maintainers = with lib.maintainers; [ danharaj ];
};
}
+11
pkgs/applications/science/machine-learning/sc2-headless/maps.nix
···
+
{ fetchzip
+
}:
+
+
{
+
minigames = fetchzip {
+
url = "https://github.com/deepmind/pysc2/releases/download/v1.2/mini_games.zip";
+
sha256 = "19f873ilcdsf50g2v0s2zzmxil1bqncsk8nq99bzy87h0i7khkla";
+
stripRoot = false;
+
};
+
+
}
+28
pkgs/development/python-modules/absl-py/default.nix
···
+
{ buildPythonPackage
+
, lib
+
, fetchPypi
+
, six
+
}:
+
+
buildPythonPackage rec {
+
pname = "absl-py";
+
version = "0.1.3";
+
name = "${pname}-${version}";
+
+
src = fetchPypi {
+
inherit pname version;
+
sha256 = "017wc85i7l3vpjzw3shgb7k7n0jfid88g09dlf1kgdy4ll0sjfax";
+
};
+
+
propagatedBuildInputs = [ six ];
+
+
# checks use bazel; should be revisited
+
doCheck = false;
+
+
meta = {
+
description = "Abseil Python Common Libraries";
+
homepage = "https://github.com/abseil/abseil-py";
+
license = lib.licenses.asl20;
+
maintainers = with lib.maintainers; [ danharaj ];
+
};
+
}
+22
pkgs/development/python-modules/mpyq/default.nix
···
+
{ buildPythonPackage
+
, lib
+
, fetchPypi
+
}:
+
+
buildPythonPackage rec {
+
pname = "mpyq";
+
version = "0.2.5";
+
name = "${pname}-${version}";
+
+
src = fetchPypi {
+
inherit pname version;
+
sha256 = "01q0xh2fy3zzsrfr45d2ypj4whs7s060cy1rnprg6sg55fbgbaih";
+
};
+
+
meta = {
+
description = "A Python library for extracting MPQ (MoPaQ) files.";
+
homepage = "https://github.com/eagleflo/mpyq";
+
license = lib.licenses.bsd2;
+
maintainers = with lib.maintainers; [ danharaj ];
+
};
+
}
+22
pkgs/development/python-modules/portpicker/default.nix
···
+
{ buildPythonPackage
+
, lib
+
, fetchPypi
+
}:
+
+
buildPythonPackage rec {
+
pname = "portpicker";
+
version = "1.2.0";
+
name = "${pname}-${version}";
+
+
src = fetchPypi {
+
inherit pname version;
+
sha256 = "0c1lm3i4yngi1qclb0hny19vwjd2si5k2qni30wcrnxqqasqak1y";
+
};
+
+
meta = {
+
description = "A library to choose unique available network ports.";
+
homepage = "https://github.com/google/python_portpicker";
+
license = lib.licenses.asl20;
+
maintainers = with lib.maintainers; [ danharaj ];
+
};
+
}
+64
pkgs/development/python-modules/pysc2/default.nix
···
+
{ 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 ];
+
};
+
}
+64
pkgs/development/python-modules/pysc2/fix-setup-for-py3.patch
···
+
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',
+18
pkgs/development/python-modules/pysc2/parameterize-runconfig-sc2path.patch
···
+
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
+27
pkgs/development/python-modules/s2clientprotocol/default.nix
···
+
{ buildPythonPackage
+
, lib
+
, fetchPypi
+
, protobuf
+
}:
+
+
buildPythonPackage rec {
+
pname = "s2clientprotocol";
+
version = "3.19.1.58600.0";
+
name = "${pname}-${version}";
+
+
src = fetchPypi {
+
inherit pname version;
+
sha256 = "02jqwdfj5zpag4c5nf0707qmwk7sqm98yfgrd19rq6pi58zgl74f";
+
};
+
+
patches = [ ./pure-version.patch ];
+
+
buildInputs = [ protobuf ];
+
+
meta = {
+
description = "StarCraft II - client protocol.";
+
homepage = "https://github.com/Blizzard/sc2client-proto";
+
license = lib.licenses.mit;
+
maintainers = with lib.maintainers; [ danharaj ];
+
};
+
}
+13
pkgs/development/python-modules/s2clientprotocol/pure-version.patch
···
+
diff --git a/setup.py b/setup.py
+
index 89131a8..19527df 100755
+
--- a/setup.py
+
+++ b/setup.py
+
@@ -13,8 +13,6 @@ from distutils.spawn import find_executable
+
from setuptools import setup
+
from setuptools.command.build_py import build_py
+
+
-import gameversion_autogen as ver
+
-
+
SETUP_DIR = os.path.dirname(os.path.abspath(__file__))
+
PROTO_DIR = os.path.join(SETUP_DIR, 's2clientprotocol')
+
+9
pkgs/top-level/python-packages.nix
···
# Left for backwards compatibility
"3to2" = self.py3to2;
+
absl-py = callPackage ../development/python-modules/absl-py { };
+
aenum = callPackage ../development/python-modules/aenum { };
affinity = callPackage ../development/python-modules/affinity { };
···
pyqt5 = pkgs.libsForQt5.callPackage ../development/python-modules/pyqt/5.x.nix {
pythonPackages = self;
};
+
+
pysc2 = callPackage ../development/python-modules/pysc2 { };
pyscard = callPackage ../development/python-modules/pyscard { inherit (pkgs.darwin.apple_sdk.frameworks) PCSC; };
···
};
};
+
mpyq = callPackage ../development/python-modules/mpyq { };
+
mxnet = buildPythonPackage rec {
inherit (pkgs.mxnet) name version src meta;
···
ln -s ${pkgs.mxnet}/lib/libmxnet.so $out/${python.sitePackages}/mxnet
'';
};
+
+
portpicker = callPackage ../development/python-modules/portpicker { };
pkginfo = buildPythonPackage rec {
version = "1.3.2";
···
meta.broken = true; # Tests fail, and no reverse-dependencies anyway
};
+
s2clientprotocol = callPackage ../development/python-modules/s2clientprotocol { };
statsd = buildPythonPackage rec {
name = "statsd-${version}";