[yt-svn] commit/yt: 2 new changesets
Bitbucket
commits-noreply at bitbucket.org
Mon Dec 3 13:34:05 PST 2012
2 new commits in yt:
https://bitbucket.org/yt_analysis/yt/changeset/2cc1aa41184e/
changeset: 2cc1aa41184e
branch: yt
user: MatthewTurk
date: 2012-12-03 21:17:30
summary: This updates yt to embed the mercurial hash (and branch) in a file named
__hg_version__.py when installing. I believe I have fixed the locations where
this is used to correctly use it.
affected #: 3 files
diff -r fa360d6c81c39378a925cc88cb67ac2b44248ba7 -r 2cc1aa41184e1447b8398fa1a4252b12a63cb3a7 setup.py
--- a/setup.py
+++ b/setup.py
@@ -7,6 +7,7 @@
import distribute_setup
distribute_setup.use_setuptools()
+from distutils.command.build_py import build_py
from numpy.distutils.misc_util import appendpath
from numpy.distutils import log
from distutils import version
@@ -110,6 +111,39 @@
if os.path.exists('MANIFEST'): os.remove('MANIFEST')
+def get_mercurial_changeset_id(targetDir):
+ """adapted from a script by Jason F. Harris, published at
+
+ http://jasonfharris.com/blog/2010/05/versioning-your-application-with-the-mercurial-changeset-hash/
+
+ """
+ import subprocess
+ import re
+ getChangeset = subprocess.Popen('hg identify -b -i', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
+
+ if (getChangeset.stderr.read() != ""):
+ print "Error in obtaining current changeset of the Mercurial repository"
+ changeset = None
+
+ changeset = getChangeset.stdout.read().strip()
+ if (not re.search("^[0-9a-f]{12}", changeset)):
+ print "Current changeset of the Mercurial repository is malformed"
+ changeset = None
+
+ return changeset
+
+class my_build_py(build_py):
+ def run(self):
+ # honor the --dry-run flag
+ if not self.dry_run:
+ target_dir = os.path.join(self.build_lib,'yt')
+ src_dir = os.getcwd()
+ changeset = get_mercurial_changeset_id(src_dir)
+ self.mkpath(target_dir)
+ with open(os.path.join(target_dir, '__hg_version__.py'), 'w') as fobj:
+ fobj.write("hg_version = '%s'\n" % changeset)
+
+ build_py.run(self)
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
@@ -166,6 +200,7 @@
configuration=configuration,
zip_safe=False,
data_files=REASON_FILES,
+ cmdclass = {'build_py': my_build_py},
)
return
diff -r fa360d6c81c39378a925cc88cb67ac2b44248ba7 -r 2cc1aa41184e1447b8398fa1a4252b12a63cb3a7 yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -466,6 +466,11 @@
return u.popbuffer()
def get_yt_version():
+ try:
+ from yt.__hg_version__ import hg_version
+ return hg_version
+ except ImportError:
+ pass
import pkg_resources
yt_provider = pkg_resources.get_provider("yt")
path = os.path.dirname(yt_provider.module_path)
diff -r fa360d6c81c39378a925cc88cb67ac2b44248ba7 -r 2cc1aa41184e1447b8398fa1a4252b12a63cb3a7 yt/utilities/command_line.py
--- a/yt/utilities/command_line.py
+++ b/yt/utilities/command_line.py
@@ -339,9 +339,15 @@
return u.popbuffer()
def get_yt_version():
+ try:
+ from yt.__hg_version__ import hg_version
+ return hg_version
+ except ImportError:
+ pass
import pkg_resources
yt_provider = pkg_resources.get_provider("yt")
path = os.path.dirname(yt_provider.module_path)
+ if not os.path.isdir(os.path.join(path, ".hg")): return None
version = _get_hg_version(path)[:12]
return version
@@ -1037,9 +1043,8 @@
print "The supplemental repositories are located at:"
print " %s" % (spath)
update_supp = True
- vstring = None
- if "site-packages" not in path:
- vstring = get_hg_version(path)
+ vstring = get_yt_version()
+ if vstring is not None:
print
print "The current version of the code is:"
print
@@ -1047,10 +1052,11 @@
print vstring.strip()
print "---"
print
- print "This installation CAN be automatically updated."
- if opts.update_source:
- update_hg(path)
- print "Updated successfully."
+ if "site-packages" not in path:
+ print "This installation CAN be automatically updated."
+ if opts.update_source:
+ update_hg(path)
+ print "Updated successfully."
elif opts.update_source:
print
print "YT site-packages not in path, so you must"
https://bitbucket.org/yt_analysis/yt/changeset/61f553c23c6a/
changeset: 61f553c23c6a
branch: yt
user: MatthewTurk
date: 2012-12-03 21:26:38
summary: Fixing a couple camelCase issues. Note that target_dir is not currently used.
affected #: 1 file
diff -r 2cc1aa41184e1447b8398fa1a4252b12a63cb3a7 -r 61f553c23c6aa7f9aefa2e53d9879c61c0733eaa setup.py
--- a/setup.py
+++ b/setup.py
@@ -111,7 +111,7 @@
if os.path.exists('MANIFEST'): os.remove('MANIFEST')
-def get_mercurial_changeset_id(targetDir):
+def get_mercurial_changeset_id(target_dir):
"""adapted from a script by Jason F. Harris, published at
http://jasonfharris.com/blog/2010/05/versioning-your-application-with-the-mercurial-changeset-hash/
@@ -119,13 +119,16 @@
"""
import subprocess
import re
- getChangeset = subprocess.Popen('hg identify -b -i', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
+ get_changeset = subprocess.Popen('hg identify -b -i',
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ shell=True)
- if (getChangeset.stderr.read() != ""):
+ if (get_changeset.stderr.read() != ""):
print "Error in obtaining current changeset of the Mercurial repository"
changeset = None
- changeset = getChangeset.stdout.read().strip()
+ changeset = get_changeset.stdout.read().strip()
if (not re.search("^[0-9a-f]{12}", changeset)):
print "Current changeset of the Mercurial repository is malformed"
changeset = None
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list