diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 7de5d54..73177b4 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['2.7', '3.5', '3.6', '3.7', '3.8', '3.9', '3.10'] + python-version: ['3.7', '3.8', '3.9', '3.10'] steps: - uses: actions/checkout@v2 @@ -26,20 +26,19 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install --upgrade build wheel setuptools setuptools_scm - 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 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 + pip install aiofiles - name: Lint with pylint and flake8 run: | - if python --version 2>&1 | grep -q "Python 2" || python --version 2>&1 | grep -q "Python 3.5" || python --version 2>&1 | grep -q "Python 3.6"; then flake8 adb_shell/ --exclude="adb_shell/adb_device_async.py,adb_shell/transport/base_transport_async.py,adb_shell/transport/tcp_transport_async.py" && pylint --ignore="adb_device_async.py,base_transport_async.py,tcp_transport_async.py" adb_shell/; fi - 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 flake8 adb_shell/ && pylint adb_shell/; fi + flake8 adb_shell + pylint adb_shell - name: Test with unittest env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} COVERALLS_SERVICE_NAME: github run: | - if python --version 2>&1 | grep -q "Python 2" || python --version 2>&1 | grep -q "Python 3.5" || python --version 2>&1 | grep -q "Python 3.6" ; then for synctest in $(cd tests && ls test*.py | grep -v async); do python -m unittest discover -s tests/ -t . -p "$synctest" || exit 1; done; fi - 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 coverage run --source adb_shell -m unittest discover -s tests/ -t . && coverage report -m && coveralls; fi + coverage run --source adb_shell -m unittest discover -s tests/ -t . + coverage report -m + coveralls diff --git a/pyproject.toml b/pyproject.toml index a129fcb..bbdce58 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,6 +2,38 @@ requires = ["setuptools>=61.2.0", "wheel", "setuptools_scm[toml]>=3.4.3"] build-backend = "setuptools.build_meta" +[project] +name = "adb_shell" +authors = [{name = "Jeff Irion", email = "jefflirion@users.noreply.github.com"}] +description = "A Python implementation of ADB with shell and FileSync functionality." +license = {text = "Apache-2.0"} +keywords = ["adb", "android"] +readme = "README.rst" +classifiers = [ + "Operating System :: OS Independent", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 2", +] +urls = {Homepage = "https://github.com/JeffLIrion/adb_shell"} +dependencies = ["cryptography", "pyasn1", "rsa"] +dynamic = ["version"] + +[project.optional-dependencies] +usb = ["libusb1>=1.0.16"] +async = ["aiofiles>=0.4.0"] +testing = ["pycryptodome", "libusb1>=1.0.16"] + +[tool.setuptools] +packages = [ + "adb_shell", + "adb_shell.auth", + "adb_shell.transport", +] + [tool.setuptools_scm] write_to = "adb_shell/version.py" write_to_template = "'''Generated by setuptools_scm'''\n__version__ = '{version}'\n" + +[tool.distutils.bdist_wheel] +universal = 1 diff --git a/scripts/get_package_name.py b/scripts/get_package_name.py index 4a8b649..f4161c7 100755 --- a/scripts/get_package_name.py +++ b/scripts/get_package_name.py @@ -19,14 +19,23 @@ """ +def extractFromPEP621(pyproject) -> None: + project = pyproject.get("project", None) + if isinstance(project, dict): + return project.get("name", None) + + return None + + def getPackageName(rootDir: Path) -> str: - from setuptools.config import read_configuration + tomlPath = Path(rootDir / "pyproject.toml") + + with tomlPath.open("rb") as f: + pyproject = tomli.load(f) - setupCfg = read_configuration(Path(rootDir / "setup.cfg")) - try: - return setupCfg["metadata"]["name"] - except KeyError: - return None + fromPEP621 = extractFromPEP621(pyproject) + if fromPEP621: + return fromPEP621 def main(): diff --git a/scripts/rename_package.sh b/scripts/rename_package.sh index ec9cd2a..77b8fc1 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.cfg -sed -i "s|$PACKAGE|$1|g" $DIR/../setup.cfg +# pyproject.toml +sed -i "s|$PACKAGE|$1|g" $DIR/../pyproject.toml # docs/Makefile sed -i "s|$PACKAGE|$1|g" $DIR/../docs/Makefile diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index d19569f..0000000 --- a/setup.cfg +++ /dev/null @@ -1,29 +0,0 @@ -[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_content_type = text/x-rst -classifiers = - Operating System :: OS Independent - License :: OSI Approved :: Apache Software License - Programming Language :: Python :: 3 - Programming Language :: Python :: 2 - -[options] -install_requires = cryptography; pyasn1; rsa -packages = adb_shell, adb_shell.auth, adb_shell.transport - -[options.extras_require] -usb = libusb1>=1.0.16 -async = aiofiles>=0.4.0 -testing = pycryptodome; libusb1>=1.0.16 - -[tool.setuptools] - -[distutils.bdist_wheel] -universal = 1