From 6c860b15316e27595749dca5ea44775e3d9e4763 Mon Sep 17 00:00:00 2001 From: Alex Henderson Date: Sat, 5 Mar 2022 18:00:03 +0000 Subject: [PATCH] Released to PyPI. Version bumped to 1.1.0. Released to PyPI. Version number bumped to v1.1.0. Version number now available as a static function. --- CITATION.cff | 6 +++--- README.md | 18 ++++++++++++------ pyproject.toml | 6 ++++++ requirements.txt | 2 ++ setup.py | 31 +++++++++++++++++++++++++++++++ src/hasher/hasher.py | 22 ++++++++++++++++++---- 6 files changed, 72 insertions(+), 13 deletions(-) create mode 100644 pyproject.toml create mode 100644 requirements.txt create mode 100644 setup.py diff --git a/CITATION.cff b/CITATION.cff index 93ea994..b4b39c1 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -9,8 +9,8 @@ authors: affiliation: University of Manchester, UK email: alex.henderson@manchester.ac.uk website: https://alexhenderson.info -version: v1.0.0 -date-released: "2022-02-09" +version: v1.1.0 +date-released: "2022-03-05" license: MIT license-url: https://spdx.org/licenses/MIT#licenseText -repository: "https://github.com/AlexHenderson/hasher/" +repository: "https://github.com/AlexHenderson/hasher" diff --git a/README.md b/README.md index 7d8bd89..55fe1bd 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,7 @@ Python package to generate a stable hash value for either a single file, or a folder containing many files and sub-folders. -Requires Python 3.7 or higher. - -Features: +## Features ## - The default hash type is `sha256`, although the user can specify any valid hash type provided by `hashlib`. - A single hash is generated from a folder, regardless of how many files and sub-folders it contains. - For a single file, the filename can be included into the hash if required (default is not to include). @@ -108,11 +106,19 @@ output hash name: md5 hash digest: f2865fa......6679c3 +## Requirements ## + + python >= 3.7 + pytest + +### Installation ### + + pip install hasher-AlexHenderson==1.1.0 + ## Usage rights ## Copyright (c) 2022 Alex Henderson (alex.henderson@manchester.ac.uk) Licensed under the MIT License. See https://opensource.org/licenses/MIT SPDX-License-Identifier: MIT -Version 1.0.0 -See https://github.com/AlexHenderson/hasher/ for the most recent version - +Version 1.1.0 +See https://github.com/AlexHenderson/hasher for the most recent version diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..374b58c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,6 @@ +[build-system] +requires = [ + "setuptools>=42", + "wheel" +] +build-backend = "setuptools.build_meta" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..75fd60e --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +pytest~=7.0.1 +setuptools~=60.9.3 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..7be0311 --- /dev/null +++ b/setup.py @@ -0,0 +1,31 @@ +from setuptools import setup, find_packages + + +with open("README.md", "r", encoding="utf-8") as fh: + long_description = fh.read() + +setup( + name="hasher-AlexHenderson", + version="1.1.0", + author="Alex Henderson", + author_email="alex.henderson@manchester.ac.uk", + description="Python package to generate a stable hash value for either a single file, or a folder containing many " + "files and sub-folders.", + long_description=long_description, + long_description_content_type="text/markdown", + url="https://github.com/AlexHenderson/hasher", + project_urls={ + "Bug Tracker": "https://github.com/AlexHenderson/hasher/issues", + }, + classifiers=[ + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + ], + package_dir={"": "src"}, + packages=find_packages(where="src"), + python_requires=">=3.7", +) diff --git a/src/hasher/hasher.py b/src/hasher/hasher.py index 6a814b1..b04dd1a 100644 --- a/src/hasher/hasher.py +++ b/src/hasher/hasher.py @@ -2,7 +2,7 @@ # Copyright (c) 2022 Alex Henderson (alex.henderson@manchester.ac.uk) # Licensed under the MIT License. See https://opensource.org/licenses/MIT # SPDX-License-Identifier: MIT -# Version 1.0.0 +# Version 1.1.0 # See https://github.com/AlexHenderson/hasher for the most recent version import hashlib @@ -61,14 +61,28 @@ class Hasher: Copyright (c) 2022 Alex Henderson (alex.henderson@manchester.ac.uk) Licensed under the MIT License. See https://opensource.org/licenses/MIT SPDX-License-Identifier: MIT - Version 1.0.0 + Version 1.1.0 See https://github.com/AlexHenderson/hasher for the most recent version """ + # Define the version of this code + _version = "1.1.0" + # Define the default type of hash as 'sha256' _default_hash_type = 'sha256' + @classmethod + def version(cls) -> str: + """ + Returns the version number of this code. + + :return: The version number. + :rtype: str + """ + + return Hasher._version + @classmethod def default_hash_type(cls) -> str: """ @@ -77,7 +91,7 @@ def default_hash_type(cls) -> str: :return: The default hash type. :rtype: str """ - + return Hasher._default_hash_type @classmethod @@ -189,7 +203,7 @@ def generate(self, logging.info(f"Hasher >>>>>>") # Log the version of this source code - logging.info(f"Version: 1.0.0") + logging.info(f"Version: {Hasher._version}") try: # Normalise input