From f359f70879f26172457f997931235c1a54380c95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Tue, 26 Mar 2024 15:59:47 -0500 Subject: [PATCH 1/7] =?UTF-8?q?=F0=9F=94=A7=20Refactor=20package=20manager?= =?UTF-8?q?,=20move=20from=20Flit=20to=20PDM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 59 +++++++++++++++++--------------------------------- 1 file changed, 20 insertions(+), 39 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c6e282a545..7e40e94256 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,16 @@ [build-system] -requires = ["flit_core >=2,<3"] -build-backend = "flit_core.buildapi" +requires = ["pdm-backend"] +build-backend = "pdm.backend" -[tool.flit.metadata] -module = "typer" -author = "Sebastián Ramírez" -author-email = "tiangolo@gmail.com" -home-page = "https://github.com/tiangolo/typer" +[project] +name = "typer" +dynamic = ["version"] +description = "Typer, build great CLIs. Easy to code. Based on Python type hints." +authors = [ + {name = "Sebastián Ramírez", email = "tiangolo@gmail.com"}, +] +readme = "README.md" +requires-python = ">=3.7" classifiers = [ "Intended Audience :: Information Technology", "Intended Audience :: System Administrators", @@ -26,49 +30,27 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", - "License :: OSI Approved :: MIT License" - ] -requires = [ + "License :: OSI Approved :: MIT License", +] +dependencies = [ "click >= 8.0.0", "typing-extensions >= 3.7.4.3", ] -description-file = "README.md" -requires-python = ">=3.7" -[tool.flit.metadata.urls] +[project.urls] Documentation = "https://typer.tiangolo.com/" +homepage = "https://github.com/tiangolo/typer" -[tool.flit.metadata.requires-extra] -test = [ - "shellingham >=1.3.0,<2.0.0", - "pytest >=4.4.0,<8.0.0", - "pytest-cov >=2.10.0,<5.0.0", - "coverage >=6.2,<7.0", - "pytest-xdist >=1.32.0,<4.0.0", - "pytest-sugar >=0.9.4,<0.10.0", - "mypy ==0.971", - "black >=22.3.0,<23.0.0", - "isort >=5.0.6,<6.0.0", - "rich >=10.11.0,<14.0.0", -] -doc = [ - "mkdocs >=1.1.2,<2.0.0", - "mkdocs-material >=8.1.4,<9.0.0", - "mdx-include >=1.4.1,<2.0.0", - "pillow >=9.3.0,<10.0.0", - "cairosvg >=2.5.2,<3.0.0", -] -dev = [ - "autoflake >=1.3.1,<2.0.0", - "flake8 >=3.8.3,<4.0.0", - "pre-commit >=2.17.0,<3.0.0", -] +[project.optional-dependencies] all = [ "colorama >=0.4.3,<0.5.0", "shellingham >=1.3.0,<2.0.0", "rich >=10.11.0,<14.0.0", ] +[tool.pdm] +version = { source = "file", path = "typer/__init__.py" } + [tool.isort] profile = "black" known_third_party = ["typer", "click"] @@ -89,7 +71,6 @@ filterwarnings = [ "error", # TODO: until I refactor completion to use the new shell_complete "ignore:'autocompletion' is renamed to 'shell_complete'. The old name is deprecated and will be removed in Click 8.1. See the docs about 'Parameter' for information about new behavior.:DeprecationWarning:typer", - 'ignore:starlette.middleware.wsgi is deprecated and will be removed in a future release\..*:DeprecationWarning:starlette', # For pytest-xdist 'ignore::DeprecationWarning:xdist', ] From 7fbd0c1c2bf7d4e55b39d99ee43900233fb06aff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Tue, 26 Mar 2024 16:00:33 -0500 Subject: [PATCH 2/7] =?UTF-8?q?=E2=9E=95=20Add=20development,=20testing,?= =?UTF-8?q?=20docs=20dependencies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements-docs.txt | 17 +++++++++++++++++ requirements-tests.txt | 10 ++++++++++ requirements.txt | 6 ++++++ 3 files changed, 33 insertions(+) create mode 100644 requirements-docs.txt create mode 100644 requirements-tests.txt create mode 100644 requirements.txt diff --git a/requirements-docs.txt b/requirements-docs.txt new file mode 100644 index 0000000000..bad2afad2a --- /dev/null +++ b/requirements-docs.txt @@ -0,0 +1,17 @@ +-e . + +mkdocs-material==9.4.7 +mdx-include >=1.4.1,<2.0.0 +mkdocs-markdownextradata-plugin >=0.1.7,<0.3.0 +mkdocs-redirects>=1.2.1,<1.3.0 +pyyaml >=5.3.1,<7.0.0 +# For Material for MkDocs, Chinese search +jieba==0.42.1 +# For image processing by Material for MkDocs +pillow==10.1.0 +# For image processing by Material for MkDocs +cairosvg==2.7.0 +mkdocstrings[python]==0.23.0 +griffe-typingdoc==0.2.2 +# For griffe, it formats with black +black==23.3.0 diff --git a/requirements-tests.txt b/requirements-tests.txt new file mode 100644 index 0000000000..10444cdd41 --- /dev/null +++ b/requirements-tests.txt @@ -0,0 +1,10 @@ +-e .[all] + +pytest >=4.4.0,<8.0.0 +pytest-cov >=2.10.0,<5.0.0 +coverage >=6.2,<7.0 +pytest-xdist >=1.32.0,<4.0.0 +pytest-sugar >=0.9.4,<0.10.0 +mypy ==0.971 +black >=22.3.0,<23.0.0 +isort >=5.0.6,<6.0.0 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000..d84d26a8da --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +-e .[all] + +-r requirements-tests.txt +-r requirements-docs.txt + +pre-commit >=2.17.0,<4.0.0 From 7f8fa6bc3e8bddf6b2e21c62aea67f1247e2c17f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Tue, 26 Mar 2024 16:15:48 -0500 Subject: [PATCH 3/7] =?UTF-8?q?=E2=9E=95=20Update=20coverage=20dependency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements-tests.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-tests.txt b/requirements-tests.txt index 10444cdd41..e7850a4c06 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -2,7 +2,7 @@ pytest >=4.4.0,<8.0.0 pytest-cov >=2.10.0,<5.0.0 -coverage >=6.2,<7.0 +coverage[toml] >=6.2,<7.0 pytest-xdist >=1.32.0,<4.0.0 pytest-sugar >=0.9.4,<0.10.0 mypy ==0.971 From 176bb99008e7bd1c103778e242be300672d7772d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Tue, 26 Mar 2024 16:17:14 -0500 Subject: [PATCH 4/7] =?UTF-8?q?=F0=9F=91=B7=20Update=20build-docs=20CI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-docs.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index bcd0e4e4a0..b8b2164354 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -17,9 +17,9 @@ jobs: outputs: docs: ${{ steps.filter.outputs.docs }} steps: - - uses: actions/checkout@v3 - # For pull requests it's not necessary to checkout the code but for the main branch it is - - uses: dorny/paths-filter@v2 + - uses: actions/checkout@v4 + # For pull requests it's not necessary to checkout the code but for master it is + - uses: dorny/paths-filter@v3 id: filter with: filters: | @@ -27,6 +27,7 @@ jobs: - README.md - docs/** - docs_src/** + - requirements-docs.txt - pyproject.toml - mkdocs.yml - mkdocs.insiders.yml @@ -43,25 +44,25 @@ jobs: env: GITHUB_CONTEXT: ${{ toJson(github) }} run: echo "$GITHUB_CONTEXT" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.11" - uses: actions/cache@v3 id: cache with: path: ${{ env.pythonLocation }} - key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-v01 - - name: Install Flit - if: steps.cache.outputs.cache-hit != 'true' - run: python -m pip install flit + key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-docs.txt') }}-v01 - name: Install docs extras if: steps.cache.outputs.cache-hit != 'true' - run: python -m flit install --extras doc + run: pip install -r requirements-docs.txt - name: Install Material for MkDocs Insiders - if: ( github.event_name != 'pull_request' || github.secret_source == 'Actions' ) && steps.cache.outputs.cache-hit != 'true' - run: python -m pip install git+https://${{ secrets.TYPER_MKDOCS_MATERIAL_INSIDERS }}@github.com/squidfunk/mkdocs-material-insiders.git + if: ( github.event_name != 'pull_request' || github.secret_source != 'Actions' ) && steps.cache.outputs.cache-hit != 'true' + run: | + pip install git+https://${{ secrets.TYPER_MKDOCS_MATERIAL_INSIDERS }}@github.com/squidfunk/mkdocs-material-insiders.git + pip install git+https://${{ secrets.TYPER_MKDOCS_MATERIAL_INSIDERS }}@github.com/pawamoy-insiders/griffe-typing-deprecated.git + pip install git+https://${{ secrets.TYPER_MKDOCS_MATERIAL_INSIDERS }}@github.com/pawamoy-insiders/mkdocstrings-python.git - uses: actions/cache@v3 with: key: mkdocs-cards-${{ github.ref }}-v1 @@ -70,10 +71,9 @@ jobs: if: github.event_name == 'pull_request' && github.secret_source != 'Actions' run: python -m mkdocs build - name: Build Docs with Insiders - if: github.event_name != 'pull_request' || github.secret_source == 'Actions' + if: ( github.event_name != 'pull_request' || github.secret_source != 'Actions' ) run: python -m mkdocs build --config-file mkdocs.insiders.yml - - uses: actions/upload-artifact@v3 with: name: docs-site From f72bebf7592c5ef9ddb2d02247b8f7b5676696e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Tue, 26 Mar 2024 16:17:32 -0500 Subject: [PATCH 5/7] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Upgrade=20dependencies?= =?UTF-8?q?=20for=20deploy-docs=20CI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-docs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index bca10dfdd6..8f526d818d 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -14,14 +14,14 @@ jobs: env: GITHUB_CONTEXT: ${{ toJson(github) }} run: echo "$GITHUB_CONTEXT" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Clean site run: | rm -rf ./site mkdir ./site - name: Download Artifact Docs id: download - uses: dawidd6/action-download-artifact@v2.27.0 + uses: dawidd6/action-download-artifact@v3.1.4 with: if_no_artifact_found: ignore github_token: ${{ secrets.GITHUB_TOKEN }} From 211e5ebd8610930acdd89ab5ac3e63bf4609146d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Tue, 26 Mar 2024 16:18:17 -0500 Subject: [PATCH 6/7] =?UTF-8?q?=F0=9F=91=B7=20Update=20publish=20CI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/publish.yml | 36 +++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1786d2dbb5..bc72a0ed72 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -9,17 +9,33 @@ jobs: publish: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 + with: + python-version: "3.10" + # Issue ref: https://github.com/actions/setup-python/issues/436 + # cache: "pip" + # cache-dependency-path: pyproject.toml + - uses: actions/cache@v3 + id: cache with: - python-version: "3.7" - - name: Install Flit - run: pip install flit - - name: Install Dependencies - run: flit install --symlink + path: ${{ env.pythonLocation }} + key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }} + - name: Install build dependencies + if: steps.cache.outputs.cache-hit != 'true' + run: pip install build + - name: Build distribution + run: python -m build - name: Publish + uses: pypa/gh-action-pypi-publish@v1.8.11 + with: + password: ${{ secrets.PYPI_API_TOKEN }} + - name: Dump GitHub context env: - FLIT_USERNAME: ${{ secrets.FLIT_USERNAME }} - FLIT_PASSWORD: ${{ secrets.FLIT_PASSWORD }} - run: bash scripts/publish.sh + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" From cbf85156c4465ffea9638ee3399e6a845a82fd22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Tue, 26 Mar 2024 16:18:44 -0500 Subject: [PATCH 7/7] =?UTF-8?q?=F0=9F=91=B7=20Update=20tests=20CI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test.yml | 45 ++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 533c4cf417..8fcc70910e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,26 +5,38 @@ on: branches: - master pull_request: - types: [opened, synchronize] + types: + - opened + - synchronize jobs: test: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest strategy: matrix: python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] fail-fast: false - steps: - - uses: actions/checkout@v3 + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - name: Install Flit - run: pip install flit + # Issue ref: https://github.com/actions/setup-python/issues/436 + # cache: "pip" + # cache-dependency-path: pyproject.toml + - uses: actions/cache@v3 + id: cache + with: + path: ${{ env.pythonLocation }} + key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }} - name: Install Dependencies - run: python -m flit install --symlink + if: steps.cache.outputs.cache-hit != 'true' + run: pip install -r requirements-tests.txt - name: Lint run: bash scripts/lint.sh - run: mkdir coverage @@ -42,27 +54,28 @@ jobs: coverage-combine: needs: [test] runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-python@v4 + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: '3.8' - + # Issue ref: https://github.com/actions/setup-python/issues/436 + # cache: "pip" + # cache-dependency-path: pyproject.toml - name: Get coverage files uses: actions/download-artifact@v3 with: name: coverage path: coverage - - run: pip install coverage[toml] - - run: ls -la coverage - run: coverage combine coverage - run: coverage report - run: coverage html --show-contexts --title "Coverage for ${{ github.sha }}" - - name: Store coverage HTML uses: actions/upload-artifact@v3 with: