working versions, data files, and package metadata
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -21,6 +21,9 @@ overviewer_core/c_overviewer.pyd
|
|||||||
overviewer_core/c_overviewer_d.pyd
|
overviewer_core/c_overviewer_d.pyd
|
||||||
overviewer_core/c_overviewer.dylib
|
overviewer_core/c_overviewer.dylib
|
||||||
|
|
||||||
|
# generated version file
|
||||||
|
overviewer_core/overviewer_version.py
|
||||||
|
|
||||||
# Mac OS X noise
|
# Mac OS X noise
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
|||||||
@@ -4,5 +4,6 @@ include CONTRIBUTORS.rst
|
|||||||
include overviewer.py
|
include overviewer.py
|
||||||
recursive-include contrib/ *.py
|
recursive-include contrib/ *.py
|
||||||
recursive-include overviewer_core/*.py
|
recursive-include overviewer_core/*.py
|
||||||
|
exclude overviewer_core/overviewer_version.py
|
||||||
recursive-include overviewer_core/src/ *.c *.h
|
recursive-include overviewer_core/src/ *.c *.h
|
||||||
recursive-include overviewer_core/data/ *.png *.js index.html style.css
|
recursive-include overviewer_core/data/ *.png *.js index.html style.css
|
||||||
|
|||||||
@@ -56,8 +56,8 @@ if hasattr(sys, "frozen"):
|
|||||||
pass # we don't bother with a compat test since it should always be in sync
|
pass # we don't bother with a compat test since it should always be in sync
|
||||||
elif "extension_version" in dir(c_overviewer):
|
elif "extension_version" in dir(c_overviewer):
|
||||||
# check to make sure the binary matches the headers
|
# check to make sure the binary matches the headers
|
||||||
if os.path.exists(os.path.join(this_dir, "src", "overviewer.h")):
|
if os.path.exists(os.path.join(this_dir, "overviewer_core", "src", "overviewer.h")):
|
||||||
with open(os.path.join(this_dir, "src", "overviewer.h")) as f:
|
with open(os.path.join(this_dir, "overviewer_core", "src", "overviewer.h")) as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
lines = filter(lambda x: x.startswith("#define OVERVIEWER_EXTENSION_VERSION"), lines)
|
lines = filter(lambda x: x.startswith("#define OVERVIEWER_EXTENSION_VERSION"), lines)
|
||||||
if lines:
|
if lines:
|
||||||
@@ -116,9 +116,8 @@ def main():
|
|||||||
print "Minecraft-Overviewer"
|
print "Minecraft-Overviewer"
|
||||||
print "Git version: %s" % util.findGitVersion()
|
print "Git version: %s" % util.findGitVersion()
|
||||||
try:
|
try:
|
||||||
import overviewer_version
|
import overviewer_core.overviewer_version as overviewer_version
|
||||||
if hasattr(sys, "frozen"):
|
print "built on %s" % overviewer_version.BUILD_DATE
|
||||||
print "py2exe version build on %s" % overviewer_version.BUILD_DATE
|
|
||||||
print "Build machine: %s %s" % (overviewer_version.BUILD_PLATFORM, overviewer_version.BUILD_OS)
|
print "Build machine: %s %s" % (overviewer_version.BUILD_PLATFORM, overviewer_version.BUILD_OS)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ class MapGen(object):
|
|||||||
blank.save(os.path.join(tileDir, "blank."+quadtree.imgformat))
|
blank.save(os.path.join(tileDir, "blank."+quadtree.imgformat))
|
||||||
|
|
||||||
# copy web assets into destdir:
|
# 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
|
# do the same with the local copy, if we have it
|
||||||
if self.web_assets_path:
|
if self.web_assets_path:
|
||||||
mirror_dir(self.web_assets_path, self.destdir)
|
mirror_dir(self.web_assets_path, self.destdir)
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ def _find_file(filename, mode="rb"):
|
|||||||
This searches the following locations in this order:
|
This searches the following locations in this order:
|
||||||
|
|
||||||
* the textures_path given in the config file (if present)
|
* the textures_path given in the config file (if present)
|
||||||
* The program dir (same dir as this file)
|
* The program dir (same dir as overviewer.py)
|
||||||
* The program dir / textures
|
* The overviewer_core textures dir
|
||||||
* On Darwin, in /Applications/Minecraft
|
* On Darwin, in /Applications/Minecraft
|
||||||
* Inside minecraft.jar, which is looked for at these locations
|
* 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):
|
if os.path.exists(path):
|
||||||
return open(path, mode)
|
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):
|
if os.path.exists(path):
|
||||||
return open(path, mode)
|
return open(path, mode)
|
||||||
|
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ def get_program_path():
|
|||||||
return os.path.dirname(sys.executable)
|
return os.path.dirname(sys.executable)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
# normally, we're in ./overviewer/util.py
|
# normally, we're in ./overviewer_core/util.py
|
||||||
# we want ./overviewer/data/
|
# we want ./
|
||||||
return os.path.join(os.path.dirname(__file__), 'data')
|
return os.path.dirname(os.path.dirname(__file__))
|
||||||
except NameError:
|
except NameError:
|
||||||
return os.path.dirname(sys.argv[0])
|
return os.path.dirname(sys.argv[0])
|
||||||
|
|
||||||
|
|||||||
48
setup.py
48
setup.py
@@ -29,6 +29,9 @@ setup_kwargs['options'] = {}
|
|||||||
|
|
||||||
setup_kwargs['name'] = 'Minecraft-Overviewer'
|
setup_kwargs['name'] = 'Minecraft-Overviewer'
|
||||||
setup_kwargs['version'] = '0.0.0' # TODO useful version
|
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
|
# py2exe options
|
||||||
@@ -36,7 +39,6 @@ setup_kwargs['version'] = '0.0.0' # TODO useful version
|
|||||||
|
|
||||||
if py2exe is not None:
|
if py2exe is not None:
|
||||||
setup_kwargs['console'] = ['overviewer.py']
|
setup_kwargs['console'] = ['overviewer.py']
|
||||||
setup_kwargs['data_files'] = [('', ['COPYING.txt', 'README.rst', 'CONTRIBUTORS.rst'])]
|
|
||||||
setup_kwargs['zipfile'] = None
|
setup_kwargs['zipfile'] = None
|
||||||
if platform.system() == 'Windows' and '64bit' in platform.architecture():
|
if platform.system() == 'Windows' and '64bit' in platform.architecture():
|
||||||
b = 3
|
b = 3
|
||||||
@@ -53,6 +55,7 @@ setup_kwargs['scripts'] = ['overviewer.py']
|
|||||||
setup_kwargs['package_data'] = {'overviewer_core':
|
setup_kwargs['package_data'] = {'overviewer_core':
|
||||||
['data/textures/*',
|
['data/textures/*',
|
||||||
'data/web_assets/*']}
|
'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)]
|
build.sub_commands = [('build_ext', None)]
|
||||||
|
|
||||||
# custom clean command to remove in-place extension
|
# custom clean command to remove in-place extension
|
||||||
|
# and the version file
|
||||||
class CustomClean(clean):
|
class CustomClean(clean):
|
||||||
def run(self):
|
def run(self):
|
||||||
# do the normal cleanup
|
# do the normal cleanup
|
||||||
@@ -115,7 +119,31 @@ class CustomClean(clean):
|
|||||||
log.debug("'%s' does not exist -- can't clean it",
|
log.debug("'%s' does not exist -- can't clean it",
|
||||||
pretty_fname)
|
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):
|
class CustomBuild(build_ext):
|
||||||
|
def run(self):
|
||||||
|
# generate the version file
|
||||||
|
generate_version_py()
|
||||||
|
build_ext.run(self)
|
||||||
def build_extensions(self):
|
def build_extensions(self):
|
||||||
c = self.compiler.compiler_type
|
c = self.compiler.compiler_type
|
||||||
if c == "msvc":
|
if c == "msvc":
|
||||||
@@ -130,24 +158,6 @@ class CustomBuild(build_ext):
|
|||||||
build_ext.build_extensions(self)
|
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']['clean'] = CustomClean
|
||||||
setup_kwargs['cmdclass']['build_ext'] = CustomBuild
|
setup_kwargs['cmdclass']['build_ext'] = CustomBuild
|
||||||
###
|
###
|
||||||
|
|||||||
Reference in New Issue
Block a user