diff --git a/doc/source/conf.py b/doc/source/conf.py index b931088..b7600f0 100755 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -19,7 +19,8 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath('../..')) +sys.path.insert(0, normpath(abspath(join(dirname(__file__), '..', '..')))) +import isotp # -- General configuration ------------------------------------------------ @@ -60,9 +61,9 @@ # built documents. # # The short X.Y version. -version = u'2.0' +version = '.'.join(isotp.__version__.split('.')[0:2]) # The full version, including alpha/beta/rc tags. -release = version +release = isotp.__version__ # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/isotp/__init__.py b/isotp/__init__.py index 69b7bcf..23fc363 100755 --- a/isotp/__init__.py +++ b/isotp/__init__.py @@ -38,3 +38,7 @@ from isotp.address import AddressingMode, TargetAddressType, Address, AsymmetricAddress from isotp.protocol import TransportLayerLogic, TransportLayer, CanStack, NotifierBasedCanStack from isotp.tpsock import socket + +__version__ = '2.0.5' +__license__ = 'MIT' +__author__ = 'Pier-Yves Lessard' diff --git a/scripts/release.sh b/scripts/release.sh new file mode 100755 index 0000000..d8b5eed --- /dev/null +++ b/scripts/release.sh @@ -0,0 +1,43 @@ +#!/bin/bash +set -eEuo pipefail +PROJECT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. >/dev/null 2>&1 && pwd -P )" +cd "$PROJECT_ROOT" + +RED='\033[0;31m'; CYAN='\033[0;36m'; YELLOW='\033[1;33m'; NC='\033[0m' + +info() { >&2 echo -e "$CYAN[Info]$NC $1";} +warn() { >&2 echo -e "$YELLOW[Warning]$NC $1";} +error() { >&2 echo -e "$RED[Error]$NC $1"; } +fatal() { >&2 echo -e "$RED[Fatal]$NC $1"; exit ${2:-1}; } + +trap 'fatal "Exited with status $? at line $LINENO"' ERR + +[ -z ${1:+x} ] && fatal "Missing version argument" + +version=$1 + +git_diff=$(git diff --shortstat) +git_diff_cached=$(git diff --shortstat --cached) + +[ -z $git_diff ] || fatal "Uncomitted changes on repo" +[ -z $git_diff_cached ] || fatal "Staging changes on repo" + +tag=$( { git tag -l --points-at HEAD || true; } | { grep $version || true; }) +code_version=$(cat isotp/__init__.py | grep __version__ | sed -r "s/__version__[[:space:]]*=[[:space:]]*[']([^']+)'/\1/") +code_version=$(echo $code_version | tr -d '\r') + +[ "$version" != "$tag" ] && fatal "Tag of HEAD does not match given version. Expected $version" +[ "$version" != "v$code_version" ] && fatal "Code version does not match given version : v$code_version vs $version" + +rm -rf build dist *.egg-info +python3 -m build + +read -p "Everything seems alright. Upload? " + +proceed=0 + +[ "${REPLY,,}" == "yes" ] && proceed=1 +[ "${REPLY,,}" == "y" ] && proceed=1 + +[ $proceed -ne 1 ] && { info "Not uploading"; exit; } +python3 -m twine upload dist/* diff --git a/setup.py b/setup.py index 28ab6a6..a3ef3ad 100755 --- a/setup.py +++ b/setup.py @@ -1,8 +1,11 @@ from setuptools import setup, find_packages from codecs import open from os import path +import sys here = path.abspath(path.dirname(__file__)) +sys.path.insert(0, here) +import isotp with open(path.join(here, 'README.rst'), encoding='utf-8') as f: long_description = f.read() @@ -13,7 +16,7 @@ package_data={ 'isotp' : ['py.typed'] }, - version='2.0.4', + version=isotp.__version__, extras_require={ 'test': ['mypy', 'coverage', 'python-can'], 'dev': ['mypy', 'ipdb', 'autopep8', 'coverage', 'python-can'] @@ -24,7 +27,7 @@ author_email='py.lessard@gmail.com', license='MIT', url='https://github.com/pylessard/python-can-isotp', - download_url='https://github.com/pylessard/python-can-isotp/archive/v2.0.4.tar.gz', + download_url=f'https://github.com/pylessard/python-can-isotp/archive/v{isotp.__version__}.tar.gz', keywords=['isotp', 'can', 'iso-15765', '15765', 'iso15765'], python_requires='>=3.7', classifiers=[