Skip to content

Commit

Permalink
Moved the metadata from setup.cfg into PEP 621-compliant `pyproje…
Browse files Browse the repository at this point in the history
…ct.toml`.

Dropped wheel building support on unsupported versions of `python`, because `setuptools` available for this versions doesn't support `PEP 621`.
  • Loading branch information
KOLANICH committed May 6, 2022
1 parent c635a6e commit e8af3a1
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 45 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/python-package.yml
Expand Up @@ -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
Expand All @@ -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
32 changes: 32 additions & 0 deletions pyproject.toml
Expand Up @@ -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
21 changes: 15 additions & 6 deletions scripts/get_package_name.py
Expand Up @@ -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():
Expand Down
4 changes: 2 additions & 2 deletions scripts/rename_package.sh
Expand Up @@ -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
Expand Down
29 changes: 0 additions & 29 deletions setup.cfg

This file was deleted.

0 comments on commit e8af3a1

Please sign in to comment.