Skip to content

Commit a8ffb31

Browse files
committed
Moved the metadata into setup.cfg.
Added `pyproject.toml`. Version is now populated automatically from git tags using `setuptools_scm`. Deleted `bumpversion.sh`. Fixed some missing metadata fields. Fixed the scripts to work with `pyproject.toml` and cleaned them up.
1 parent ba3fb4b commit a8ffb31

16 files changed

+113
-124
lines changed

.github/workflows/python-package.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ jobs:
2525
- name: Install dependencies
2626
run: |
2727
python -m pip install --upgrade pip
28+
python -m pip install --upgrade build wheel setuptools setuptools_scm
2829
if python --version 2>&1 | grep -q "Python 2"; then pip install mock rsa==4.0 libusb1==1.9.3; fi
2930
python -m pip install flake8 pylint coveralls cryptography libusb1>=1.0.16 pycryptodome
3031
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
31-
pip install .
32+
python -m build -nwsx .;
33+
pip install ./dist/*.whl;
3234
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
3335
- name: Lint with pylint and flake8
3436
run: |

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Autogenerated version file
2+
/adb_shell/version.py
3+
14
# Python files
25
*.idea
36
*.pyc

.travis.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ addons:
1212
- swig
1313
- libusb-1.0-0-dev
1414
install:
15-
- pip install .
15+
- pip install --upgrade pip
16+
- pip install --upgrade build wheel setuptools setuptools_scm
17+
- python -m build -nwx .
18+
- pip install ./dist/*.whl
1619
- pip install flake8 pylint coveralls cryptography libusb1>=1.0.16 pycryptodome
1720
- python --version 2>&1 | grep -q "Python 2" && pip install mock || true
1821
- 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

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ release:
33
rm -rf dist
44
rm -rf build
55
scripts/git_tag.sh
6-
python setup.py sdist bdist_wheel
6+
python -m build -nwsx
77
twine upload dist/*
88

99
.PHONY: docs

adb_shell/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
"""
88

99

10-
__version__ = '0.4.2'
10+
from .version import __version__ # noqa: F401

pyproject.toml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[build-system]
2+
requires = ["setuptools>=44", "wheel", "setuptools_scm[toml]>=3.4.3"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[tool.setuptools_scm]
6+
write_to = "adb_shell/version.py"
7+
write_to_template = "'''Generated by setuptools_scm'''\n__version__ = '{version}'\n"

scripts/bumpversion.sh

-35
This file was deleted.

scripts/get_package_name.py

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env python3
2+
import sys
3+
import typing
4+
from pathlib import Path
5+
6+
import tomli
7+
8+
__license__ = "Unlicense"
9+
__copyright__ = """
10+
This is free and unencumbered software released into the public domain.
11+
12+
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.
13+
14+
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.
15+
16+
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.
17+
18+
For more information, please refer to <https://unlicense.org/>
19+
"""
20+
21+
22+
def getPackageName(rootDir: Path) -> str:
23+
from setuptools.config import read_configuration
24+
25+
setupCfg = read_configuration(Path(rootDir / "setup.cfg"))
26+
try:
27+
return setupCfg["metadata"]["name"]
28+
except KeyError:
29+
return None
30+
31+
32+
def main():
33+
if len(sys.argv) > 1:
34+
p = sys.argv[1]
35+
else:
36+
p = "."
37+
pn = getPackageName(Path(p))
38+
if pn:
39+
print(pn, file=sys.stdout)
40+
else:
41+
print("Package name could not be determined", file=sys.stderr)
42+
43+
44+
if __name__ == "__main__":
45+
main()

scripts/get_package_name.sh

-22
This file was deleted.

scripts/get_version.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env python3
2+
import sys
3+
4+
__license__ = "Unlicense"
5+
6+
if __name__ == "__main__":
7+
import setuptools_scm
8+
9+
v = setuptools_scm.get_version(local_scheme="no-local-version").rsplit(".", 1)
10+
if not v:
11+
print("Version could not be determined", file=sys.stderr)
12+
sys.exit(1)
13+
if v[-1].startswith("dev"):
14+
v = v[:-1]
15+
print(".".join(v))

scripts/get_version.sh

-26
This file was deleted.

scripts/git_retag.sh

+1-5
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@
33
# get the directory of this script
44
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
55

6-
# get the package name
7-
PACKAGE=$($DIR/get_package_name.sh)
8-
96
# get the current version
10-
VERSION=$($DIR/get_version.sh)
11-
7+
VERSION=$(python3 $DIR/get_version.py)
128

139
# Announce the tag
1410
echo "Re-tagging v$VERSION"

scripts/git_tag.sh

+1-5
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@
33
# get the directory of this script
44
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
55

6-
# get the package name
7-
PACKAGE=$($DIR/get_package_name.sh)
8-
96
# get the current version
10-
VERSION=$($DIR/get_version.sh)
11-
7+
VERSION=$(python3 $DIR/get_version.py)
128

139
# Announce the tag
1410
echo "Creating tag v$VERSION"

scripts/rename_package.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fi
1818
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
1919

2020
# get the current package name
21-
PACKAGE=$($DIR/get_package_name.sh)
21+
PACKAGE=$(python3 $DIR/get_package_name.py)
2222

2323
# Announce the renaming
2424
echo "Renaming from '$PACKAGE' to '$1'"
@@ -32,8 +32,8 @@ sed -i "s|$PACKAGE|$1|g" $DIR/../Doxyfile
3232
# Makefile
3333
sed -i "s|$PACKAGE|$1|g" $DIR/../Makefile
3434

35-
# setup.py
36-
sed -i "s|$PACKAGE|$1|g" $DIR/../setup.py
35+
# setup.cfg
36+
sed -i "s|$PACKAGE|$1|g" $DIR/../setup.cfg
3737

3838
# docs/Makefile
3939
sed -i "s|$PACKAGE|$1|g" $DIR/../docs/Makefile

setup.cfg

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[metadata]
2+
name = adb_shell
3+
author = Jeff Irion
4+
author_email = [email protected]
5+
description = A Python implementation of ADB with shell and FileSync functionality.
6+
license = Apache-2.0
7+
keywords = adb, android
8+
url = https://github.com/JeffLIrion/adb_shell
9+
long_description = file: README.rst
10+
long_description_content_type = text/x-rst
11+
classifiers =
12+
Operating System :: OS Independent
13+
License :: OSI Approved :: Apache Software License
14+
Programming Language :: Python :: 3
15+
Programming Language :: Python :: 2
16+
17+
[options]
18+
install_requires = cryptography; pyasn1; rsa
19+
packages = adb_shell, adb_shell.auth, adb_shell.transport
20+
21+
[options.extras_require]
22+
usb = libusb1>=1.0.16
23+
async = aiofiles>=0.4.0
24+
testing = pycryptodome; libusb1>=1.0.16
25+
26+
[tool.setuptools]
27+
28+
[distutils.bdist_wheel]
29+
universal = 1

setup.py

-24
This file was deleted.

0 commit comments

Comments
 (0)