diff --git a/README.rst b/README.rst index 3991498..19fe247 100644 --- a/README.rst +++ b/README.rst @@ -56,8 +56,7 @@ Install:: $ python3 -m venv .venv $ . .venv/bin/activate - (.venv)$ pip install -e . - (.venv)$ pip install -r tests/test_requirements.txt + (.venv)$ pip install -e .[test] Run:: @@ -75,6 +74,13 @@ Run:: Change Log ---------- +1.0.1 +~~~~~ + +* officially remove Python 2 support that was broken since 1.0.0 + anyway; now the package works with Python 3.8+ because of a few + features + 1.0.0 ~~~~~ diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..11ff6b6 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,34 @@ +[build-system] +requires = ["setuptools", "setuptools-scm[toml]"] +build-backend = "setuptools.build_meta" + +[project] +name = "bitrot" +authors = [ + {name = "Łukasz Langa", email = "lukasz@langa.pl"}, +] +description = "Detects bit rotten files on the hard drive to save your precious photo and music collection from slow decay." +readme = "README.rst" +requires-python = ">=3.8" +keywords = ["file", "checksum", "database"] +license = {text = "MIT"} +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Natural Language :: English", + "Programming Language :: Python :: 3", + "Topic :: System :: Filesystems", + "Topic :: System :: Monitoring", + "Topic :: Software Development :: Libraries :: Python Modules", + +] +dependencies = [] +dynamic = ["version"] + +[project.optional-dependencies] +test = ["pytest", "pytest-order"] + +[project.scripts] +bitrot = "bitrot:run_from_command_line" + +[tool.setuptools_scm] +tag_regex = "^(?Pv\\d+(?:\\.\\d+){0,2}[^\\+]*)(?:\\+.*)?$" diff --git a/setup.py b/setup.py deleted file mode 100644 index 8abc00f..0000000 --- a/setup.py +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# Copyright (C) 2013 by Łukasz Langa -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: - -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. - -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. - -import codecs -import os -import sys -from setuptools import setup, find_packages - -current_dir = os.path.abspath(os.path.dirname(__file__)) -ld_file = codecs.open(os.path.join(current_dir, 'README.rst'), encoding='utf8') -try: - long_description = ld_file.read() -finally: - ld_file.close() -# We let it die a horrible tracebacking death if reading the file fails. -# We couldn't sensibly recover anyway: we need the long description. - -sys.path.insert(0, current_dir + os.sep + 'src') -from bitrot import VERSION -release = ".".join(str(num) for num in VERSION) - -setup( - name = 'bitrot', - version = release, - author = u'Łukasz Langa', - author_email = 'lukasz@langa.pl', - description = ("Detects bit rotten files on the hard drive to save your " - "precious photo and music collection from slow decay."), - long_description = long_description, - url = 'https://github.com/ambv/bitrot/', - keywords = 'file checksum database', - platforms = ['any'], - license = 'MIT', - package_dir = {'': 'src'}, - packages = find_packages('src'), - py_modules = ['bitrot'], - scripts = ['bin/bitrot'], - include_package_data = True, - zip_safe = False, # if only because of the readme file - install_requires = [ - 'futures; python_version == "2.7"' - ], - classifiers = [ - 'Development Status :: 4 - Beta', - 'License :: OSI Approved :: MIT License', - 'Natural Language :: English', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python', - 'Topic :: System :: Filesystems', - 'Topic :: System :: Monitoring', - 'Topic :: Software Development :: Libraries :: Python Modules', - ] - ) diff --git a/src/bitrot.py b/src/bitrot.py index 8e49249..94b710b 100755 --- a/src/bitrot.py +++ b/src/bitrot.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- +#!/usr/bin/env python3 # Copyright (C) 2013 by Łukasz Langa @@ -21,10 +20,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals +from __future__ import annotations import argparse import atexit @@ -41,18 +37,17 @@ import time import unicodedata from concurrent.futures import ProcessPoolExecutor, as_completed +from importlib.metadata import version, PackageNotFoundError DEFAULT_CHUNK_SIZE = 16384 # block size in HFS+; 4X the block size in ext4 DOT_THRESHOLD = 200 -VERSION = (1, 0, 0) IGNORED_FILE_SYSTEM_ERRORS = {errno.ENOENT, errno.EACCES} FSENCODING = sys.getfilesystemencoding() - - -if sys.version[0] == '2': - str = type(u'text') - # use `bytes` for bytestrings +try: + VERSION = version("bitrot") +except PackageNotFoundError: + VERSION = "1.0.1" def normalize_path(path): @@ -545,7 +540,7 @@ def run_from_command_line(): help='just test against an existing database, don\'t update anything') parser.add_argument( '--version', action='version', - version='%(prog)s {}.{}.{}'.format(*VERSION)) + version=f"%(prog)s {VERSION}") parser.add_argument( '--commit-interval', type=float, default=300, help='min time in seconds between commits ' diff --git a/tests/test_bitrot.py b/tests/test_bitrot.py index c41cbba..35abb5c 100644 --- a/tests/test_bitrot.py +++ b/tests/test_bitrot.py @@ -2,6 +2,8 @@ NOTE: those tests are ordered and require pytest-order to run correctly. """ +from __future__ import annotations + import getpass import os from pathlib import Path