[med-svn] [Git][med-team/python-scitrack][upstream] New upstream version 2021.5.3
Nilesh Patra (@nilesh)
gitlab at salsa.debian.org
Sun Aug 8 20:39:00 BST 2021
Nilesh Patra pushed to branch upstream at Debian Med / python-scitrack
Commits:
ff1dc2ab by Nilesh Patra at 2021-08-09T00:44:20+05:30
New upstream version 2021.5.3
- - - - -
9 changed files:
- .github/workflows/testing_develop.yml
- .hgtags
- README.rst
- pyproject.toml
- − setup.cfg
- − setup.py
- src/scitrack/__init__.py
- tests/test_logging.py
- tox.ini
Changes:
=====================================
.github/workflows/testing_develop.yml
=====================================
@@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
- python-version: [3.6, 3.7, 3.8]
+ python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- uses: "actions/checkout at v2"
@@ -25,13 +25,13 @@ jobs:
run: |
python -VV
python -m site
- python -m pip install --upgrade pip setuptools wheel
+ python -m pip install --upgrade pip setuptools wheel flit
python -m pip install --upgrade tox tox-gh-actions
- name: "Run tox targets for ${{ matrix.python-version }}"
run: "python -m tox"
- - name: Upload py3.8 coverage to Codecov
+ - name: Upload coverage to Codecov
uses: codecov/codecov-action at v1
with:
file: ./tests/junit-*.xml
=====================================
.hgtags
=====================================
@@ -2,3 +2,4 @@
402b7daea661f3904f85f6f248f46c8d9f588704 0.1.7
038183f48645c7ba0417fa98946689f86efca803 0.1.8
d8aa7076747c991858750c0ecfa5915c6d421d5f 0.1.8.1
+d223af41764757c47b24f6594a4597818f18e785 2020.6.5
=====================================
README.rst
=====================================
@@ -66,6 +66,10 @@ Creating the logger. Setting ``create_dir=True`` means on creation of the logfil
The last assignment triggers creation of ``somedir/some_path.log``.
+.. warning::
+
+ Once set, a loggers ``.log_file_path`` cannot be changed.
+
******************************************
Capturing a programs arguments and options
******************************************
@@ -74,6 +78,10 @@ Capturing a programs arguments and options
Here's one approach to incorporating ``scitrack`` into a command line application built using the ``click`` `command line interface library <http://click.pocoo.org/>`_. Below we create a simple ``click`` app and capture the required and optional argument values.
+.. note::
+
+ ``LOGGER.log_args()`` should be called immediately after the function definition, or after "true" default values have been configured.
+
.. code:: python
import click
@@ -137,4 +145,20 @@ Reporting issues
Use the project `issue tracker <https://github.com/HuttleyLab/scitrack/issues>`_.
+**************
+For Developers
+**************
+
+We use flit_ for package building. Having cloned the repository onto your machine. Install ``flit``::
+
+$ python3 -m pip install flit
+
+Do a developer install of ``scitrack`` using flit as::
+
+$ cd path/to/cloned/repo
+$ flit install -s --python `which python`
+
+.. note:: This installs a symlink into ``site-packages`` of the python identified by ``which python``.
+
.. [1] The hexdigest serves as a unique signature of a files contents.
+.. _flit: https://flit.readthedocs.io/en/latest/
\ No newline at end of file
=====================================
pyproject.toml
=====================================
@@ -1,6 +1,46 @@
[build-system]
-requires = ["setuptools>=40.6.0", "wheel"]
-build-backend = "setuptools.build_meta"
+requires = ["flit_core >=2,<4"]
+build-backend = "flit_core.buildapi"
+
+[tool.flit.metadata]
+module = "scitrack"
+author = "Gavin Huttley"
+author-email = "Gavin.Huttley at anu.edu.au"
+home-page = "https://github.com/HuttleyLab/scitrack"
+license = "BSD-3"
+description-file = "README.rst"
+keywords = "science, logging"
+classifiers = [
+ "Development Status :: 4 - Beta",
+ "Intended Audience :: Science/Research",
+ "License :: OSI Approved :: BSD License",
+ "Topic :: Scientific/Engineering :: Bio-Informatics",
+ "Topic :: Software Development :: Libraries :: Python Modules",
+ "Operating System :: OS Independent",
+ "Programming Language :: Python :: 3.6",
+ "Programming Language :: Python :: 3.7",
+ "Programming Language :: Python :: 3.8",
+ "Programming Language :: Python :: 3.9",
+ ]
+requires-python = ">=3.6"
+
+[tool.flit.sdist]
+include = ["src/*", "pyproject.toml", "*.rst"]
+exclude = ["*.xml"]
+
+
+[tool.flit.metadata.urls]
+Documentation = "https://github.com/HuttleyLab/scitrack"
+"Bug Tracker" = "https://github.com/HuttleyLab/scitrack/issues"
+"Source Code" = "https://github.com/HuttleyLab/scitrack"
+
+[tool.flit.metadata.requires-extra]
+test = [
+ "black",
+ "isort",
+ "pytest",
+ "pytest-cov",
+ "tox"]
[tool.black]
line-length = 88
=====================================
setup.cfg deleted
=====================================
@@ -1,2 +0,0 @@
-[bdist_wheel]
-universal = 1
=====================================
setup.py deleted
=====================================
@@ -1,63 +0,0 @@
-#!/usr/bin/env python
-import pathlib
-import sys
-
-from setuptools import find_packages, setup
-
-
-__author__ = "Gavin Huttley"
-__copyright__ = "Copyright 2016-2020, Gavin Huttley"
-__credits__ = ["Gavin Huttley"]
-__license__ = "BSD"
-__version__ = "2020.6.5"
-__maintainer__ = "Gavin Huttley"
-__email__ = "Gavin.Huttley at anu.edu.au"
-__status__ = "Development"
-
-if sys.version_info < (3, 6):
- py_version = ".".join([str(n) for n in sys.version_info])
- raise RuntimeError(
- "Python-3.6 or greater is required, Python-%s used." % py_version
- )
-
-PROJECT_URLS = {
- "Documentation": "https://github.com/HuttleyLab/scitrack",
- "Bug Tracker": "https://github.com/HuttleyLab/scitrack/issues",
- "Source Code": "https://github.com/HuttleyLab/scitrack",
-}
-
-short_description = "scitrack"
-
-readme_path = pathlib.Path(__file__).parent / "README.rst"
-
-long_description = readme_path.read_text()
-
-PACKAGE_DIR = "src"
-
-setup(
- name="scitrack",
- version=__version__,
- author="Gavin Huttley",
- author_email="gavin.huttley at anu.edu.au",
- description=short_description,
- long_description=long_description,
- long_description_content_type="text/x-rst",
- platforms=["any"],
- license=[__license__],
- keywords=["science", "logging"],
- classifiers=[
- "Development Status :: 4 - Beta",
- "Intended Audience :: Science/Research",
- "License :: OSI Approved :: BSD License",
- "Topic :: Scientific/Engineering :: Bio-Informatics",
- "Topic :: Software Development :: Libraries :: Python Modules",
- "Operating System :: OS Independent",
- "Programming Language :: Python :: 3.6",
- "Programming Language :: Python :: 3.7",
- "Programming Language :: Python :: 3.8",
- ],
- packages=find_packages(where="src"),
- package_dir={"": PACKAGE_DIR},
- url="https://github.com/HuttleyLab/scitrack",
- project_urls=PROJECT_URLS,
-)
=====================================
src/scitrack/__init__.py
=====================================
@@ -1,3 +1,6 @@
+"""
+SciTrack provides basic logging capabilities to track scientific computations.
+"""
import hashlib
import importlib
import inspect
@@ -11,10 +14,10 @@ from getpass import getuser
__author__ = "Gavin Huttley"
-__copyright__ = "Copyright 2016-2020, Gavin Huttley"
+__copyright__ = "Copyright 2016-2021, Gavin Huttley"
__credits__ = ["Gavin Huttley"]
__license__ = "BSD"
-__version__ = "2020.6.5"
+__version__ = "2021.5.3"
__maintainer__ = "Gavin Huttley"
__email__ = "Gavin.Huttley at anu.edu.au"
__status__ = "Development"
@@ -112,6 +115,11 @@ class CachingLogger(object):
@log_file_path.setter
def log_file_path(self, path):
"""set the log file path and then dump cached log messages"""
+ if self._log_file_path is not None:
+ raise AttributeError(
+ f"log_file_path already defined as {self._log_file_path}"
+ )
+
path = abspath(path)
if self.create_dir:
dirname = os.path.dirname(path)
@@ -282,11 +290,12 @@ def get_text_hexdigest(data):
'rb' versus 'r' modes.
"""
data_class = data.__class__
+ # fmt: off
if data_class in ("".__class__, u"".__class__):
data = data.encode("utf-8")
elif data.__class__ != b"".__class__:
raise TypeError("can only checksum string, unicode or bytes data")
-
+ # fmt: on
md5 = hashlib.md5()
md5.update(data)
return md5.hexdigest()
=====================================
tests/test_logging.py
=====================================
@@ -18,10 +18,10 @@ from scitrack import (
__author__ = "Gavin Huttley"
-__copyright__ = "Copyright 2016-2020, Gavin Huttley"
+__copyright__ = "Copyright 2016-2021, Gavin Huttley"
__credits__ = ["Gavin Huttley"]
__license__ = "BSD"
-__version__ = "2020.6.5"
+__version__ = "2021.5.3"
__maintainer__ = "Gavin Huttley"
__email__ = "Gavin.Huttley at anu.edu.au"
__status__ = "Development"
@@ -47,6 +47,18 @@ def test_creates_path():
pass
+def test_set_path_if_exists():
+ """cannot change an existing logging path"""
+ with TemporaryDirectory(dir=".") as dirname:
+ dirname = Path(dirname)
+ LOGGER = CachingLogger(create_dir=True)
+ LOGGER.log_file_path = dirname / LOGFILE_NAME
+ LOGGER.input_file(TEST_ROOTDIR / "sample-lf.fasta")
+ with pytest.raises(AttributeError):
+ LOGGER.log_file_path = dirname / "invalid.log"
+ LOGGER.shutdown()
+
+
def test_tracks_args():
"""details on host, python version should be present in log"""
LOGGER = CachingLogger(create_dir=True)
=====================================
tox.ini
=====================================
@@ -1,5 +1,6 @@
[tox]
-envlist = py36, py37, py38
+isolated_build = True
+envlist = py36, py37, py38, py39
[testenv]
passenv = *
@@ -8,6 +9,12 @@ deps = numpy
pytest
pytest-cov
+[testenv:py39]
+changedir = tests
+basepython = python3.9
+commands =
+ pytest --junitxml=junit-{envname}.xml --cov-report xml --cov=scitrack
+
[testenv:py38]
changedir = tests
basepython = python3.8
@@ -31,3 +38,4 @@ python =
3.6: py36
3.7: py37
3.8: py38
+ 3.9: py39
View it on GitLab: https://salsa.debian.org/med-team/python-scitrack/-/commit/ff1dc2ab9e72c3b736b49d402631f813b43e893f
--
View it on GitLab: https://salsa.debian.org/med-team/python-scitrack/-/commit/ff1dc2ab9e72c3b736b49d402631f813b43e893f
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/20210808/8927cd74/attachment-0001.htm>
More information about the debian-med-commit
mailing list