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

🔧 Refactor package manager, move from Flit to PDM, remove private pip extras for test, doc, dev #764

Merged
merged 7 commits into from
Mar 26, 2024
Merged
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
28 changes: 14 additions & 14 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ 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: |
docs:
- README.md
- docs/**
- docs_src/**
- requirements-docs.txt
- pyproject.toml
- mkdocs.yml
- mkdocs.insiders.yml
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
36 changes: 26 additions & 10 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
45 changes: 29 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
59 changes: 20 additions & 39 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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"]
Expand All @@ -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',
]
17 changes: 17 additions & 0 deletions requirements-docs.txt
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions requirements-tests.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-e .[all]

pytest >=4.4.0,<8.0.0
pytest-cov >=2.10.0,<5.0.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
black >=22.3.0,<23.0.0
isort >=5.0.6,<6.0.0
6 changes: 6 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-e .[all]

-r requirements-tests.txt
-r requirements-docs.txt

pre-commit >=2.17.0,<4.0.0
Loading