From a403315421f302a8e8fa078632175097d91311d2 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Fri, 26 May 2023 12:44:58 -0400 Subject: [PATCH 1/5] Update action versions --- .github/workflows/build.yml | 10 +++++----- .github/workflows/release.yml | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e35cfd1..272065d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,19 +22,19 @@ jobs: awk -F '\/' '{ print tolower($2) }' | tr '_' '-' ) - - name: Set up Python 3.7 - uses: actions/setup-python@v1 + - name: Set up Python 3.x + uses: actions/setup-python@v4 with: - python-version: 3.7 + python-version: '3.x' - name: Versions run: | python3 --version - name: Checkout Current Repo - uses: actions/checkout@v1 + uses: actions/checkout@v3 with: submodules: true - name: Checkout tools repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: adafruit/actions-ci-circuitpython-libs path: actions-ci diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7f49be8..037cf01 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,14 +12,14 @@ jobs: upload-pypi: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v3 - name: Check For setup.py id: need-pypi run: | echo ::set-output name=setup-py::$( find . -wholename './setup.py' ) - name: Set up Python if: contains(steps.need-pypi.outputs.setup-py, 'setup.py') - uses: actions/setup-python@v1 + uses: actions/setup-python@v4 with: python-version: '3.x' - name: Install dependencies From 9af4579fdd448486766983b027573dfc68ceb5de Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Fri, 26 May 2023 12:45:31 -0400 Subject: [PATCH 2/5] Remove dumping GitHub context --- .github/workflows/build.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 272065d..e0de3a1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,10 +10,6 @@ jobs: test: runs-on: ubuntu-latest steps: - - name: Dump GitHub context - env: - GITHUB_CONTEXT: ${{ toJson(github) }} - run: echo "$GITHUB_CONTEXT" - name: Translate Repo Name For Build Tools filename_prefix id: repo-name run: | From 7051c1e78cc040cccdcbe641fd6ee354e4ca360e Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Fri, 26 May 2023 12:48:16 -0400 Subject: [PATCH 3/5] Remove pylint action step --- .github/workflows/build.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e0de3a1..14e3236 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,15 +40,12 @@ jobs: source actions-ci/install.sh - name: Pip install pylint, Sphinx, pre-commit run: | - pip install --force-reinstall pylint Sphinx sphinx-rtd-theme pre-commit + pip install --force-reinstall Sphinx sphinx-rtd-theme pre-commit - name: Library version run: git describe --dirty --always --tags - name: Pre-commit hooks run: | pre-commit run --all-files - - name: PyLint - run: | - pylint $( find . -path './adafruit*.py' ) - name: Build docs working-directory: docs run: sphinx-build -E -W -b html . _build/html From 5f10a029a2a3dc819a0ea28ef780e7b4c32db0de Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Fri, 26 May 2023 12:51:35 -0400 Subject: [PATCH 4/5] Move to pyproject.toml, build wheels in CI --- .github/workflows/build.yml | 16 +++++----- .github/workflows/release.yml | 15 +++++---- optional_dependencies.txt | 3 ++ pyproject.toml | 52 ++++++++++++++++++++++++++++-- setup.py | 60 ----------------------------------- 5 files changed, 69 insertions(+), 77 deletions(-) create mode 100644 optional_dependencies.txt delete mode 100644 setup.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 14e3236..1e6098f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,11 +13,11 @@ jobs: - name: Translate Repo Name For Build Tools filename_prefix id: repo-name run: | - echo ::set-output name=repo-name::$( + echo repo-name=$( echo ${{ github.repository }} | awk -F '\/' '{ print tolower($2) }' | tr '_' '-' - ) + ) >> $GITHUB_OUTPUT - name: Set up Python 3.x uses: actions/setup-python@v4 with: @@ -49,14 +49,14 @@ jobs: - name: Build docs working-directory: docs run: sphinx-build -E -W -b html . _build/html - - name: Check For setup.py + - name: Check For pyproject.toml id: need-pypi run: | - echo ::set-output name=setup-py::$( find . -wholename './setup.py' ) + echo pyproject-toml=$( find . -wholename './pyproject.toml' ) >> $GITHUB_OUTPUT - name: Build Python package - if: contains(steps.need-pypi.outputs.setup-py, 'setup.py') + if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml') run: | - pip install --upgrade setuptools wheel twine readme_renderer testresources - python setup.py sdist - python setup.py bdist_wheel --universal + pip install --upgrade build twine + find -type f -not -path "./.*" -not -path "./docs*" \( -name "*.py" -o -name "*.toml" \) -exec sed -i -e "s/0.0.0+auto.0/1.2.3/" {} + + python -m build twine check dist/* diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 037cf01..88542af 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,25 +13,26 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Check For setup.py + - name: Check For pyproject.toml id: need-pypi run: | - echo ::set-output name=setup-py::$( find . -wholename './setup.py' ) + echo pyproject-toml=$( find . -wholename './pyproject.toml' ) >> $GITHUB_OUTPUT - name: Set up Python - if: contains(steps.need-pypi.outputs.setup-py, 'setup.py') + if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml') uses: actions/setup-python@v4 with: python-version: '3.x' - name: Install dependencies - if: contains(steps.need-pypi.outputs.setup-py, 'setup.py') + if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml') run: | python -m pip install --upgrade pip - pip install setuptools wheel twine + pip install --upgrade build twine - name: Build and publish - if: contains(steps.need-pypi.outputs.setup-py, 'setup.py') + if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml') env: TWINE_USERNAME: ${{ secrets.pypi_username }} TWINE_PASSWORD: ${{ secrets.pypi_password }} run: | - python setup.py sdist + find -type f -not -path "./.*" -not -path "./docs*" \( -name "*.py" -o -name "*.toml" \) -exec sed -i -e "s/0.0.0+auto.0/${{github.event.release.tag_name}}/" {} + + python -m build twine upload dist/* diff --git a/optional_dependencies.txt b/optional_dependencies.txt new file mode 100644 index 0000000..e8214e0 --- /dev/null +++ b/optional_dependencies.txt @@ -0,0 +1,3 @@ +# SPDX-FileCopyrightText: 2023 Alec Delaney, written for Adafruit Industries +# +# SPDX-License-Identifier: MIT diff --git a/pyproject.toml b/pyproject.toml index f3c35ae..4b6d815 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,54 @@ # SPDX-FileCopyrightText: 2020 Diego Elio Pettenò +# SPDX-FileCopyrightText: 2023 Alec Delaney for Adafruit Industries # # SPDX-License-Identifier: Unlicense -[tool.black] -target-version = ['py35'] +[build-system] +requires = [ + "setuptools", + "wheel", + "setuptools-scm", +] + +[project] +name = "adafruit-python-shell" +description = "Python helper for running Shell scripts in Python" +version = "0.0.0+auto.0" +readme = "README.rst" +authors = [ + {name = "Adafruit Industries", email = "circuitpython@adafruit.com"} +] +urls = {Homepage = "https://github.com/adafruit/Adafruit_Python_Shell"} +keywords = [ + "adafruit", + "blinka", + "circuitpython", + "micropython", + "python", + "shell", + "installation", + "raspberry", + "pi", + "console", + "terminal", + "installer", +] +license = {text = "MIT"} +classifiers = [ + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "Topic :: Software Development :: Libraries", + "Topic :: System :: Hardware", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.4", + "Programming Language :: Python :: 3.5", +] +dynamic = ["dependencies", "optional-dependencies"] + +[tool.setuptools] +py-modules = ["adafruit_shell"] + +[tool.setuptools.dynamic] +dependencies = {file = ["requirements.txt"]} +optional-dependencies = {optional = {file = ["optional_requirements.txt"]}} diff --git a/setup.py b/setup.py deleted file mode 100644 index 90a2725..0000000 --- a/setup.py +++ /dev/null @@ -1,60 +0,0 @@ -# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries -# SPDX-FileCopyrightText: Copyright (c) 2020 Melissa LeBlanc-Williams for Adafruit Industries -# -# SPDX-License-Identifier: MIT - -"""A setuptools based setup module. - -See: -https://packaging.python.org/en/latest/distributing.html -https://github.com/pypa/sampleproject -""" - -from setuptools import setup, find_packages - -# To use a consistent encoding -from codecs import open -from os import path - -here = path.abspath(path.dirname(__file__)) - -# Get the long description from the README file -with open(path.join(here, "README.rst"), encoding="utf-8") as f: - long_description = f.read() - -setup( - name="adafruit-python-shell", - use_scm_version=True, - setup_requires=["setuptools_scm"], - description="Python helper for running Shell scripts in Python", - long_description=long_description, - long_description_content_type="text/x-rst", - # The project's main homepage. - url="https://github.com/adafruit/Adafruit_Python_Shell", - # Author details - author="Adafruit Industries", - author_email="circuitpython@adafruit.com", - install_requires=[ - "clint", - "Adafruit-PlatformDetect", - ], - # Choose your license - license="MIT", - # See https://pypi.python.org/pypi?%3Aaction=list_classifiers - classifiers=[ - "Development Status :: 3 - Alpha", - "Intended Audience :: Developers", - "Topic :: Software Development :: Libraries", - "Topic :: System :: Hardware", - "License :: OSI Approved :: MIT License", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", - ], - # What does your project relate to? - keywords="adafruit blinka circuitpython micropython python shell installation raspberry pi " - "console terminal installer", - # You can just specify the packages manually here if your project is - # simple. Or you can use find_packages(). - py_modules=["adafruit_shell"], -) From c818ade2ae6426515d7325d3b1b9c79d7850a4c1 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Fri, 26 May 2023 12:52:42 -0400 Subject: [PATCH 5/5] Update version string --- adafruit_shell.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_shell.py b/adafruit_shell.py index 681af4f..62244b1 100644 --- a/adafruit_shell.py +++ b/adafruit_shell.py @@ -33,7 +33,7 @@ from datetime import datetime from clint.textui import colored, prompt import adafruit_platformdetect -__version__ = "0.0.0-auto.0" +__version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_Python_Shell.git"