diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 06d140da..8f417a71 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -25,10 +25,13 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + python -m pip install --upgrade build wheel setuptools if python --version 2>&1 | grep -q "Python 2"; then pip install mock rsa==4.0 libusb1==1.9.3; fi python -m pip install flake8 pylint coveralls cryptography libusb1>=1.0.16 pycryptodome if [ -f requirements.txt ]; then pip install -r requirements.txt; fi pip install . + python -m build -nwsx .; + pip install ./dist/*.whl; if python --version 2>&1 | grep -q "Python 3.7" || python --version 2>&1 | grep -q "Python 3.8" || python --version 2>&1 | grep -q "Python 3.9" || python --version 2>&1 | grep -q "Python 3.10"; then pip install aiofiles; fi - name: Lint with pylint and flake8 run: | diff --git a/.gitignore b/.gitignore index db3f3ee1..c56a99bc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# Autogenerated version file +/adb_shell/version.py + # Python files *.idea *.pyc diff --git a/.travis.yml b/.travis.yml index 0795ead3..08014b8a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,10 @@ addons: - swig - libusb-1.0-0-dev install: - - pip install . + - pip install --upgrade pip + - pip install --upgrade build + - python -m build -nwx . + - pip install ./dist/*.whl - pip install flake8 pylint coveralls cryptography libusb1>=1.0.16 pycryptodome - python --version 2>&1 | grep -q "Python 2" && pip install mock || true - if python --version 2>&1 | grep -q "Python 3.7" || python --version 2>&1 | grep -q "Python 3.8" || python --version 2>&1 | grep -q "Python 3.9"; then pip install aiofiles; fi diff --git a/Makefile b/Makefile index 1c78665c..a7ee5bb2 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ release: rm -rf dist rm -rf build scripts/git_tag.sh - python setup.py sdist bdist_wheel + python -m build -nwsx twine upload dist/* .PHONY: docs diff --git a/adb_shell/__init__.py b/adb_shell/__init__.py index 3c1eda4d..3762de84 100644 --- a/adb_shell/__init__.py +++ b/adb_shell/__init__.py @@ -7,4 +7,4 @@ """ -__version__ = '0.4.2' +from .version import __version__ # noqa: F401 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..4a6dd2b5 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,7 @@ +[build-system] +requires = ["setuptools>=44", "wheel", "setuptools_scm[toml]>=3.4.3"] +build-backend = "setuptools.build_meta" + +[tool.setuptools_scm] +write_to = "adb_shell/version.py" +write_to_template = "'''Generated by setuptools_scm'''\n__version__ = '{version}'\n" diff --git a/scripts/bumpversion.sh b/scripts/bumpversion.sh deleted file mode 100755 index 7ee2b92b..00000000 --- a/scripts/bumpversion.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -# Make sure there is only 1 argument passed -if [ "$#" -ne 1 ]; then - echo "You must provide a new version" - exit 1 -fi - -# Make sure the new version is not empty -if [ -z "$1" ]; then - echo "You must provide a non-empty version" - exit 1 -fi - -# get the directory of this script -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" - -# get the package name -PACKAGE=$($DIR/get_package_name.sh) - -# get the current version -VERSION=$($DIR/get_version.sh) - -# Announce the version bump -echo "Bumping the version from $VERSION to $1" - -# __init__.py -sed -i "s|__version__ = '$VERSION'|__version__ = '$1'|g" $DIR/../$PACKAGE/__init__.py - -# setup.py -sed -i "s|version='$VERSION',|version='$1',|g" $DIR/../setup.py - -# conf.py -sed -i "s|version = '$VERSION'|version = '$1'|g" $DIR/../docs/source/conf.py -sed -i "s|release = '$VERSION'|release = '$1'|g" $DIR/../docs/source/conf.py diff --git a/scripts/rename_package.sh b/scripts/rename_package.sh index b4487fc4..c0309687 100755 --- a/scripts/rename_package.sh +++ b/scripts/rename_package.sh @@ -32,8 +32,8 @@ sed -i "s|$PACKAGE|$1|g" $DIR/../Doxyfile # Makefile sed -i "s|$PACKAGE|$1|g" $DIR/../Makefile -# setup.py -sed -i "s|$PACKAGE|$1|g" $DIR/../setup.py +# setup.cfg +sed -i "s|$PACKAGE|$1|g" $DIR/../setup.cfg # docs/Makefile sed -i "s|$PACKAGE|$1|g" $DIR/../docs/Makefile diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..f030a028 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,28 @@ +[metadata] +name = adb_shell +author = Jeff Irion +author_email = jefflirion@users.noreply.github.com +description = A Python implementation of ADB with shell and FileSync functionality. +license = Apache-2.0 +keywords = adb, android +url = https://github.com/JeffLIrion/adb_shell +long_description = file: README.rst +long_description_contet_type = text/x-rst +classifiers = + Operating System :: OS Independent + License :: OSI Approved :: Apache Software License + Programming Language :: Python :: 3 + Programming Language :: Python :: 2 + +[options] +packages = + adb_shell + adb_shell.auth + adb_shell.transport +install_requires = cryptography; pyasn1; rsa +test_suite = tests +tests_require = pycryptodome; libusb1>=1.0.16 + +[options.extras_require] +usb = libusb1>=1.0.16 +async = aiofiles>=0.4.0 diff --git a/setup.py b/setup.py deleted file mode 100644 index c0c4d273..00000000 --- a/setup.py +++ /dev/null @@ -1,24 +0,0 @@ -from setuptools import setup - -with open('README.rst') as f: - readme = f.read() - -setup( - name='adb_shell', - version='0.4.2', - description='A Python implementation of ADB with shell and FileSync functionality.', - long_description=readme, - keywords=['adb', 'android'], - url='https://github.com/JeffLIrion/adb_shell', - author='Jeff Irion', - author_email='jefflirion@users.noreply.github.com', - packages=['adb_shell', 'adb_shell.auth', 'adb_shell.transport'], - install_requires=['cryptography', 'pyasn1', 'rsa'], - tests_require=['pycryptodome', 'libusb1>=1.0.16'], - extras_require = {'usb': ['libusb1>=1.0.16'], 'async': ['aiofiles>=0.4.0']}, - classifiers=['Operating System :: OS Independent', - 'License :: OSI Approved :: Apache Software License', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 2'], - test_suite='tests' -)