mirror of
https://github.com/pelican-plugins/share-post.git
synced 2025-10-15 17:08:54 +02:00
Use PDM & Ruff instead of Poetry+Black+Flake8+isort
This commit is contained in:
parent
ff43fa4542
commit
d7c2f2bf1f
6 changed files with 168 additions and 156 deletions
109
.github/workflows/main.yml
vendored
109
.github/workflows/main.yml
vendored
|
|
@ -7,102 +7,89 @@ env:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
name: Test - ${{ matrix.python-version }}
|
name: Test - Python ${{ matrix.python-version }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
python-version: ["3.8", "3.9"]
|
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
|
||||||
uses: actions/setup-python@v4
|
- name: Set up Python ${{ matrix.python-version }} & PDM
|
||||||
|
uses: pdm-project/setup-pdm@v4
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
- name: Set up Pip cache
|
cache: true
|
||||||
uses: actions/cache@v3
|
cache-dependency-path: ./pyproject.toml
|
||||||
id: pip-cache
|
|
||||||
with:
|
|
||||||
path: ~/.cache/pip
|
|
||||||
key: pip-${{ hashFiles('**/pyproject.toml') }}
|
|
||||||
- name: Upgrade Pip
|
|
||||||
run: python -m pip install --upgrade pip
|
|
||||||
- name: Install Poetry
|
|
||||||
run: python -m pip install poetry
|
|
||||||
- name: Set up Poetry cache
|
|
||||||
uses: actions/cache@v3
|
|
||||||
id: poetry-cache
|
|
||||||
with:
|
|
||||||
path: ~/.cache/pypoetry/virtualenvs
|
|
||||||
key: poetry-${{ hashFiles('**/poetry.lock') }}
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
poetry run pip install --upgrade pip
|
|
||||||
poetry install
|
|
||||||
- name: Run tests
|
|
||||||
run: poetry run invoke tests
|
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pdm install
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: pdm run invoke tests
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
name: Lint
|
name: Lint
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Validate links in Markdown files
|
- name: Validate links in Markdown files
|
||||||
uses: JustinBeckwith/linkinator-action@v1
|
uses: JustinBeckwith/linkinator-action@v1
|
||||||
with:
|
with:
|
||||||
retry: true
|
retry: true
|
||||||
- name: Set up Python
|
|
||||||
uses: actions/setup-python@v4
|
|
||||||
with:
|
|
||||||
python-version: "3.9"
|
|
||||||
- name: Set Poetry cache
|
|
||||||
uses: actions/cache@v3
|
|
||||||
id: poetry-cache
|
|
||||||
with:
|
|
||||||
path: ~/.cache/pypoetry/virtualenvs
|
|
||||||
key: poetry-${{ hashFiles('**/poetry.lock') }}
|
|
||||||
- name: Upgrade Pip
|
|
||||||
run: python -m pip install --upgrade pip
|
|
||||||
- name: Install Poetry
|
|
||||||
run: python -m pip install poetry
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
poetry run pip install --upgrade pip
|
|
||||||
poetry install
|
|
||||||
- name: Run linters
|
|
||||||
run: poetry run invoke lint
|
|
||||||
|
|
||||||
|
- name: Set up Python & PDM
|
||||||
|
uses: pdm-project/setup-pdm@v4
|
||||||
|
with:
|
||||||
|
python-version: "3.10"
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pdm install
|
||||||
|
|
||||||
|
- name: Run linters
|
||||||
|
run: pdm run invoke lint --diff
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
name: Deploy
|
name: Deploy
|
||||||
environment: Deployment
|
environment: Deployment
|
||||||
needs: [test, lint]
|
needs: [test, lint]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: ${{ github.ref=='refs/heads/main' && github.event_name!='pull_request' }}
|
if: github.ref=='refs/heads/main' && github.event_name!='pull_request'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
id-token: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- name: Setup Python
|
|
||||||
uses: actions/setup-python@v4
|
|
||||||
with:
|
with:
|
||||||
python-version: "3.9"
|
token: ${{ secrets.GH_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: "3.10"
|
||||||
|
|
||||||
- name: Check release
|
- name: Check release
|
||||||
id: check_release
|
id: check_release
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install autopub httpx
|
||||||
python -m pip install poetry githubrelease httpx==0.16.1 autopub
|
python -m pip install https://github.com/scikit-build/github-release/archive/master.zip
|
||||||
echo "##[set-output name=release;]$(autopub check)"
|
autopub check
|
||||||
|
|
||||||
- name: Publish
|
- name: Publish
|
||||||
if: ${{ steps.check_release.outputs.release=='' }}
|
if: ${{ steps.check_release.outputs.autopub_release=='true' }}
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||||
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
|
|
||||||
run: |
|
run: |
|
||||||
git remote set-url origin https://$GITHUB_TOKEN@github.com/${{ github.repository }}
|
|
||||||
autopub prepare
|
autopub prepare
|
||||||
poetry build
|
|
||||||
autopub commit
|
autopub commit
|
||||||
|
autopub build
|
||||||
autopub githubrelease
|
autopub githubrelease
|
||||||
poetry publish -u __token__ -p $PYPI_PASSWORD
|
|
||||||
|
- name: Upload package to PyPI
|
||||||
|
if: ${{ steps.check_release.outputs.autopub_release=='true' }}
|
||||||
|
uses: pypa/gh-action-pypi-publish@release/v1
|
||||||
|
|
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1 +1,2 @@
|
||||||
poetry.lock
|
.pdm-python
|
||||||
|
pdm.lock
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ repos:
|
||||||
- id: check-added-large-files
|
- id: check-added-large-files
|
||||||
- id: check-ast
|
- id: check-ast
|
||||||
- id: check-case-conflict
|
- id: check-case-conflict
|
||||||
|
- id: check-docstring-first
|
||||||
- id: check-merge-conflict
|
- id: check-merge-conflict
|
||||||
- id: check-toml
|
- id: check-toml
|
||||||
- id: check-yaml
|
- id: check-yaml
|
||||||
|
|
@ -19,19 +20,9 @@ repos:
|
||||||
- id: forbid-new-submodules
|
- id: forbid-new-submodules
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
|
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: 24.4.2
|
rev: v0.5.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: ruff
|
||||||
|
- id: ruff-format
|
||||||
- repo: https://github.com/PyCQA/flake8
|
args: ["--check"]
|
||||||
rev: 7.1.0
|
|
||||||
hooks:
|
|
||||||
- id: flake8
|
|
||||||
args: [--max-line-length=88]
|
|
||||||
language_version: python3
|
|
||||||
|
|
||||||
- repo: https://github.com/PyCQA/isort
|
|
||||||
rev: 5.13.2
|
|
||||||
hooks:
|
|
||||||
- id: isort
|
|
||||||
|
|
|
||||||
119
pyproject.toml
119
pyproject.toml
|
|
@ -1,53 +1,63 @@
|
||||||
[tool.poetry]
|
[project]
|
||||||
name = "pelican-share-post"
|
name = "pelican-share-post"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
description = "A Pelican plugin to create share URLs of article"
|
description = "A Pelican plugin to create share URLs of article"
|
||||||
authors = ["Talha Mansoor <talha131@gmail.com>", "Justin Mayer <entrop@gmail.com>"]
|
authors = [{name = "Talha Mansoor", email = "talha131@gmail.com"}, {name = "Justin Mayer", email = "entroP@gmail.com"}]
|
||||||
license = "MIT"
|
license = {text = "MIT"}
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
keywords = ["pelican", "plugin", "social"]
|
keywords = ["pelican", "plugin", "social"]
|
||||||
repository = "https://github.com/pelican-plugins/share-post"
|
|
||||||
documentation = "https://docs.getpelican.com"
|
|
||||||
packages = [
|
|
||||||
{ include = "pelican" },
|
|
||||||
]
|
|
||||||
|
|
||||||
classifiers = [
|
classifiers = [
|
||||||
"Development Status :: 5 - Production/Stable",
|
"Development Status :: 5 - Production/Stable",
|
||||||
"Environment :: Console",
|
"Environment :: Console",
|
||||||
"Framework :: Pelican",
|
"Framework :: Pelican",
|
||||||
"Framework :: Pelican :: Plugins",
|
"Framework :: Pelican :: Plugins",
|
||||||
"Intended Audience :: End Users/Desktop",
|
"Intended Audience :: End Users/Desktop",
|
||||||
|
"License :: OSI Approved :: MIT License",
|
||||||
"Operating System :: OS Independent",
|
"Operating System :: OS Independent",
|
||||||
|
"Programming Language :: Python :: 3",
|
||||||
|
"Programming Language :: Python :: 3.8",
|
||||||
|
"Programming Language :: Python :: 3.9",
|
||||||
|
"Programming Language :: Python :: 3.10",
|
||||||
|
"Programming Language :: Python :: 3.11",
|
||||||
|
"Programming Language :: Python :: 3.12",
|
||||||
"Topic :: Internet :: WWW/HTTP",
|
"Topic :: Internet :: WWW/HTTP",
|
||||||
"Topic :: Software Development :: Libraries :: Python Modules",
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
||||||
]
|
]
|
||||||
|
requires-python = ">=3.8.1,<4.0"
|
||||||
|
dependencies = [
|
||||||
|
"pelican>=4.5",
|
||||||
|
"beautifulsoup4>=4.9.3",
|
||||||
|
]
|
||||||
|
|
||||||
[tool.poetry.urls]
|
[project.urls]
|
||||||
"Funding" = "https://donate.getpelican.com/"
|
Homepage = "https://github.com/pelican-plugins/share-post"
|
||||||
"Issue Tracker" = "https://github.com/pelican-plugins/share-post/issues"
|
"Issue Tracker" = "https://github.com/pelican-plugins/share-post/issues"
|
||||||
|
Funding = "https://donate.getpelican.com/"
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[project.optional-dependencies]
|
||||||
python = ">=3.7,<4.0"
|
markdown = ["markdown>=3.4"]
|
||||||
pelican = ">=4.5"
|
|
||||||
markdown = {version = ">=3.2.2", optional = true}
|
|
||||||
beautifulsoup4 = "^4.9.3"
|
|
||||||
# Avoid PyPI/Poetry problem: https://github.com/python-poetry/poetry/issues/9293
|
|
||||||
docutils = "!=0.21.post1"
|
|
||||||
|
|
||||||
[tool.poetry.dev-dependencies]
|
[tool.pdm]
|
||||||
black = ">=22.3.0"
|
|
||||||
flake8 = "^3.9"
|
|
||||||
flake8-black = "^0.3"
|
|
||||||
invoke = "^2.1"
|
|
||||||
isort = "^5.4"
|
|
||||||
markdown = "^3.4"
|
|
||||||
pytest = "^6.0"
|
|
||||||
pytest-cov = "^2.8"
|
|
||||||
pytest-sugar = "^0.9.7"
|
|
||||||
|
|
||||||
[tool.poetry.extras]
|
[tool.pdm.dev-dependencies]
|
||||||
markdown = ["markdown"]
|
lint = [
|
||||||
|
"invoke>=2.2",
|
||||||
|
"ruff>=0.5.0,<0.6.0"
|
||||||
|
]
|
||||||
|
test = [
|
||||||
|
"markdown>=3.4",
|
||||||
|
"pytest>=7.0",
|
||||||
|
"pytest-cov>=4.0",
|
||||||
|
"pytest-sugar>=1.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.pdm.build]
|
||||||
|
source-includes = [
|
||||||
|
"CHANGELOG.md",
|
||||||
|
"CONTRIBUTING.md",
|
||||||
|
]
|
||||||
|
includes = ["pelican/"]
|
||||||
|
excludes = ["**/.DS_Store", "**/test_data/**", "tasks.py"]
|
||||||
|
|
||||||
[tool.autopub]
|
[tool.autopub]
|
||||||
project-name = "Share Post"
|
project-name = "Share Post"
|
||||||
|
|
@ -55,18 +65,45 @@ git-username = "botpub"
|
||||||
git-email = "52496925+botpub@users.noreply.github.com"
|
git-email = "52496925+botpub@users.noreply.github.com"
|
||||||
append-github-contributor = true
|
append-github-contributor = true
|
||||||
|
|
||||||
[tool.isort]
|
[tool.ruff.lint]
|
||||||
# Maintain compatibility with Black
|
select = [
|
||||||
profile = "black"
|
"B", # flake8-bugbear
|
||||||
multi_line_output = 3
|
"BLE", # flake8-blind-except
|
||||||
|
"C4", # flake8-comprehensions
|
||||||
|
"D", # pydocstyle
|
||||||
|
"E", # pycodestyle
|
||||||
|
"F", # pyflakes
|
||||||
|
"I", # isort
|
||||||
|
"ICN", # flake8-import-conventions
|
||||||
|
"ISC", # flake8-implicit-str-concat
|
||||||
|
"PGH", # pygrep-hooks
|
||||||
|
"PL", # pylint
|
||||||
|
"RET", # flake8-return
|
||||||
|
"RUF", # ruff-specific rules
|
||||||
|
"SIM", # flake8-simplify
|
||||||
|
"T10", # flake8-debugger
|
||||||
|
"T20", # flake8-print
|
||||||
|
"TID", # flake8-tidy-imports
|
||||||
|
"TRY", # tryceratops
|
||||||
|
"UP", # pyupgrade
|
||||||
|
"W", # pycodestyle
|
||||||
|
"YTT", # flake8-2020
|
||||||
|
]
|
||||||
|
|
||||||
# Sort imports within their section independent of the import type
|
ignore = [
|
||||||
force_sort_within_sections = true
|
"D100", # missing docstring in public module
|
||||||
|
"D103", # missing docstring in public method
|
||||||
|
"D104", # missing docstring in public package
|
||||||
|
"D203", # blank line before class docstring
|
||||||
|
"D213", # multi-line docstring summary should start at the second line
|
||||||
|
"ISC001", # disabled so `ruff format` works without warning
|
||||||
|
]
|
||||||
|
|
||||||
# Designate "pelican" as separate import section
|
[tool.ruff.lint.isort]
|
||||||
known_pelican = "pelican"
|
combine-as-imports = true
|
||||||
sections = "FUTURE,STDLIB,THIRDPARTY,PELICAN,FIRSTPARTY,LOCALFOLDER"
|
force-sort-within-sections = true
|
||||||
|
known-first-party = ["pelican"]
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["poetry-core>=1.0.0"]
|
requires = ["pdm-backend"]
|
||||||
build-backend = "poetry.core.masonry.api"
|
build-backend = "pdm.backend"
|
||||||
|
|
|
||||||
75
tasks.py
75
tasks.py
|
|
@ -1,14 +1,15 @@
|
||||||
from inspect import cleandoc
|
from inspect import cleandoc
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from shutil import which
|
from shutil import which
|
||||||
import sys
|
|
||||||
|
|
||||||
from invoke import task
|
from invoke import task
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
PKG_NAME = "share_post"
|
PKG_NAME = "share_post"
|
||||||
PKG_PATH = Path(f"pelican/plugins/{PKG_NAME}")
|
PKG_PATH = Path(f"pelican/plugins/{PKG_NAME}")
|
||||||
TOOLS = ("poetry", "pre-commit")
|
|
||||||
|
|
||||||
ACTIVE_VENV = os.environ.get("VIRTUAL_ENV", None)
|
ACTIVE_VENV = os.environ.get("VIRTUAL_ENV", None)
|
||||||
VENV_HOME = Path(os.environ.get("WORKON_HOME", "~/.local/share/virtualenvs"))
|
VENV_HOME = Path(os.environ.get("WORKON_HOME", "~/.local/share/virtualenvs"))
|
||||||
|
|
@ -16,52 +17,50 @@ VENV_PATH = Path(ACTIVE_VENV) if ACTIVE_VENV else (VENV_HOME.expanduser() / PKG_
|
||||||
VENV = str(VENV_PATH.expanduser())
|
VENV = str(VENV_PATH.expanduser())
|
||||||
BIN_DIR = "bin" if os.name != "nt" else "Scripts"
|
BIN_DIR = "bin" if os.name != "nt" else "Scripts"
|
||||||
VENV_BIN = Path(VENV) / Path(BIN_DIR)
|
VENV_BIN = Path(VENV) / Path(BIN_DIR)
|
||||||
POETRY = which("poetry") if which("poetry") else (VENV_BIN / "poetry")
|
|
||||||
CMD_PREFIX = f"{VENV_BIN}/" if ACTIVE_VENV else f"{POETRY} run "
|
TOOLS = ("pdm", "pre-commit")
|
||||||
|
PDM = which("pdm") if which("pdm") else (VENV_BIN / "pdm")
|
||||||
|
CMD_PREFIX = f"{VENV_BIN}/" if ACTIVE_VENV else f"{PDM} run "
|
||||||
PRECOMMIT = which("pre-commit") if which("pre-commit") else f"{CMD_PREFIX}pre-commit"
|
PRECOMMIT = which("pre-commit") if which("pre-commit") else f"{CMD_PREFIX}pre-commit"
|
||||||
PTY = True if os.name != "nt" else False
|
PTY = os.name != "nt"
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def tests(c):
|
def tests(c, deprecations=False):
|
||||||
"""Run the test suite."""
|
"""Run the test suite, optionally with `--deprecations`."""
|
||||||
c.run(f"{CMD_PREFIX}pytest", pty=PTY)
|
deprecations_flag = "" if deprecations else "-W ignore::DeprecationWarning"
|
||||||
|
c.run(f"{CMD_PREFIX}pytest {deprecations_flag}", pty=PTY)
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def black(c, check=False, diff=False):
|
def format(c, check=False, diff=False):
|
||||||
"""Run Black auto-formatter, optionally with `--check` or `--diff`."""
|
"""Run Ruff's auto-formatter, optionally with `--check` or `--diff`."""
|
||||||
check_flag, diff_flag = "", ""
|
check_flag, diff_flag = "", ""
|
||||||
if check:
|
if check:
|
||||||
check_flag = "--check"
|
check_flag = "--check"
|
||||||
if diff:
|
if diff:
|
||||||
diff_flag = "--diff"
|
diff_flag = "--diff"
|
||||||
c.run(f"{CMD_PREFIX}black {check_flag} {diff_flag} {PKG_PATH} tasks.py")
|
c.run(
|
||||||
|
f"{CMD_PREFIX}ruff format {check_flag} {diff_flag} {PKG_PATH} tasks.py", pty=PTY
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def isort(c, check=False, diff=False):
|
def ruff(c, fix=False, diff=False):
|
||||||
"""Ensure imports are sorted according to project standards."""
|
"""Run Ruff to ensure code meets project standards."""
|
||||||
check_flag, diff_flag = "", ""
|
diff_flag, fix_flag = "", ""
|
||||||
if check:
|
if fix:
|
||||||
check_flag = "-c"
|
fix_flag = "--fix"
|
||||||
if diff:
|
if diff:
|
||||||
diff_flag = "--diff"
|
diff_flag = "--diff"
|
||||||
c.run(f"{CMD_PREFIX}isort {check_flag} {diff_flag} .")
|
c.run(f"{CMD_PREFIX}ruff check {diff_flag} {fix_flag} .", pty=PTY)
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def flake8(c):
|
def lint(c, fix=False, diff=False):
|
||||||
"""Check code for PEP8 compliance via Flake8."""
|
|
||||||
c.run(f"{CMD_PREFIX}flake8 {PKG_PATH} tasks.py")
|
|
||||||
|
|
||||||
|
|
||||||
@task
|
|
||||||
def lint(c, diff=False):
|
|
||||||
"""Check code style via linting tools."""
|
"""Check code style via linting tools."""
|
||||||
isort(c, check=True, diff=diff)
|
ruff(c, fix=fix, diff=diff)
|
||||||
black(c, check=True, diff=diff)
|
format(c, check=(not fix), diff=diff)
|
||||||
flake8(c)
|
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
|
|
@ -69,34 +68,34 @@ def tools(c):
|
||||||
"""Install development tools in the virtual environment if not already on PATH."""
|
"""Install development tools in the virtual environment if not already on PATH."""
|
||||||
for tool in TOOLS:
|
for tool in TOOLS:
|
||||||
if not which(tool):
|
if not which(tool):
|
||||||
print(f"** Installing {tool}.")
|
logger.info(f"** Installing {tool} **")
|
||||||
c.run(f"{CMD_PREFIX}pip install {tool}")
|
c.run(f"{CMD_PREFIX}pip install {tool}")
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def precommit(c):
|
def precommit(c):
|
||||||
"""Install pre-commit hooks to `.git/hooks/pre-commit`."""
|
"""Install pre-commit hooks to .git/hooks/pre-commit."""
|
||||||
print("** Installing pre-commit hooks.")
|
logger.info("** Installing pre-commit hooks **")
|
||||||
c.run(f"{PRECOMMIT} install")
|
c.run(f"{PRECOMMIT} install")
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def setup(c):
|
def setup(c):
|
||||||
"""Set up the development environment."""
|
"""Set up the development environment."""
|
||||||
if which("poetry") or ACTIVE_VENV:
|
if which("pdm") or ACTIVE_VENV:
|
||||||
tools(c)
|
tools(c)
|
||||||
c.run(f"{CMD_PREFIX}python -m pip install --upgrade pip")
|
c.run(f"{CMD_PREFIX}python -m pip install --upgrade pip", pty=PTY)
|
||||||
c.run(f"{POETRY} install")
|
c.run(f"{PDM} update --dev", pty=PTY)
|
||||||
precommit(c)
|
precommit(c)
|
||||||
print("\nDevelopment environment should now be set up and ready!\n")
|
logger.info("\nDevelopment environment should now be set up and ready!\n")
|
||||||
else:
|
else:
|
||||||
error_message = """
|
error_message = """
|
||||||
Poetry is not installed, and there is no active virtual environment available.
|
PDM is not installed, and there is no active virtual environment available.
|
||||||
You can either manually create and activate a virtual environment, or you can
|
You can either manually create and activate a virtual environment, or you can
|
||||||
install Poetry via:
|
install PDM via:
|
||||||
|
|
||||||
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
|
curl -sSL https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py | python3 -
|
||||||
|
|
||||||
Once you have taken one of the above two steps, run `invoke setup` again.
|
Once you have taken one of the above two steps, run `invoke setup` again.
|
||||||
""" # noqa: E501
|
""" # noqa: E501
|
||||||
sys.exit(cleandoc(error_message))
|
raise SystemExit(cleandoc(error_message))
|
||||||
|
|
|
||||||
3
tox.ini
3
tox.ini
|
|
@ -1,3 +0,0 @@
|
||||||
[flake8]
|
|
||||||
max-line-length = 88
|
|
||||||
ignore = E203, W503
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue