Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved the metadata from setup.cfg into PEP 621-compliant pyproject.toml. #200

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
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 @@ -25,19 +25,20 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
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 --upgrade build wheel setuptools setuptools_scm
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 .
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
python -m build -nwsx .;
pip install ./dist/*.whl;
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Autogenerated version file
/adb_shell/version.py

# Python files
*.idea
*.pyc
Expand Down
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion adb_shell/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
"""


__version__ = '0.4.2'
from .version import __version__ # noqa: F401
39 changes: 39 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[build-system]
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 = "[email protected]"}]
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
35 changes: 0 additions & 35 deletions scripts/bumpversion.sh

This file was deleted.

54 changes: 54 additions & 0 deletions scripts/get_package_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env python3
import sys
import typing
from pathlib import Path

import tomli

__license__ = "Unlicense"
__copyright__ = """
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <https://unlicense.org/>
"""


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:
tomlPath = Path(rootDir / "pyproject.toml")

with tomlPath.open("rb") as f:
pyproject = tomli.load(f)

fromPEP621 = extractFromPEP621(pyproject)
if fromPEP621:
return fromPEP621


def main():
if len(sys.argv) > 1:
p = sys.argv[1]
else:
p = "."
pn = getPackageName(Path(p))
if pn:
print(pn, file=sys.stdout)
else:
print("Package name could not be determined", file=sys.stderr)


if __name__ == "__main__":
main()
22 changes: 0 additions & 22 deletions scripts/get_package_name.sh

This file was deleted.

15 changes: 15 additions & 0 deletions scripts/get_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python3
import sys

__license__ = "Unlicense"

if __name__ == "__main__":
import setuptools_scm

v = setuptools_scm.get_version(local_scheme="no-local-version").rsplit(".", 1)
if not v:
print("Version could not be determined", file=sys.stderr)
sys.exit(1)
if v[-1].startswith("dev"):
v = v[:-1]
print(".".join(v))
26 changes: 0 additions & 26 deletions scripts/get_version.sh

This file was deleted.

6 changes: 1 addition & 5 deletions scripts/git_retag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@
# 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)

VERSION=$(python3 $DIR/get_version.py)

# Announce the tag
echo "Re-tagging v$VERSION"
Expand Down
6 changes: 1 addition & 5 deletions scripts/git_tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@
# 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)

VERSION=$(python3 $DIR/get_version.py)

# Announce the tag
echo "Creating tag v$VERSION"
Expand Down
6 changes: 3 additions & 3 deletions scripts/rename_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

# get the current package name
PACKAGE=$($DIR/get_package_name.sh)
PACKAGE=$(python3 $DIR/get_package_name.py)

# Announce the renaming
echo "Renaming from '$PACKAGE' to '$1'"
Expand All @@ -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
# pyproject.toml
sed -i "s|$PACKAGE|$1|g" $DIR/../pyproject.toml

# docs/Makefile
sed -i "s|$PACKAGE|$1|g" $DIR/../docs/Makefile
Expand Down
24 changes: 0 additions & 24 deletions setup.py

This file was deleted.