From 30ac18a434a4a3981ff0ae1c8737db3d6609808c Mon Sep 17 00:00:00 2001 From: Daniel Lenski Date: Sat, 6 Apr 2024 09:02:39 -0700 Subject: [PATCH] Modernize setup.py a bit, call it v0.4 --- __version__.py | 3 +-- setup.py | 60 ++++++++++++++++++-------------------------------- 2 files changed, 22 insertions(+), 41 deletions(-) diff --git a/__version__.py b/__version__.py index fc07b79..7c5fcbc 100644 --- a/__version__.py +++ b/__version__.py @@ -1,2 +1 @@ -# Do not edit this file, versioning is governed by git tags -__version__="0.3" +__version__="0.4" diff --git a/setup.py b/setup.py index bee1d73..32c6243 100755 --- a/setup.py +++ b/setup.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 -import sys, os, re, subprocess as sp +import sys +from os import path from setuptools import setup if not sys.version_info[0] == 3: @@ -8,45 +9,26 @@ ######################################## -# Based on this recipe, adapted for Python 3, Git 2.8.x, and PEP-440 version identifiers -# http://blogs.nopcode.org/brainstorm/2013/05/20/pragmatic-python-versioning-via-setuptools-and-git-tags/ -# https://www.python.org/dev/peps/pep-0440/#version-scheme +version_py = path.join(path.dirname(__file__), '__version__.py') -# Fetch version from git tags, and write to version.py. -# Also, when git is not available (PyPi package), use stored version.py. -version_py = os.path.join(os.path.dirname(__file__), '__version__.py') - -try: - version_git = sp.check_output(["git", "describe", "--tags", "--dirty=_dirty"]).strip().decode('ascii') - final, dev, blob, dirty = re.match(r'v?((?:\d+\.)*\d+)(?:-(\d+)-(g[a-z0-9]+))?(_dirty)?', version_git).groups() - version_pep = final+('.dev%s+%s'%(dev,blob) if dev else '')+(dirty if dirty else '') -except: - d = {} - with open(version_py, 'r') as fh: - exec(fh.read(), d) - version_pep = d['__version__'] -else: - with open(version_py, 'w') as fh: - print("# Do not edit this file, versioning is governed by git tags", file=fh) - print('__version__="%s"' % version_pep, file=fh) +d = {} +with open(version_py, 'r') as fh: + exec(fh.read(), d) + version_pep = d['__version__'] ######################################## -README = os.path.join(os.path.dirname(__file__), 'README.md') -try: - long_description = open(README).read() -except FileNotFoundError: - long_description = '' - -setup(name="motoflash2sh", - version=version_pep, - description=("Convert Motorola flashfile.xml to fastboot shell script"), - long_description=long_description, - author="Daniel Lenski", - author_email="dlenski@gmail.com", - license='GPL v3 or later', - url="https://github.com/dlenski/motoflash2sh", - build_requires=[ 'requests>=2.0' ], - py_modules=[ 'motoflash2sh' ], - entry_points={ 'console_scripts': [ 'motoflash2sh=motoflash2sh:main' ] } - ) +setup( + name="motoflash2sh", + version=version_pep, + description=("Convert Motorola flashfile.xml to fastboot shell script"), + long_description=open('README.md', encoding='utf-8').read(), + long_description_content_type='text/markdown', + author="Daniel Lenski", + author_email="dlenski@gmail.com", + license='GPL v3 or later', + url="https://github.com/dlenski/motoflash2sh", + py_modules=[ 'motoflash2sh' ], + entry_points={ 'console_scripts': [ 'motoflash2sh=motoflash2sh:main' ] }, + python_requires=">=3", +)