From a6e71a5bf5c423a1e10bdf1f37f4cf261066d323 Mon Sep 17 00:00:00 2001 From: James Tocknell Date: Fri, 19 Sep 2014 13:12:56 +1000 Subject: Fix requirements --- real-setup.py | 15 +++++++++++++++ requirements.txt | 2 ++ setup.cfg | 2 ++ setup.py | 53 ++++++++++++++++++++++++++++++++++++++++------------- 4 files changed, 59 insertions(+), 13 deletions(-) create mode 100644 real-setup.py create mode 100644 requirements.txt create mode 100644 setup.cfg diff --git a/real-setup.py b/real-setup.py new file mode 100644 index 0000000..c9f92b9 --- /dev/null +++ b/real-setup.py @@ -0,0 +1,15 @@ +from setuptools import find_packages, setup +from Cython.Build import cythonize + +setup( + name='robots', + packages=find_packages(), + ext_modules=cythonize('robots/*.pyx'), + install_requires=[ + 'flask', + 'blessings', + 'cython', + 'logbook', + 'zmq' + ], +) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..d144e94 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +../simple-network +. diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..01f6a07 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[metadata] +setup-requires = Cython diff --git a/setup.py b/setup.py index 9e80889..cd079e6 100644 --- a/setup.py +++ b/setup.py @@ -1,13 +1,40 @@ -from setuptools import find_packages, setup -from Cython.Build import cythonize - -setup( - name='robots', - packages=find_packages(), - ext_modules=cythonize('robots/*.pyx'), - install_requires=[ - 'flask', - 'blessings', - 'cython', - ], -) +#!/usr/bin/env python +# Install dependencies from a "[metadata] setup-requires = ..." section in +# setup.cfg, then run real-setup.py. +# From https://bitbucket.org/dholth/setup-requires + +import sys, os, subprocess, codecs, pkg_resources + +sys.path[0:0] = ['setup-requires'] +pkg_resources.working_set.add_entry('setup-requires') + +try: + import configparser +except: + import ConfigParser as configparser + +def get_requirements(): + if not os.path.exists('setup.cfg'): return + config = configparser.ConfigParser() + config.readfp(codecs.open('setup.cfg', encoding='utf-8')) + setup_requires = config.get('metadata', 'setup-requires') + specifiers = [line.strip() for line in setup_requires.splitlines()] + for specifier in specifiers: + try: + pkg_resources.require(specifier) + except pkg_resources.DistributionNotFound: + yield specifier + +try: + to_install = list(get_requirements()) + if to_install: + subprocess.call([sys.executable, "-m", "pip", "install", + "-t", "setup-requires"] + to_install) +except (configparser.NoSectionError, configparser.NoOptionError): + pass + +# Run real-setup.py +exec(compile(open("real-setup.py").read().replace('\\r\\n', '\\n'), + __file__, + 'exec')) + -- cgit v1.2.3 From 053961479b1ca17e0dac83d41b45848ba81b07c4 Mon Sep 17 00:00:00 2001 From: James Tocknell Date: Fri, 19 Sep 2014 13:25:26 +1000 Subject: Added urwid to requirements --- real-setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/real-setup.py b/real-setup.py index c9f92b9..73e9ef8 100644 --- a/real-setup.py +++ b/real-setup.py @@ -10,6 +10,7 @@ setup( 'blessings', 'cython', 'logbook', - 'zmq' + 'pyzmq', + 'urwid' ], ) -- cgit v1.2.3 From e3a217c5959f7e313d62133a7abe014634f3ad30 Mon Sep 17 00:00:00 2001 From: James Tocknell Date: Fri, 19 Sep 2014 16:13:47 +1000 Subject: Use develop mode in requirements.txt --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index d144e94..d9b8239 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -../simple-network -. +-e ../simple-network +-e . -- cgit v1.2.3 From ace2ce54a4e947250dfbab0a14ef039f9c4db147 Mon Sep 17 00:00:00 2001 From: James Tocknell Date: Fri, 19 Sep 2014 17:46:11 +1000 Subject: Fixed capturer --- .hgignore | 4 ++++ capturer.py | 20 ++++---------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/.hgignore b/.hgignore index e21f17c..5d9d8a5 100644 --- a/.hgignore +++ b/.hgignore @@ -1,3 +1,7 @@ syntax: glob *~ *.py[co] +robots.egg* +*.c +*.o +*.so diff --git a/capturer.py b/capturer.py index 7a698ee..54b0be6 100644 --- a/capturer.py +++ b/capturer.py @@ -46,19 +46,7 @@ class CaptureSpawns(object): return results if __name__ == '__main__': -# random.seed(42) - map_ = robots.border_map(40, 30, 0) - - add_spawns(map_, 300, 'X') - add_spawns(map_, 20, '+') - - for y in range(20): - map_[y][20] = 'X' - - add_spawns(map_, 6) - - game = robots.Game(map_) - game.add_bot(CaptureSpawns(variance=0), 'Alice') - game.add_bot(CaptureSpawns(variance=0.01), 'Bob') - viewer = robots.CursesViewer(game) - viewer.run() + server = robots.Server() + server.SERVER_NAME = 'Capturer Server' + server.add_bot(CaptureSpawns, 'Capture') + server.run() -- cgit v1.2.3