From 47d0dfe2bd83b415c3368a1a199f9264c116e5dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Mon, 29 Apr 2024 14:08:15 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Migrate=20from=20Poetry=20to=20P?= =?UTF-8?q?DM=20for=20handling=20the=20internal=20dependencies=20and=20bui?= =?UTF-8?q?ld=20(#148)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-docs.yml | 24 +++++------ .github/workflows/publish.yml | 40 ++++++------------ .github/workflows/test-redistribute.yml | 50 +++++++++++++++++++++++ .github/workflows/test.yml | 16 ++------ asyncer/__init__.py | 2 +- pyproject.toml | 54 +++++++++++++------------ requirements-docs.txt | 17 ++++++++ requirements-tests.txt | 6 +++ requirements.txt | 6 +++ 9 files changed, 135 insertions(+), 80 deletions(-) create mode 100644 .github/workflows/test-redistribute.yml create mode 100644 requirements-docs.txt create mode 100644 requirements-tests.txt create mode 100644 requirements.txt diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index af9d3def..3fa8bbde 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -27,6 +27,7 @@ jobs: - README.md - docs/** - docs_src/** + - requirements-docs.txt - pyproject.toml - mkdocs.yml - mkdocs.insiders.yml @@ -52,31 +53,26 @@ jobs: id: cache with: path: ${{ env.pythonLocation }} - key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-v01 - - name: Install Poetry + 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 pip install --upgrade pip - python -m pip install "poetry" - python -m poetry self add poetry-version-plugin - - name: Configure poetry - run: python -m poetry config virtualenvs.create false - - name: Install Dependencies - if: steps.cache.outputs.cache-hit != 'true' - run: python -m poetry install + 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 poetry run pip install git+https://${{ secrets.ASYNCER_MKDOCS_MATERIAL_INSIDERS }}@github.com/squidfunk/mkdocs-material-insiders.git + run: | + pip install git+https://${{ secrets.ASYNCER_MKDOCS_MATERIAL_INSIDERS }}@github.com/squidfunk/mkdocs-material-insiders.git + pip install git+https://${{ secrets.ASYNCER_MKDOCS_MATERIAL_INSIDERS }}@github.com/pawamoy-insiders/griffe-typing-deprecated.git + pip install git+https://${{ secrets.ASYNCER_MKDOCS_MATERIAL_INSIDERS }}@github.com/pawamoy-insiders/mkdocstrings-python.git - uses: actions/cache@v3 with: key: mkdocs-cards-${{ github.ref }} path: .cache - name: Build Docs if: github.event_name == 'pull_request' && github.secret_source != 'Actions' - run: python -m poetry run mkdocs build + run: python -m mkdocs build - name: Build Docs with Insiders if: github.event_name != 'pull_request' || github.secret_source == 'Actions' - run: python -m poetry run mkdocs build --config-file mkdocs.insiders.yml + run: python -m mkdocs build --config-file mkdocs.insiders.yml - uses: actions/upload-artifact@v3 with: name: docs-site diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d84d30c1..b3b4b3a2 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,37 +14,23 @@ on: jobs: publish: runs-on: ubuntu-latest + strategy: + matrix: + package: + - asyncer + permissions: + id-token: write steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.11" - # Allow debugging with tmate - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 - if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }} - with: - limit-access-to-actor: true - - uses: actions/cache@v3 - id: cache - with: - path: ${{ env.pythonLocation }} - key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-root-v2 - - name: Install poetry - if: steps.cache.outputs.cache-hit != 'true' - run: | - python -m pip install --upgrade pip - python -m pip install "poetry" - python -m poetry self add poetry-version-plugin - - name: Configure poetry - run: python -m poetry config virtualenvs.create false - - name: Install Dependencies - if: steps.cache.outputs.cache-hit != 'true' - run: python -m poetry install - - name: Publish + - name: Install build dependencies + run: pip install build + - name: Build distribution env: - PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} - run: | - python -m poetry config pypi-token.pypi $PYPI_TOKEN - bash scripts/publish.sh + TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }} + run: python -m build + - name: Publish + uses: pypa/gh-action-pypi-publish@v1.8.11 diff --git a/.github/workflows/test-redistribute.yml b/.github/workflows/test-redistribute.yml new file mode 100644 index 00000000..6c4e9129 --- /dev/null +++ b/.github/workflows/test-redistribute.yml @@ -0,0 +1,50 @@ +name: Test Redistribute + +on: + push: + branches: + - main + pull_request: + types: + - opened + - synchronize + +jobs: + test-redistribute: + runs-on: ubuntu-latest + strategy: + matrix: + package: + - asyncer + steps: + - 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@v5 + with: + python-version: "3.10" + - name: Install build dependencies + run: pip install build + - name: Build source distribution + env: + TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }} + run: python -m build --sdist + - name: Decompress source distribution + run: | + cd dist + tar xvf asyncer*.tar.gz + - name: Install test dependencies + run: | + cd dist/asyncer*/ + pip install -r requirements-tests.txt + - name: Run source distribution tests + run: | + cd dist/asyncer*/ + bash scripts/test.sh + - name: Build wheel distribution + run: | + cd dist + pip wheel --no-deps asyncer*.tar.gz diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0db71394..ec3dc5a6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -50,18 +50,10 @@ jobs: id: cache with: path: ${{ env.pythonLocation }} - key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-root-v2 - - name: Install poetry - if: steps.cache.outputs.cache-hit != 'true' - run: | - python -m pip install --upgrade pip - python -m pip install "poetry" - python -m poetry self add poetry-version-plugin - - name: Configure poetry - run: python -m poetry config virtualenvs.create false + key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }} - name: Install Dependencies if: steps.cache.outputs.cache-hit != 'true' - run: python -m poetry install + run: pip install -r requirements-tests.txt - name: Install AnyIO v3 if: matrix.anyio-version == 'anyio-v3' run: pip install --upgrade "anyio>=3.4.0,<4.0" @@ -69,10 +61,10 @@ jobs: if: matrix.anyio-version == 'anyio-v4' run: pip install --upgrade "anyio>=4.0.0,<5.0" - name: Lint - run: python -m poetry run bash scripts/lint.sh + run: bash scripts/lint.sh - run: mkdir coverage - name: Test - run: python -m poetry run bash scripts/test.sh + run: bash scripts/test.sh env: COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }} CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }} diff --git a/asyncer/__init__.py b/asyncer/__init__.py index 3cbc94d2..384c5d1d 100644 --- a/asyncer/__init__.py +++ b/asyncer/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.0.5" +__version__ = "0.0.6.dev1" from ._main import PendingValueException as PendingValueException from ._main import SoonValue as SoonValue diff --git a/pyproject.toml b/pyproject.toml index 7461bfa3..0d2df8d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,13 +1,16 @@ -[tool.poetry] +[build-system] +requires = ["pdm-backend"] +build-backend = "pdm.backend" + +[project] name = "asyncer" -version = "0" +dynamic = ["version"] description = "Asyncer, async and await, focused on developer experience." -authors = ["Sebastián Ramírez "] readme = "README.md" -homepage = "https://github.com/tiangolo/asyncer" -documentation = "https://asyncer.tiangolo.com" -repository = "https://github.com/tiangolo/asyncer" -license = "MIT" +requires-python = ">=3.8" +authors = [ + { name = "Sebastián Ramírez", email = "tiangolo@gmail.com" }, +] classifiers = [ "Development Status :: 4 - Beta", "Framework :: AsyncIO", @@ -27,28 +30,27 @@ classifiers = [ "Topic :: Internet", "Typing :: Typed", ] +dependencies = [ + "anyio >=3.4.0,<5.0", + "typing_extensions >=4.8.0; python_version < '3.10'" +] -[tool.poetry.dependencies] -python = "^3.8" -anyio = ">=3.4.0,<5.0" -typing_extensions = { version = "^4.8.0", python = "<3.10" } - -[tool.poetry.dev-dependencies] -pytest = "^7.0.1" -mypy = "1.4.1" -mkdocs-material = "9.2.7" -pillow = "^9.3.0" -cairosvg = "^2.5.2" -mdx-include = "^1.4.1" -coverage = {extras = ["toml"], version = ">=6.2,<8.0"} -ruff = "0.2.0" +[project.urls] +Homepage = "https://github.com/tiangolo/asyncer" +Documentation = "https://asyncer.tiangolo.com" +Repository = "https://github.com/tiangolo/asyncer" -[build-system] -requires = ["poetry-core"] -build-backend = "poetry.core.masonry.api" +[tool.pdm] +version = { source = "file", path = "asyncer/__init__.py" } +distribution = true -[tool.poetry-version-plugin] -source = "init" +[tool.pdm.build] +source-includes = [ + "tests/", + "docs_src/", + "requirements*.txt", + "scripts/", + ] [tool.coverage.run] parallel = true diff --git a/requirements-docs.txt b/requirements-docs.txt new file mode 100644 index 00000000..bad2afad --- /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 00000000..961bc6ad --- /dev/null +++ b/requirements-tests.txt @@ -0,0 +1,6 @@ +-e . + +pytest >=7.0.1,<8.0.0 +coverage[toml] >=6.2,<8.0 +mypy ==1.4.1 +ruff ==0.2.0 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..1e21c5d2 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +-e . + +-r requirements-tests.txt +-r requirements-docs.txt + +pre-commit >=2.17.0,<4.0.0