PIP packaging with setup.py, and fixes for bugs revealed by this.
This commit is contained in:
parent
42e7d9164e
commit
265f8a4e30
52 changed files with 92 additions and 37 deletions
|
|
@ -1 +0,0 @@
|
||||||
Beta-GIT
|
|
||||||
19
bin/evennia
19
bin/evennia
|
|
@ -15,7 +15,7 @@ import signal
|
||||||
import shutil
|
import shutil
|
||||||
import importlib
|
import importlib
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from subprocess import Popen, check_output, call
|
from subprocess import Popen, check_output, call, CalledProcessError, STDOUT
|
||||||
import django
|
import django
|
||||||
|
|
||||||
# Signal processing
|
# Signal processing
|
||||||
|
|
@ -24,9 +24,11 @@ SIG = signal.SIGINT
|
||||||
# Set up the main python paths to Evennia
|
# Set up the main python paths to Evennia
|
||||||
EVENNIA_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
EVENNIA_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
EVENNIA_BIN = os.path.join(EVENNIA_ROOT, "bin")
|
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_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_BINTESTING = os.path.join(EVENNIA_BIN, "testing")
|
||||||
EVENNIA_DUMMYRUNNER = os.path.join(EVENNIA_BINTESTING, "dummyrunner.py")
|
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.
|
Get the Evennia version info from the main package.
|
||||||
"""
|
"""
|
||||||
version = "Unknown"
|
version = "Unknown"
|
||||||
with open(os.path.join(EVENNIA_ROOT, "VERSION.txt"), 'r') as f:
|
|
||||||
version = f.read().strip()
|
|
||||||
try:
|
try:
|
||||||
version = "%s (rev %s)" % (version, check_output("git rev-parse --short HEAD", shell=True, cwd=EVENNIA_ROOT).strip())
|
import evennia
|
||||||
except IOError:
|
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
|
pass
|
||||||
return version
|
return version
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import sys
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from subprocess import Popen
|
from subprocess import Popen
|
||||||
import Queue, thread
|
import Queue, thread
|
||||||
|
import evennia
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# check if launched with pypy
|
# check if launched with pypy
|
||||||
|
|
@ -31,7 +32,7 @@ PORTAL = None
|
||||||
|
|
||||||
EVENNIA_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
EVENNIA_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
EVENNIA_BIN = os.path.join(EVENNIA_ROOT, "bin")
|
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')
|
SERVER_PY_FILE = os.path.join(EVENNIA_LIB,'server', 'server.py')
|
||||||
PORTAL_PY_FILE = os.path.join(EVENNIA_LIB, 'server', 'portal', 'portal.py')
|
PORTAL_PY_FILE = os.path.join(EVENNIA_LIB, 'server', 'portal', 'portal.py')
|
||||||
|
|
|
||||||
1
evennia/VERSION.txt
Normal file
1
evennia/VERSION.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
0.5.0
|
||||||
|
|
@ -15,6 +15,7 @@ See www.evennia.com for full documentation.
|
||||||
# Delayed loading of properties
|
# Delayed loading of properties
|
||||||
|
|
||||||
# Typeclasses
|
# Typeclasses
|
||||||
|
|
||||||
DefaultPlayer = None
|
DefaultPlayer = None
|
||||||
DefaultGuest = None
|
DefaultGuest = None
|
||||||
DefaultObject = None
|
DefaultObject = None
|
||||||
|
|
@ -61,13 +62,21 @@ spawn = None
|
||||||
managers = None
|
managers = None
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from subprocess import check_output, CalledProcessError, STDOUT
|
||||||
|
|
||||||
|
__version__ = "Unknown"
|
||||||
|
|
||||||
|
root = os.path.dirname(os.path.abspath(__file__))
|
||||||
try:
|
try:
|
||||||
__version__ = "Evennia"
|
with open(os.path.join(root, "VERSION.txt"), 'r') as f:
|
||||||
with os.path.join(open(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), "VERSION.txt", 'r') as f:
|
__version__ = f.read().strip()
|
||||||
__version__ += " %s" % f.read().strip()
|
except IOError as err:
|
||||||
except IOError:
|
print err
|
||||||
__version__ += " (unknown version)"
|
try:
|
||||||
del os
|
__version__ = "%s" % (check_output("git rev-parse --short HEAD", shell=True, cwd=root, stderr=STDOUT).strip())
|
||||||
|
except (IOError, CalledProcessError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -242,7 +242,7 @@ class CmdBatchCommands(MuxCommand):
|
||||||
except UnicodeDecodeError, err:
|
except UnicodeDecodeError, err:
|
||||||
caller.msg(_UTF8_ERROR % (python_path, err))
|
caller.msg(_UTF8_ERROR % (python_path, err))
|
||||||
return
|
return
|
||||||
except IOError:
|
except IOError as err:
|
||||||
string = "'%s' not found.\nYou have to supply the python path "
|
string = "'%s' not found.\nYou have to supply the python path "
|
||||||
string += "of the file relative to \none of your batch-file directories (%s)."
|
string += "of the file relative to \none of your batch-file directories (%s)."
|
||||||
caller.msg(string % (python_path, ", ".join(settings.BASE_BATCHPROCESS_PATHS)))
|
caller.msg(string % (python_path, ", ".join(settings.BASE_BATCHPROCESS_PATHS)))
|
||||||
|
|
|
||||||
|
|
@ -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)
|
# 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.
|
||||||
|
|
||||||
|
|
||||||
==========================================================================
|
==========================================================================
|
||||||
|
|
|
||||||
|
|
@ -306,25 +306,8 @@ def host_os_is(osname):
|
||||||
|
|
||||||
|
|
||||||
def get_evennia_version():
|
def get_evennia_version():
|
||||||
"""
|
import evennia
|
||||||
Get the Evennia version info from the main package.
|
return evennia.__version__
|
||||||
"""
|
|
||||||
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"
|
|
||||||
|
|
||||||
|
|
||||||
def pypath_to_realpath(python_path, file_ending='.py'):
|
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]
|
pathsplit = pathsplit[:-1]
|
||||||
if not pathsplit:
|
if not pathsplit:
|
||||||
return python_path
|
return python_path
|
||||||
path = settings.ROOT_DIR
|
path = settings.EVENNIA_DIR
|
||||||
for directory in pathsplit:
|
for directory in pathsplit:
|
||||||
path = os.path.join(path, directory)
|
path = os.path.join(path, directory)
|
||||||
if file_ending:
|
if file_ending:
|
||||||
|
|
|
||||||
57
setup.py
Normal file
57
setup.py
Normal file
|
|
@ -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
|
||||||
|
)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue