[med-svn] [Git][med-team/pyscanfcs][upstream] New upstream version 0.3.6+ds

Steffen Möller gitlab at salsa.debian.org
Mon Jun 29 23:44:41 BST 2020



Steffen Möller pushed to branch upstream at Debian Med / pyscanfcs


Commits:
96db1a80 by Steffen Moeller at 2020-06-30T00:30:53+02:00
New upstream version 0.3.6+ds
- - - - -


6 changed files:

- + .github/FUNDING.yml
- CHANGELOG
- pyscanfcs/_version.py
- pyscanfcs/gui_wx/doc.py
- pyscanfcs/openfile.py
- setup.py


Changes:

=====================================
.github/FUNDING.yml
=====================================
@@ -0,0 +1,2 @@
+github: paulmueller
+liberapay: paulmueller


=====================================
CHANGELOG
=====================================
@@ -1,3 +1,5 @@
+0.3.6
+ - setup: change dependency of scikit-image to tifffile 2020.5.25
 0.3.5
  - maintenance release
 0.3.4


=====================================
pyscanfcs/_version.py
=====================================
@@ -1,20 +1,56 @@
 #!/usr/bin/env python
-"""Determine package version for git repositories from tags
-
-Each time this file is imported it checks if the ".git" folder is
-present and if so, obtains the version from the git history using
-`git describe`. This information is then stored in the file
-`_version_save.py` which is not versioned by git, but distributed
-along e.g. on PyPI.
+"""Determine package version from git repository tag
+
+Each time this file is imported it checks whether the package version
+can be determined using `git describe`. If this fails (because either
+this file is not located at the 1st level down the repository root or
+it is not under version control), the version is read from the script
+"_version_save.py" which is not versioned by git, but always included
+in the final distribution archive (e.g. via PyPI). If the git version
+does not match the saved version, then "_version_save.py" is updated.
+
+
+Usage
+-----
+1. Put this file in your main module directory:
+
+    REPO_ROOT/package_name/_version.py
+
+2. Add this line to REPO_ROOT/package_name/__init__.py
+
+    from ._version import version as __version__  # noqa: F401
+
+3. (Optional) Add this line to REPO_ROOT/.gitignore
+
+    _version_save.py
+
+Features
+--------
+- supports Python 2 and 3
+- supports frozen applications (e.g. PyInstaller)
+- supports installing into a virtual environment that is located in
+  a git repository
+- saved version is located in a python file and therefore no other
+  files (e.g. MANIFEST.in) need be edited
+- fallback version is the creation date
+- excluded from code coverage via "pragma: no cover"
+
+Changelog
+---------
+2019-11-06.2
+ - use os.path.split instead of counting os.path.sep (Windows)
+2019-11-06
+ - remove deprecated imp dependency (replace with parser)
+ - check whether this file is versioned and its location is correct
+ - code cleanup and docs update
 """
 from __future__ import print_function
 
 # Put the entire script into a `True` statement and add the hint
 # `pragma: no cover` to ignore code coverage here.
 if True:  # pragma: no cover
-    import imp
     import os
-    from os.path import abspath, basename, dirname, join
+    from os.path import abspath, basename, dirname, join, split
     import subprocess
     import sys
     import time
@@ -33,7 +69,7 @@ if True:  # pragma: no cover
         ourdir = dirname(abspath(__file__))
 
         def _minimal_ext_cmd(cmd):
-            # construct minimal environment
+            # Construct minimal environment
             env = {}
             for k in ['SYSTEMROOT', 'PATH']:
                 v = os.environ.get(k)
@@ -48,19 +84,33 @@ if True:  # pragma: no cover
                                    stderr=subprocess.PIPE,
                                    env=env)
             out = pop.communicate()[0]
-            return out
+            return out.strip().decode('ascii', errors="ignore")
 
         # change directory
         olddir = abspath(os.curdir)
         os.chdir(ourdir)
 
+        # Make sure that we are getting "git describe" from our own
+        # repository (and not from a repository where we just happen
+        # to be in the directory tree).
+        git_revision = ""
         try:
-            out = _minimal_ext_cmd(['git', 'describe', '--tags', 'HEAD'])
-            git_revision = out.strip().decode('ascii')
+            # If this file is not under version control, "loc" will
+            # be empty.
+            loc = _minimal_ext_cmd(['git', 'ls-files', '--full-name',
+                                    __file__])
+            # If it is under version control, it should be located
+            # one hierarchy down from the repository root (either
+            # __file__ is "docs/conf.py" or "package_name/_version.py".
+            if len(split(loc)) == 2:
+                try:
+                    git_revision = _minimal_ext_cmd(['git', 'describe',
+                                                     '--tags', 'HEAD'])
+                except OSError:
+                    pass
         except OSError:
-            git_revision = ""
-
-        # go back to original directory
+            pass
+        # Go back to original directory
         os.chdir(olddir)
 
         return git_revision
@@ -69,8 +119,11 @@ if True:  # pragma: no cover
         """load version from version_save.py"""
         longversion = ""
         try:
-            _version_save = imp.load_source("_version_save", versionfile)
-            longversion = _version_save.longversion
+            with open(versionfile, "r") as fd:
+                data = fd.readlines()
+                for line in data:
+                    if line.startswith("longversion"):
+                        longversion = line.split("=")[1].strip().strip("'")
         except BaseException:
             try:
                 from ._version_save import longversion
@@ -82,7 +135,7 @@ if True:  # pragma: no cover
 
         return longversion
 
-    def save_version(version, versionfile):
+    def write_version(version, versionfile):
         """save version to version_save.py"""
         data = "#!/usr/bin/env python\n" \
             + "# This file was created automatically\n" \
@@ -91,8 +144,11 @@ if True:  # pragma: no cover
             with open(versionfile, "w") as fd:
                 fd.write(data.format(VERSION=version))
         except BaseException:
-            msg = "Could not write package version to {}.".format(versionfile)
-            warnings.warn(msg)
+            if not os.path.exists(versionfile):
+                # Only issue a warning if the file does not exist.
+                msg = "Could not write package version to {}.".format(
+                    versionfile)
+                warnings.warn(msg)
 
     hdir = dirname(abspath(__file__))
     if basename(__file__) == "conf.py" and "name" in locals():
@@ -116,7 +172,7 @@ if True:  # pragma: no cover
 
     # 2. previously created version file
     if longversion == "":
-        # Either this is this is not a git repository or we are in the
+        # Either this is not a git repository or we are in the
         # wrong git repository.
         # Get the version from the previously generated `_version_save.py`
         longversion = load_version(versionfile)
@@ -135,7 +191,7 @@ if True:  # pragma: no cover
         # This is only done if the program is not frozen (with e.g.
         # pyinstaller),
         if longversion != load_version(versionfile):
-            save_version(longversion, versionfile)
+            write_version(longversion, versionfile)
 
     # PEP 440-conform development version:
     version = ".post".join(longversion.split("-")[:2])


=====================================
pyscanfcs/gui_wx/doc.py
=====================================
@@ -8,7 +8,7 @@ import matplotlib
 import multipletau
 import numpy
 import scipy
-import skimage
+import tifffile
 import wx
 
 
@@ -108,8 +108,8 @@ def SoftwareUsed():
            "\n - matplotlib " + matplotlib.__version__ +\
            "\n - multipletau " + multipletau.__version__ +\
            "\n - NumPy " + numpy.__version__ +\
-           "\n - scikit-image " + skimage.__version__ +\
            "\n - SciPy " + scipy.__version__ +\
+           "\n - tifffile " + tifffile.__version__ +\
            "\n - wxPython " + wx.__version__
     if hasattr(sys, 'frozen'):
         pyinst = "\n\nThis executable has been created using PyInstaller."


=====================================
pyscanfcs/openfile.py
=====================================
@@ -1,7 +1,7 @@
 """filetype definitions"""
 import astropy.io.fits
 import numpy as np
-from skimage.external import tifffile
+import tifffile
 
 
 def openAny(path, callback=None):


=====================================
setup.py
=====================================
@@ -68,8 +68,8 @@ setup(
         "matplotlib>=1.1.0",
         "multipletau>=0.1.4",
         "numpy>=1.5.1",
-        "scikit-image>=0.13.1",
         "scipy>=0.8.0",
+        "tifffile>=2020.5.25",
         "wxpython>=4.0.3",
         ],
     setup_requires=['cython', 'numpy', 'pytest-runner'],



View it on GitLab: https://salsa.debian.org/med-team/pyscanfcs/-/commit/96db1a801938caef2b0fa16b22b7ee73e9a63ec9

-- 
View it on GitLab: https://salsa.debian.org/med-team/pyscanfcs/-/commit/96db1a801938caef2b0fa16b22b7ee73e9a63ec9
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20200629/50eba1db/attachment-0001.html>


More information about the debian-med-commit mailing list