diff --git a/VERSION.txt b/VERSION.txt deleted file mode 100644 index 4cc8a67cd0..0000000000 --- a/VERSION.txt +++ /dev/null @@ -1 +0,0 @@ -Beta-GIT diff --git a/bin/evennia b/bin/evennia index 7a965af40c..8f10566192 100755 --- a/bin/evennia +++ b/bin/evennia @@ -15,7 +15,7 @@ import signal import shutil import importlib from argparse import ArgumentParser -from subprocess import Popen, check_output, call +from subprocess import Popen, check_output, call, CalledProcessError, STDOUT import django # Signal processing @@ -24,9 +24,11 @@ SIG = signal.SIGINT # Set up the main python paths to Evennia EVENNIA_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) EVENNIA_BIN = os.path.join(EVENNIA_ROOT, "bin") -EVENNIA_LIB = os.path.join(EVENNIA_ROOT, "evennia") + +import evennia +EVENNIA_LIB = os.path.join(os.path.dirname(os.path.abspath(evennia.__file__))) EVENNIA_RUNNER = os.path.join(EVENNIA_BIN, "evennia_runner.py") -EVENNIA_TEMPLATE = os.path.join(EVENNIA_ROOT, "game_template") +EVENNIA_TEMPLATE = os.path.join(EVENNIA_ROOT, "share", "evennia", "game_template") EVENNIA_BINTESTING = os.path.join(EVENNIA_BIN, "testing") EVENNIA_DUMMYRUNNER = os.path.join(EVENNIA_BINTESTING, "dummyrunner.py") @@ -299,11 +301,14 @@ def evennia_version(): Get the Evennia version info from the main package. """ version = "Unknown" - with open(os.path.join(EVENNIA_ROOT, "VERSION.txt"), 'r') as f: - version = f.read().strip() try: - version = "%s (rev %s)" % (version, check_output("git rev-parse --short HEAD", shell=True, cwd=EVENNIA_ROOT).strip()) - except IOError: + import evennia + version = evennia.__version__ + except ImportError: + pass + try: + version = "%s (rev %s)" % (version, check_output("git rev-parse --short HEAD", shell=True, cwd=EVENNIA_ROOT, stderr=STDOUT).strip()) + except (IOError, CalledProcessError): pass return version diff --git a/bin/evennia_runner.py b/bin/evennia_runner.py index 8f133594f3..e1269e149d 100644 --- a/bin/evennia_runner.py +++ b/bin/evennia_runner.py @@ -19,6 +19,7 @@ import sys from argparse import ArgumentParser from subprocess import Popen import Queue, thread +import evennia try: # check if launched with pypy @@ -31,7 +32,7 @@ PORTAL = None EVENNIA_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) EVENNIA_BIN = os.path.join(EVENNIA_ROOT, "bin") -EVENNIA_LIB = os.path.join(EVENNIA_ROOT, "evennia") +EVENNIA_LIB = os.path.dirname(evennia.__file__) SERVER_PY_FILE = os.path.join(EVENNIA_LIB,'server', 'server.py') PORTAL_PY_FILE = os.path.join(EVENNIA_LIB, 'server', 'portal', 'portal.py') diff --git a/evennia/VERSION.txt b/evennia/VERSION.txt new file mode 100644 index 0000000000..8f0916f768 --- /dev/null +++ b/evennia/VERSION.txt @@ -0,0 +1 @@ +0.5.0 diff --git a/evennia/__init__.py b/evennia/__init__.py index 29b9902513..b87209b076 100644 --- a/evennia/__init__.py +++ b/evennia/__init__.py @@ -15,6 +15,7 @@ See www.evennia.com for full documentation. # Delayed loading of properties # Typeclasses + DefaultPlayer = None DefaultGuest = None DefaultObject = None @@ -61,13 +62,21 @@ spawn = None managers = None import os +from subprocess import check_output, CalledProcessError, STDOUT + +__version__ = "Unknown" + +root = os.path.dirname(os.path.abspath(__file__)) try: - __version__ = "Evennia" - with os.path.join(open(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), "VERSION.txt", 'r') as f: - __version__ += " %s" % f.read().strip() -except IOError: - __version__ += " (unknown version)" -del os + with open(os.path.join(root, "VERSION.txt"), 'r') as f: + __version__ = f.read().strip() +except IOError as err: + print err +try: + __version__ = "%s" % (check_output("git rev-parse --short HEAD", shell=True, cwd=root, stderr=STDOUT).strip()) +except (IOError, CalledProcessError): + pass + def init(): """ diff --git a/evennia/commands/default/batchprocess.py b/evennia/commands/default/batchprocess.py index 266b5f9c45..f16a3ced7e 100644 --- a/evennia/commands/default/batchprocess.py +++ b/evennia/commands/default/batchprocess.py @@ -242,7 +242,7 @@ class CmdBatchCommands(MuxCommand): except UnicodeDecodeError, err: caller.msg(_UTF8_ERROR % (python_path, err)) return - except IOError: + except IOError as err: string = "'%s' not found.\nYou have to supply the python path " string += "of the file relative to \none of your batch-file directories (%s)." caller.msg(string % (python_path, ", ".join(settings.BASE_BATCHPROCESS_PATHS))) diff --git a/contrib/README b/evennia/contrib/README similarity index 100% rename from contrib/README rename to evennia/contrib/README diff --git a/contrib/__init__.py b/evennia/contrib/__init__.py similarity index 100% rename from contrib/__init__.py rename to evennia/contrib/__init__.py diff --git a/contrib/barter.py b/evennia/contrib/barter.py similarity index 100% rename from contrib/barter.py rename to evennia/contrib/barter.py diff --git a/contrib/battle_for_evennia/README b/evennia/contrib/battle_for_evennia/README similarity index 100% rename from contrib/battle_for_evennia/README rename to evennia/contrib/battle_for_evennia/README diff --git a/contrib/chargen.py b/evennia/contrib/chargen.py similarity index 100% rename from contrib/chargen.py rename to evennia/contrib/chargen.py diff --git a/contrib/dice.py b/evennia/contrib/dice.py similarity index 100% rename from contrib/dice.py rename to evennia/contrib/dice.py diff --git a/contrib/email-login.py b/evennia/contrib/email-login.py similarity index 100% rename from contrib/email-login.py rename to evennia/contrib/email-login.py diff --git a/contrib/extended_room.py b/evennia/contrib/extended_room.py similarity index 100% rename from contrib/extended_room.py rename to evennia/contrib/extended_room.py diff --git a/contrib/lineeditor.py b/evennia/contrib/lineeditor.py similarity index 100% rename from contrib/lineeditor.py rename to evennia/contrib/lineeditor.py diff --git a/contrib/menu_login.py b/evennia/contrib/menu_login.py similarity index 100% rename from contrib/menu_login.py rename to evennia/contrib/menu_login.py diff --git a/contrib/menusystem.py b/evennia/contrib/menusystem.py similarity index 100% rename from contrib/menusystem.py rename to evennia/contrib/menusystem.py diff --git a/contrib/procpools/README.txt b/evennia/contrib/procpools/README.txt similarity index 100% rename from contrib/procpools/README.txt rename to evennia/contrib/procpools/README.txt diff --git a/contrib/procpools/__init__.py b/evennia/contrib/procpools/__init__.py similarity index 100% rename from contrib/procpools/__init__.py rename to evennia/contrib/procpools/__init__.py diff --git a/contrib/procpools/ampoule/COPYING.txt b/evennia/contrib/procpools/ampoule/COPYING.txt similarity index 100% rename from contrib/procpools/ampoule/COPYING.txt rename to evennia/contrib/procpools/ampoule/COPYING.txt diff --git a/contrib/procpools/ampoule/EVENNIA.txt b/evennia/contrib/procpools/ampoule/EVENNIA.txt similarity index 100% rename from contrib/procpools/ampoule/EVENNIA.txt rename to evennia/contrib/procpools/ampoule/EVENNIA.txt diff --git a/contrib/procpools/ampoule/__init__.py b/evennia/contrib/procpools/ampoule/__init__.py similarity index 100% rename from contrib/procpools/ampoule/__init__.py rename to evennia/contrib/procpools/ampoule/__init__.py diff --git a/contrib/procpools/ampoule/child.py b/evennia/contrib/procpools/ampoule/child.py similarity index 100% rename from contrib/procpools/ampoule/child.py rename to evennia/contrib/procpools/ampoule/child.py diff --git a/contrib/procpools/ampoule/commands.py b/evennia/contrib/procpools/ampoule/commands.py similarity index 100% rename from contrib/procpools/ampoule/commands.py rename to evennia/contrib/procpools/ampoule/commands.py diff --git a/contrib/procpools/ampoule/iampoule.py b/evennia/contrib/procpools/ampoule/iampoule.py similarity index 100% rename from contrib/procpools/ampoule/iampoule.py rename to evennia/contrib/procpools/ampoule/iampoule.py diff --git a/contrib/procpools/ampoule/main.py b/evennia/contrib/procpools/ampoule/main.py similarity index 100% rename from contrib/procpools/ampoule/main.py rename to evennia/contrib/procpools/ampoule/main.py diff --git a/contrib/procpools/ampoule/pool.py b/evennia/contrib/procpools/ampoule/pool.py similarity index 100% rename from contrib/procpools/ampoule/pool.py rename to evennia/contrib/procpools/ampoule/pool.py diff --git a/contrib/procpools/ampoule/rpool.py b/evennia/contrib/procpools/ampoule/rpool.py similarity index 100% rename from contrib/procpools/ampoule/rpool.py rename to evennia/contrib/procpools/ampoule/rpool.py diff --git a/contrib/procpools/ampoule/service.py b/evennia/contrib/procpools/ampoule/service.py similarity index 100% rename from contrib/procpools/ampoule/service.py rename to evennia/contrib/procpools/ampoule/service.py diff --git a/contrib/procpools/ampoule/test/__init__.py b/evennia/contrib/procpools/ampoule/test/__init__.py similarity index 100% rename from contrib/procpools/ampoule/test/__init__.py rename to evennia/contrib/procpools/ampoule/test/__init__.py diff --git a/contrib/procpools/ampoule/test/test_process.py b/evennia/contrib/procpools/ampoule/test/test_process.py similarity index 100% rename from contrib/procpools/ampoule/test/test_process.py rename to evennia/contrib/procpools/ampoule/test/test_process.py diff --git a/contrib/procpools/ampoule/test/test_proxy.py b/evennia/contrib/procpools/ampoule/test/test_proxy.py similarity index 100% rename from contrib/procpools/ampoule/test/test_proxy.py rename to evennia/contrib/procpools/ampoule/test/test_proxy.py diff --git a/contrib/procpools/ampoule/util.py b/evennia/contrib/procpools/ampoule/util.py similarity index 100% rename from contrib/procpools/ampoule/util.py rename to evennia/contrib/procpools/ampoule/util.py diff --git a/contrib/procpools/python_procpool.py b/evennia/contrib/procpools/python_procpool.py similarity index 100% rename from contrib/procpools/python_procpool.py rename to evennia/contrib/procpools/python_procpool.py diff --git a/contrib/procpools/python_procpool_plugin.py b/evennia/contrib/procpools/python_procpool_plugin.py similarity index 100% rename from contrib/procpools/python_procpool_plugin.py rename to evennia/contrib/procpools/python_procpool_plugin.py diff --git a/contrib/slow_exit.py b/evennia/contrib/slow_exit.py similarity index 100% rename from contrib/slow_exit.py rename to evennia/contrib/slow_exit.py diff --git a/contrib/talking_npc.py b/evennia/contrib/talking_npc.py similarity index 100% rename from contrib/talking_npc.py rename to evennia/contrib/talking_npc.py diff --git a/contrib/tutorial_examples/__init__.py b/evennia/contrib/tutorial_examples/__init__.py similarity index 100% rename from contrib/tutorial_examples/__init__.py rename to evennia/contrib/tutorial_examples/__init__.py diff --git a/contrib/tutorial_examples/batch_cmds.ev b/evennia/contrib/tutorial_examples/batch_cmds.ev similarity index 100% rename from contrib/tutorial_examples/batch_cmds.ev rename to evennia/contrib/tutorial_examples/batch_cmds.ev diff --git a/contrib/tutorial_examples/cmdset_red_button.py b/evennia/contrib/tutorial_examples/cmdset_red_button.py similarity index 100% rename from contrib/tutorial_examples/cmdset_red_button.py rename to evennia/contrib/tutorial_examples/cmdset_red_button.py diff --git a/contrib/tutorial_examples/red_button.py b/evennia/contrib/tutorial_examples/red_button.py similarity index 100% rename from contrib/tutorial_examples/red_button.py rename to evennia/contrib/tutorial_examples/red_button.py diff --git a/contrib/tutorial_examples/red_button_scripts.py b/evennia/contrib/tutorial_examples/red_button_scripts.py similarity index 100% rename from contrib/tutorial_examples/red_button_scripts.py rename to evennia/contrib/tutorial_examples/red_button_scripts.py diff --git a/contrib/tutorial_world/README b/evennia/contrib/tutorial_world/README similarity index 100% rename from contrib/tutorial_world/README rename to evennia/contrib/tutorial_world/README diff --git a/contrib/tutorial_world/__init__.py b/evennia/contrib/tutorial_world/__init__.py similarity index 100% rename from contrib/tutorial_world/__init__.py rename to evennia/contrib/tutorial_world/__init__.py diff --git a/contrib/tutorial_world/build.ev b/evennia/contrib/tutorial_world/build.ev similarity index 100% rename from contrib/tutorial_world/build.ev rename to evennia/contrib/tutorial_world/build.ev diff --git a/contrib/tutorial_world/mob.py b/evennia/contrib/tutorial_world/mob.py similarity index 100% rename from contrib/tutorial_world/mob.py rename to evennia/contrib/tutorial_world/mob.py diff --git a/contrib/tutorial_world/objects.py b/evennia/contrib/tutorial_world/objects.py similarity index 100% rename from contrib/tutorial_world/objects.py rename to evennia/contrib/tutorial_world/objects.py diff --git a/contrib/tutorial_world/rooms.py b/evennia/contrib/tutorial_world/rooms.py similarity index 100% rename from contrib/tutorial_world/rooms.py rename to evennia/contrib/tutorial_world/rooms.py diff --git a/contrib/tutorial_world/scripts.py b/evennia/contrib/tutorial_world/scripts.py similarity index 100% rename from contrib/tutorial_world/scripts.py rename to evennia/contrib/tutorial_world/scripts.py diff --git a/evennia/utils/batchprocessors.py b/evennia/utils/batchprocessors.py index e0975efbae..ca832707aa 100644 --- a/evennia/utils/batchprocessors.py +++ b/evennia/utils/batchprocessors.py @@ -90,7 +90,7 @@ It seems the bottom of the box is a bit loose. # close the @drop command since it's the end of the file) ------------------------- -An example batch file is contribs/examples/batch_example.ev. +An example batch file is contrib/examples/batch_example.ev. ========================================================================== diff --git a/evennia/utils/utils.py b/evennia/utils/utils.py index edfe068a58..012ca78888 100644 --- a/evennia/utils/utils.py +++ b/evennia/utils/utils.py @@ -306,25 +306,8 @@ def host_os_is(osname): def get_evennia_version(): - """ - Get the Evennia version info from the main package. - """ - version = "Unknown" - with open(os.path.join(settings.ROOT_DIR, "VERSION.txt"), 'r') as f: - version = f.read().strip() - try: - version = "%s (rev %s)" % (version, check_output("git rev-parse --short HEAD", shell=True, cwd=settings.ROOT_DIR).strip()) - except IOError: - pass - return version - """ - Check for the evennia version info. - """ - try: - f = open(settings.ROOT_DIR + os.sep + "VERSION.txt", 'r') - return "%s-%s" % (f.read().strip(), os.popen("git rev-parse --short HEAD").read().strip()) - except IOError: - return "Unknown version" + import evennia + return evennia.__version__ def pypath_to_realpath(python_path, file_ending='.py'): @@ -343,7 +326,7 @@ def pypath_to_realpath(python_path, file_ending='.py'): pathsplit = pathsplit[:-1] if not pathsplit: return python_path - path = settings.ROOT_DIR + path = settings.EVENNIA_DIR for directory in pathsplit: path = os.path.join(path, directory) if file_ending: diff --git a/setup.py b/setup.py new file mode 100644 index 0000000000..7d573b56e1 --- /dev/null +++ b/setup.py @@ -0,0 +1,57 @@ +import os +from setuptools import setup, find_packages + +os.chdir(os.path.dirname(os.path.realpath(__file__))) + + +def get_requirements(): + req_lines = open('requirements.txt', 'r').readlines() + reqs = [] + for line in req_lines: + line = line.strip() + if line and not line.startswith('#'): + reqs.append(line) + return reqs + +VERSION_PATH = os.path.join('evennia', 'VERSION.txt') + + +def get_version(): + return open(VERSION_PATH).read().strip() + + +def package_data(): + file_set = [] + for root, dirs, files in os.walk('evennia'): + for f in files: + file_name = os.path.relpath(os.path.join(root, f), 'evennia') + file_set.append(file_name) + return file_set + + +def template_data(): + """ + Finds all of the static and template dirs in the project and adds + them to the package data. + + By default setup.py only installs Python modules. + """ + data = [] + for dirname, _, files in os.walk("game_template"): + for root, ___, current_files in os.walk(dirname): + for f in current_files: + file_name = os.path.join(root, f) + data.append((os.path.join('share', 'evennia', root), [file_name])) + return data + +setup( + name='evennia', + version=get_version(), + description='A full-featured MUD building toolkit.', + packages=find_packages(exclude=['game_template', 'game_template.*']), + scripts=['bin/evennia', 'bin/evennia_runner.py'], + install_requires=get_requirements(), + package_data={'': package_data()}, + data_files=template_data(), + zip_safe=False +)