Skip to content

Commit

Permalink
Tasks: Define sandbox tasks in pyproject.toml, using poethepoet
Browse files Browse the repository at this point in the history
The fundamental commands to mostly use are:

- poe format
- poe check
  • Loading branch information
amotl committed Oct 24, 2024
1 parent 3455d9d commit 4c82049
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- uses: yezz123/setup-uv@v4
- run: uv pip install --editable '.[graphql,test]' --system
- run: pytest
- run: uv pip install --editable '.[graphql,develop,test]' --system
- run: poe check
22 changes: 22 additions & 0 deletions DEVELOP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Development Sandbox

Set up a development sandbox.

Acquire sources and install project in editable mode.
```shell
git clone https://github.com/kennethreitz/responder
cd responder
python3 -m venv .venv
source .venv/bin/activate
pip install --editable '.[graphql,develop,release,test]'
```

Invoke linter and software tests.
```shell
poe check
```

Format code.
```shell
poe format
```
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,7 @@ Requests.
- GraphQL support, via Graphene. The goal here is to have any GraphQL query exposable at
any route, magically.
- Provide an official way to run webpack.

## Development

See [Development Sandbox](DEVELOP.md).
47 changes: 47 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,50 @@ testpaths = [
markers = [
]
xfail_strict = true

[tool.poe.tasks]

check = [
"lint",
"test",
]

docs-autobuild = [
{ cmd = "sphinx-autobuild --open-browser --watch docs/source docs/build" },
]
docs-html = [
{ cmd = "sphinx-build -W --keep-going docs/source docs/build" },
]
docs-linkcheck = [
{ cmd = "sphinx-build -W --keep-going -b linkcheck docs/source docs/build" },
]

format = [
{ cmd = "ruff format ." },
# Configure Ruff not to auto-fix (remove!):
# unused imports (F401), unused variables (F841), `print` statements (T201), and commented-out code (ERA001).
{ cmd = "ruff check --fix --ignore=ERA --ignore=F401 --ignore=F841 --ignore=T20 --ignore=ERA001 ." },
{ cmd = "pyproject-fmt --keep-full-version pyproject.toml" },
]

lint = [
{ cmd = "ruff format --check ." },
{ cmd = "ruff check ." },
{ cmd = "validate-pyproject pyproject.toml" },
# { cmd = "mypy" },
]

release = [
{ cmd = "python -m build" },
{ cmd = "twine upload --skip-existing dist/*" },
]

[tool.poe.tasks.test]
cmd = "pytest"
help = "Invoke software tests"

[tool.poe.tasks.test.args.expression]
options = [ "-k" ]

[tool.poe.tasks.test.args.marker]
options = [ "-m" ]
37 changes: 2 additions & 35 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"requests",
"requests-toolbelt",
"rfc3986",
"typesystem<0.3",
"starlette[full]",
"typesystem<0.3",
"uvicorn[standard]",
"whitenoise",
]
Expand Down Expand Up @@ -71,39 +71,6 @@ def run(self):
os.system("dpkg-buildpackage -rfakeroot -uc -us")


class UploadCommand(Command):
"""Support setup.py publish."""

description = "Build and publish the package."
user_options = []

@staticmethod
def status(s):
"""Prints things in bold."""
print("\033[1m{0}\033[0m".format(s))

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
try:
self.status("Removing previous builds…")
rmtree(os.path.join(here, "dist"))
except FileNotFoundError:
pass
self.status("Building Source distribution…")
os.system("{0} setup.py sdist bdist_wheel".format(sys.executable))
self.status("Uploading the package to PyPI via Twine…")
os.system("twine upload dist/*")
self.status("Pushing git tags…")
os.system("git tag v{0}".format(about["__version__"]))
os.system("git push --tags")
sys.exit()


setup(
name="responder",
version=about["__version__"],
Expand Down Expand Up @@ -141,5 +108,5 @@ def run(self):
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Internet :: WWW/HTTP",
],
cmdclass={"upload": UploadCommand, "deb": DebCommand},
cmdclass={"deb": DebCommand},
)

0 comments on commit 4c82049

Please sign in to comment.