[yt-svn] commit/yt: 2 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Wed Apr 20 11:09:51 PDT 2016


2 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/17467a0fe24f/
Changeset:   17467a0fe24f
Branch:      yt
User:        ngoldbaum
Date:        2016-04-18 21:02:27+00:00
Summary:     Make "yt update" and "yt version" behave more nicely on conda
Affected #:  2 files

diff -r d8eec89b2c86f300ce9cfb0205b97cefb5dd0c45 -r 17467a0fe24fc86b7c296e2c616d43bd54423c51 yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -551,9 +551,13 @@
         print("Updating and precise version information requires ")
         print("python-hglib to be installed.")
         print("Try: pip install python-hglib")
-        return -1
-    repo = hglib.open(path)
-    return repo.identify()
+        return None
+    try:
+        repo = hglib.open(path)
+        return repo.identify()
+    except hglib.error.ServerError:
+        # path is not an hg repository
+        return None
 
 def get_yt_version():
     try:
@@ -564,8 +568,11 @@
     import pkg_resources
     yt_provider = pkg_resources.get_provider("yt")
     path = os.path.dirname(yt_provider.module_path)
-    version = get_hg_version(path)[:12]
-    return version
+    version = get_hg_version(path)
+    if version is None:
+        return version
+    else:
+        return version[:12].strip().decode('utf-8')
 
 def get_version_stack():
     version_info = {}

diff -r d8eec89b2c86f300ce9cfb0205b97cefb5dd0c45 -r 17467a0fe24fc86b7c296e2c616d43bd54423c51 yt/utilities/command_line.py
--- a/yt/utilities/command_line.py
+++ b/yt/utilities/command_line.py
@@ -32,6 +32,7 @@
 from yt.funcs import \
     ensure_list, \
     get_hg_version, \
+    get_yt_version, \
     mylog, \
     ensure_dir_exists, \
     update_hg, \
@@ -74,6 +75,48 @@
     if "longname" in argc: argnames.append(argc.pop('longname'))
     sc.add_argument(*argnames, **argc)
 
+def _print_failed_source_update(reinstall=False):
+    print()
+    print("The yt package is not installed from a mercurial repository,")
+    print("so you must update this installation manually.")
+    if 'Continuum Analytics' in sys.version or 'Anaconda' in sys.version:
+        # see http://stackoverflow.com/a/21318941/1382869 for why we need
+        # to check both Continuum *and* Anaconda
+        print()
+        print("Since it looks like you are using a python installation")
+        print("that is managed by conda, you may want to do:")
+        print()
+        print("    $ conda update yt")
+        print()
+        print("to update your yt installation.")
+        if reinstall is True:
+            print()
+            print("To update all of your packages, you can do:")
+            print()
+            print("    $ conda update --all")
+
+def _print_installation_information(path):
+    import yt
+    print()
+    print("yt module located at:")
+    print("    %s" % (path))
+    if "YT_DEST" in os.environ:
+        spath = os.path.join(
+            os.environ["YT_DEST"], "src", "yt-supplemental")
+        if os.path.isdir(spath):
+            print("The supplemental repositories are located at:")
+            print("    %s" % (spath))
+    print()
+    print("The current version of yt is:")
+    print()
+    print("---")
+    print("Version = %s" % yt.__version__)
+    vstring = get_hg_version(path)
+    if vstring is not None:
+        print("Changeset = %s" % vstring.strip().decode("utf-8"))
+    print("---")
+    return vstring
+
 class YTCommandSubtype(type):
     def __init__(cls, name, b, d):
         type.__init__(cls, name, b, d)
@@ -334,6 +377,13 @@
 def _update_yt_stack(path):
     "Rerun the install script to updated all dependencies."
 
+    if "YT_DEST" not in os.environ:
+        print()
+        print("This yt installation does not appear to be managed by the")
+        print("source-based install script, but 'update --all' was specified.")
+        print("You will need to update your dependencies manually.")
+        return
+
     install_script = os.path.join(path, "doc/install_script.sh")
     if not os.path.exists(install_script):
         print()
@@ -361,19 +411,6 @@
         print("The yt stack has been updated successfully.")
         print("Now get back to work!")
 
-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)
-    return version
-
 # This code snippet is modified from Georg Brandl
 def bb_apicall(endpoint, data, use_pass = True):
     uri = 'https://api.bitbucket.org/1.0/%s/' % endpoint
@@ -605,43 +642,17 @@
 
     def __call__(self, opts):
         import pkg_resources
-        import yt
         yt_provider = pkg_resources.get_provider("yt")
         path = os.path.dirname(yt_provider.module_path)
-        print()
-        print("yt module located at:")
-        print("    %s" % (path))
-        if "YT_DEST" in os.environ:
-            spath = os.path.join(
-                     os.environ["YT_DEST"], "src", "yt-supplemental")
-            if os.path.isdir(spath):
-                print("The supplemental repositories are located at:")
-                print("    %s" % (spath))
-        vstring = get_yt_version()
-        if vstring == -1:
-            vstring = "unknown"
+        vstring = _print_installation_information(path)
         if vstring is not None:
-            print()
-            print("The current version and changeset for the code is:")
-            print()
-            print("---")
-            print("Version = %s" % yt.__version__)
-            print("Changeset = %s" % vstring.strip().decode("utf-8"))
-            print("---")
-            print()
-            if "site-packages" not in path:
-                print("This installation CAN be automatically updated.")
-                if opts.update_source:
-                    update_hg(path)
-                    print("Updated successfully.")
+            print("This installation CAN be automatically updated.")
+            if opts.update_source:
+                update_hg(path)
+                print("Updated successfully.")
                 _get_yt_stack_date()
         elif opts.update_source:
-            print()
-            print("YT site-packages not in path, so you must")
-            print("update this installation manually by committing and")
-            print("merging your modifications to the code before")
-            print("updating to the newest changeset.")
-            print()
+            _print_failed_source_update()
         if vstring is not None and opts.outputfile is not None:
             open(opts.outputfile, "w").write(vstring)
 
@@ -1024,28 +1035,10 @@
 
     def __call__(self, opts):
         import pkg_resources
-        import yt
         yt_provider = pkg_resources.get_provider("yt")
         path = os.path.dirname(yt_provider.module_path)
-        print()
-        print("yt module located at:")
-        print("    %s" % (path))
-        if "YT_DEST" in os.environ:
-            spath = os.path.join(
-                     os.environ["YT_DEST"], "src", "yt-supplemental")
-            if os.path.isdir(spath):
-                print("The supplemental repositories are located at:")
-                print("    %s" % (spath))
-        vstring = None
-        if "site-packages" not in path:
-            vstring = get_hg_version(path)
-            print()
-            print("The current version and changeset for the code is:")
-            print()
-            print("---")
-            print("Version = %s" % yt.__version__)
-            print("Changeset = %s" % vstring.strip().decode("utf-8"))
-            print("---")
+        vstring = _print_installation_information(path)
+        if vstring is not None:
             print()
             print("This installation CAN be automatically updated.")
             update_hg(path, skip_rebuild=opts.reinstall)
@@ -1054,12 +1047,7 @@
             if opts.reinstall:
                 _update_yt_stack(path)
         else:
-            print()
-            print("YT site-packages not in path, so you must")
-            print("update this installation manually by committing and")
-            print("merging your modifications to the code before")
-            print("updating to the newest changeset.")
-            print()
+            _print_failed_source_update(opts.reinstall)
 
 class YTUploadImageCmd(YTCommand):
     args = (dict(short="file", type=str),)


https://bitbucket.org/yt_analysis/yt/commits/27481b513244/
Changeset:   27481b513244
Branch:      yt
User:        xarthisius
Date:        2016-04-20 18:09:43+00:00
Summary:     Merged in ngoldbaum/yt (pull request #2129)

Make "yt update" and "yt version" behave more nicely on conda
Affected #:  2 files

diff -r 116dd39ae554e73c9b45718afee7c4f5cf593ff2 -r 27481b513244c9c7bb15578ed5381a812983e567 yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -551,9 +551,13 @@
         print("Updating and precise version information requires ")
         print("python-hglib to be installed.")
         print("Try: pip install python-hglib")
-        return -1
-    repo = hglib.open(path)
-    return repo.identify()
+        return None
+    try:
+        repo = hglib.open(path)
+        return repo.identify()
+    except hglib.error.ServerError:
+        # path is not an hg repository
+        return None
 
 def get_yt_version():
     try:
@@ -564,8 +568,11 @@
     import pkg_resources
     yt_provider = pkg_resources.get_provider("yt")
     path = os.path.dirname(yt_provider.module_path)
-    version = get_hg_version(path)[:12]
-    return version
+    version = get_hg_version(path)
+    if version is None:
+        return version
+    else:
+        return version[:12].strip().decode('utf-8')
 
 def get_version_stack():
     version_info = {}

diff -r 116dd39ae554e73c9b45718afee7c4f5cf593ff2 -r 27481b513244c9c7bb15578ed5381a812983e567 yt/utilities/command_line.py
--- a/yt/utilities/command_line.py
+++ b/yt/utilities/command_line.py
@@ -32,6 +32,7 @@
 from yt.funcs import \
     ensure_list, \
     get_hg_version, \
+    get_yt_version, \
     mylog, \
     ensure_dir_exists, \
     update_hg, \
@@ -74,6 +75,48 @@
     if "longname" in argc: argnames.append(argc.pop('longname'))
     sc.add_argument(*argnames, **argc)
 
+def _print_failed_source_update(reinstall=False):
+    print()
+    print("The yt package is not installed from a mercurial repository,")
+    print("so you must update this installation manually.")
+    if 'Continuum Analytics' in sys.version or 'Anaconda' in sys.version:
+        # see http://stackoverflow.com/a/21318941/1382869 for why we need
+        # to check both Continuum *and* Anaconda
+        print()
+        print("Since it looks like you are using a python installation")
+        print("that is managed by conda, you may want to do:")
+        print()
+        print("    $ conda update yt")
+        print()
+        print("to update your yt installation.")
+        if reinstall is True:
+            print()
+            print("To update all of your packages, you can do:")
+            print()
+            print("    $ conda update --all")
+
+def _print_installation_information(path):
+    import yt
+    print()
+    print("yt module located at:")
+    print("    %s" % (path))
+    if "YT_DEST" in os.environ:
+        spath = os.path.join(
+            os.environ["YT_DEST"], "src", "yt-supplemental")
+        if os.path.isdir(spath):
+            print("The supplemental repositories are located at:")
+            print("    %s" % (spath))
+    print()
+    print("The current version of yt is:")
+    print()
+    print("---")
+    print("Version = %s" % yt.__version__)
+    vstring = get_hg_version(path)
+    if vstring is not None:
+        print("Changeset = %s" % vstring.strip().decode("utf-8"))
+    print("---")
+    return vstring
+
 class YTCommandSubtype(type):
     def __init__(cls, name, b, d):
         type.__init__(cls, name, b, d)
@@ -334,6 +377,13 @@
 def _update_yt_stack(path):
     "Rerun the install script to updated all dependencies."
 
+    if "YT_DEST" not in os.environ:
+        print()
+        print("This yt installation does not appear to be managed by the")
+        print("source-based install script, but 'update --all' was specified.")
+        print("You will need to update your dependencies manually.")
+        return
+
     install_script = os.path.join(path, "doc/install_script.sh")
     if not os.path.exists(install_script):
         print()
@@ -361,19 +411,6 @@
         print("The yt stack has been updated successfully.")
         print("Now get back to work!")
 
-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)
-    return version
-
 # This code snippet is modified from Georg Brandl
 def bb_apicall(endpoint, data, use_pass = True):
     uri = 'https://api.bitbucket.org/1.0/%s/' % endpoint
@@ -605,43 +642,17 @@
 
     def __call__(self, opts):
         import pkg_resources
-        import yt
         yt_provider = pkg_resources.get_provider("yt")
         path = os.path.dirname(yt_provider.module_path)
-        print()
-        print("yt module located at:")
-        print("    %s" % (path))
-        if "YT_DEST" in os.environ:
-            spath = os.path.join(
-                     os.environ["YT_DEST"], "src", "yt-supplemental")
-            if os.path.isdir(spath):
-                print("The supplemental repositories are located at:")
-                print("    %s" % (spath))
-        vstring = get_yt_version()
-        if vstring == -1:
-            vstring = "unknown"
+        vstring = _print_installation_information(path)
         if vstring is not None:
-            print()
-            print("The current version and changeset for the code is:")
-            print()
-            print("---")
-            print("Version = %s" % yt.__version__)
-            print("Changeset = %s" % vstring.strip().decode("utf-8"))
-            print("---")
-            print()
-            if "site-packages" not in path:
-                print("This installation CAN be automatically updated.")
-                if opts.update_source:
-                    update_hg(path)
-                    print("Updated successfully.")
+            print("This installation CAN be automatically updated.")
+            if opts.update_source:
+                update_hg(path)
+                print("Updated successfully.")
                 _get_yt_stack_date()
         elif opts.update_source:
-            print()
-            print("YT site-packages not in path, so you must")
-            print("update this installation manually by committing and")
-            print("merging your modifications to the code before")
-            print("updating to the newest changeset.")
-            print()
+            _print_failed_source_update()
         if vstring is not None and opts.outputfile is not None:
             open(opts.outputfile, "w").write(vstring)
 
@@ -1024,28 +1035,10 @@
 
     def __call__(self, opts):
         import pkg_resources
-        import yt
         yt_provider = pkg_resources.get_provider("yt")
         path = os.path.dirname(yt_provider.module_path)
-        print()
-        print("yt module located at:")
-        print("    %s" % (path))
-        if "YT_DEST" in os.environ:
-            spath = os.path.join(
-                     os.environ["YT_DEST"], "src", "yt-supplemental")
-            if os.path.isdir(spath):
-                print("The supplemental repositories are located at:")
-                print("    %s" % (spath))
-        vstring = None
-        if "site-packages" not in path:
-            vstring = get_hg_version(path)
-            print()
-            print("The current version and changeset for the code is:")
-            print()
-            print("---")
-            print("Version = %s" % yt.__version__)
-            print("Changeset = %s" % vstring.strip().decode("utf-8"))
-            print("---")
+        vstring = _print_installation_information(path)
+        if vstring is not None:
             print()
             print("This installation CAN be automatically updated.")
             update_hg(path, skip_rebuild=opts.reinstall)
@@ -1054,12 +1047,7 @@
             if opts.reinstall:
                 _update_yt_stack(path)
         else:
-            print()
-            print("YT site-packages not in path, so you must")
-            print("update this installation manually by committing and")
-            print("merging your modifications to the code before")
-            print("updating to the newest changeset.")
-            print()
+            _print_failed_source_update(opts.reinstall)
 
 class YTUploadImageCmd(YTCommand):
     args = (dict(short="file", type=str),)

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-svn-spacepope.org/attachments/20160420/523657f9/attachment.html>


More information about the yt-svn mailing list