0

working versions, data files, and package metadata

This commit is contained in:
Aaron Griffith
2011-05-13 22:24:49 -04:00
parent e84ef2c1d2
commit 4ec1b4c971
7 changed files with 45 additions and 32 deletions

3
.gitignore vendored
View File

@@ -21,6 +21,9 @@ overviewer_core/c_overviewer.pyd
overviewer_core/c_overviewer_d.pyd
overviewer_core/c_overviewer.dylib
# generated version file
overviewer_core/overviewer_version.py
# Mac OS X noise
.DS_Store

View File

@@ -4,5 +4,6 @@ include CONTRIBUTORS.rst
include overviewer.py
recursive-include contrib/ *.py
recursive-include overviewer_core/*.py
exclude overviewer_core/overviewer_version.py
recursive-include overviewer_core/src/ *.c *.h
recursive-include overviewer_core/data/ *.png *.js index.html style.css

View File

@@ -56,8 +56,8 @@ if hasattr(sys, "frozen"):
pass # we don't bother with a compat test since it should always be in sync
elif "extension_version" in dir(c_overviewer):
# check to make sure the binary matches the headers
if os.path.exists(os.path.join(this_dir, "src", "overviewer.h")):
with open(os.path.join(this_dir, "src", "overviewer.h")) as f:
if os.path.exists(os.path.join(this_dir, "overviewer_core", "src", "overviewer.h")):
with open(os.path.join(this_dir, "overviewer_core", "src", "overviewer.h")) as f:
lines = f.readlines()
lines = filter(lambda x: x.startswith("#define OVERVIEWER_EXTENSION_VERSION"), lines)
if lines:
@@ -116,10 +116,9 @@ def main():
print "Minecraft-Overviewer"
print "Git version: %s" % util.findGitVersion()
try:
import overviewer_version
if hasattr(sys, "frozen"):
print "py2exe version build on %s" % overviewer_version.BUILD_DATE
print "Build machine: %s %s" % (overviewer_version.BUILD_PLATFORM, overviewer_version.BUILD_OS)
import overviewer_core.overviewer_version as overviewer_version
print "built on %s" % overviewer_version.BUILD_DATE
print "Build machine: %s %s" % (overviewer_version.BUILD_PLATFORM, overviewer_version.BUILD_OS)
except:
pass
sys.exit(0)

View File

@@ -97,7 +97,7 @@ class MapGen(object):
blank.save(os.path.join(tileDir, "blank."+quadtree.imgformat))
# copy web assets into destdir:
mirror_dir(os.path.join(util.get_program_path(), "web_assets"), self.destdir)
mirror_dir(os.path.join(util.get_program_path(), "overviewer_core", "data", "web_assets"), self.destdir)
# do the same with the local copy, if we have it
if self.web_assets_path:
mirror_dir(self.web_assets_path, self.destdir)

View File

@@ -32,8 +32,8 @@ def _find_file(filename, mode="rb"):
This searches the following locations in this order:
* the textures_path given in the config file (if present)
* The program dir (same dir as this file)
* The program dir / textures
* The program dir (same dir as overviewer.py)
* The overviewer_core textures dir
* On Darwin, in /Applications/Minecraft
* Inside minecraft.jar, which is looked for at these locations
@@ -53,7 +53,7 @@ def _find_file(filename, mode="rb"):
if os.path.exists(path):
return open(path, mode)
path = os.path.join(programdir, "textures", filename)
path = os.path.join(programdir, "overviewer_core", "data", "textures", filename)
if os.path.exists(path):
return open(path, mode)

View File

@@ -27,9 +27,9 @@ def get_program_path():
return os.path.dirname(sys.executable)
else:
try:
# normally, we're in ./overviewer/util.py
# we want ./overviewer/data/
return os.path.join(os.path.dirname(__file__), 'data')
# normally, we're in ./overviewer_core/util.py
# we want ./
return os.path.dirname(os.path.dirname(__file__))
except NameError:
return os.path.dirname(sys.argv[0])

View File

@@ -29,6 +29,9 @@ setup_kwargs['options'] = {}
setup_kwargs['name'] = 'Minecraft-Overviewer'
setup_kwargs['version'] = '0.0.0' # TODO useful version
setup_kwargs['author'] = 'Andrew Brown'
setup_kwargs['author_email'] = 'brownan@gmail.com'
setup_kwargs['url'] = 'http://overviewer.org/'
#
# py2exe options
@@ -36,7 +39,6 @@ setup_kwargs['version'] = '0.0.0' # TODO useful version
if py2exe is not None:
setup_kwargs['console'] = ['overviewer.py']
setup_kwargs['data_files'] = [('', ['COPYING.txt', 'README.rst', 'CONTRIBUTORS.rst'])]
setup_kwargs['zipfile'] = None
if platform.system() == 'Windows' and '64bit' in platform.architecture():
b = 3
@@ -53,6 +55,7 @@ setup_kwargs['scripts'] = ['overviewer.py']
setup_kwargs['package_data'] = {'overviewer_core':
['data/textures/*',
'data/web_assets/*']}
setup_kwargs['data_files'] = [('Minecraft-Overviewer', ['COPYING.txt', 'README.rst', 'CONTRIBUTORS.rst', 'sample.settings.py'])]
#
@@ -93,6 +96,7 @@ setup_kwargs['options']['build_ext'] = {'inplace' : 1}
build.sub_commands = [('build_ext', None)]
# custom clean command to remove in-place extension
# and the version file
class CustomClean(clean):
def run(self):
# do the normal cleanup
@@ -114,8 +118,32 @@ class CustomClean(clean):
else:
log.debug("'%s' does not exist -- can't clean it",
pretty_fname)
versionpath = os.path.join("overviewer_core", "overviewer_version.py")
try:
if not self.dry_run:
os.remove(versionpath)
log.info("removing '%s'", versionpath)
except OSError:
log.warn("'%s' could not be cleaned -- permission denied", versionpath)
def generate_version_py():
try:
import overviewer_core.util as util
f = open("overviewer_core/overviewer_version.py", "w")
f.write("VERSION=%r\n" % util.findGitVersion())
f.write("BUILD_DATE=%r\n" % time.asctime())
f.write("BUILD_PLATFORM=%r\n" % platform.processor())
f.write("BUILD_OS=%r\n" % platform.platform())
f.close()
except:
print "WARNING: failed to build overview_version file"
class CustomBuild(build_ext):
def run(self):
# generate the version file
generate_version_py()
build_ext.run(self)
def build_extensions(self):
c = self.compiler.compiler_type
if c == "msvc":
@@ -130,24 +158,6 @@ class CustomBuild(build_ext):
build_ext.build_extensions(self)
if py2exe is not None:
# define a subclass of py2exe to build our version file on the fly
class CustomPy2exe(py2exe.build_exe.py2exe):
def run(self):
try:
import util
f = open("overviewer_version.py", "w")
f.write("VERSION=%r\n" % util.findGitVersion())
f.write("BUILD_DATE=%r\n" % time.asctime())
f.write("BUILD_PLATFORM=%r\n" % platform.processor())
f.write("BUILD_OS=%r\n" % platform.platform())
f.close()
setup_kwargs['data_files'].append(('.', ['overviewer_version.py']))
except:
print "WARNING: failed to build overview_version file"
py2exe.build_exe.py2exe.run(self)
setup_kwargs['cmdclass']['py2exe'] = CustomPy2exe
setup_kwargs['cmdclass']['clean'] = CustomClean
setup_kwargs['cmdclass']['build_ext'] = CustomBuild
###