Skip to content

Switch to pyproject.toml #158

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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
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
160 changes: 148 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,150 @@
*.swp
# Project-specific generated files
docs/build/

# Temp file during Mypy processing
mypy_annotate.dat

/.pytest_cache/
/.coverage
/.cache/
/.eggs/
/.pybuild/
/build/
/docs/build/
__pycache__/
/trio_asyncio.egg-info/
/.pybuild/
/dist
/empty

# MacOS files
**/.DS_Store

# Byte-compiled / optimized / DLL files / editor temp files
__pycache__/
*.py[cod]
*$py.class
*~
\#*
.#*
*.swp

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
pip-wheel-metadata/

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
pyvenv.cfg
.venv/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
.mypy_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# Ruff
.ruff_cache

# Sphinx documentation
doc/_build/

# PyCharm
.idea/
6 changes: 3 additions & 3 deletions CHEATSHEET.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ To run yapf
-----------

* Show what changes yapf wants to make:
``yapf3 -rpd setup.py trio_asyncio tests``
``yapf3 -rpd trio_asyncio tests``

* Apply all changes directly to the source tree:
``yapf -rpi setup.py trio_asyncio tests``
``yapf -rpi trio_asyncio tests``

* Find semantic problems: ``flake8 setup.py trio_asyncio tests``
* Find semantic problems: ``flake8 trio_asyncio tests``


To make a release
Expand Down
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.PHONY: doc test update all tag pypi upload

all:
@echo "Please use 'python setup.py'."
@echo "Please use 'pip install -e .'."
@exit 1

# need to use python3 sphinx-build
Expand Down Expand Up @@ -43,12 +43,14 @@ test:


tag:
@-git tag v$(shell python3 setup.py -V)
@-git tag v$(shell python3 -c "from trio_asyncio._version import __version__; print(__version__)")

pypi: tag
@if python3 setup.py -V 2>/dev/null | grep -qs + >/dev/null 2>&1 ; \
@if python3 python3 -c "from trio_asyncio._version import __version__; print(__version__)" 2>/dev/null | grep -qs + >/dev/null 2>&1 ; \
then echo "You need a clean, tagged tree" >&2; exit 1 ; fi
python3 setup.py sdist upload
python3 -m pip install uv
uv build
uv publish
## version depends on tag, so re-tagging doesn't make sense

upload: pypi
Expand Down
6 changes: 3 additions & 3 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ BLACK_VERSION=24.1.0

if [ "$CHECK_FORMATTING" = "1" ]; then
pip install black==${BLACK_VERSION}
if ! black --check setup.py tests trio_asyncio; then
black --diff setup.py tests trio_asyncio
if ! black --check tests src; then
black --diff tests src
cat <<EOF
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Formatting problems were found (listed above). To fix them, run

pip install black==${BLACK_VERSION}
black setup.py tests trio_asyncio
black tests src

in your local checkout.

Expand Down
77 changes: 68 additions & 9 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,80 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
from __future__ import annotations

import glob
import os
import sys
from pathlib import Path
from typing import TYPE_CHECKING, cast

if TYPE_CHECKING:
from sphinx.application import Sphinx
from sphinx.util.typing import Inventory

# So autodoc can import our package
sys.path.insert(0, os.path.abspath('../..'))

# https://docs.readthedocs.io/en/stable/builds.html#build-environment
if "READTHEDOCS" in os.environ:
import glob
if glob.glob("../../newsfragments/*.*.rst"):
print("-- Found newsfragments; running towncrier --", flush=True)
import subprocess
# Enable reloading with `typing.TYPE_CHECKING` being True
os.environ["SPHINX_AUTODOC_RELOAD_MODULES"] = "1"

# Handle writing newsfragments into the history file.
# We want to keep files unchanged when testing locally.
# So immediately revert the contents after running towncrier,
# then substitute when Sphinx wants to read it in.
history_file = Path("history.rst")

history_new: str | None
if glob.glob("../../newsfragments/*.*.rst"):
print("-- Found newsfragments; running towncrier --", flush=True)
history_orig = history_file.read_bytes()
import subprocess

# In case changes were staged, preserve indexed version.
# This grabs the hash of the current staged version.
history_staged = subprocess.run(
["git", "rev-parse", "--verify", ":docs/source/history.rst"],
check=True,
cwd="../..",
stdout=subprocess.PIPE,
encoding="ascii",
).stdout.strip()
try:
subprocess.run(
["towncrier", "--yes", "--date", "not released yet"],
["towncrier", "--keep", "--date", "not released yet"],
cwd="../..",
check=True,
)
history_new = history_file.read_text("utf8")
finally:
# Make sure this reverts even if a failure occurred.
# Restore whatever was staged.
print(f"Restoring history.rst = {history_staged}")
subprocess.run(
[
"git",
"update-index",
"--cacheinfo",
f"100644,{history_staged},docs/source/history.rst",
],
cwd="../..",
check=False,
)
# And restore the working copy.
history_file.write_bytes(history_orig)
del history_orig # We don't need this any more.
else:
# Leave it as is.
history_new = None


def on_read_source(app: Sphinx, docname: str, content: list[str]) -> None:
"""Substitute the modified history file."""
if docname == "history" and history_new is not None:
# This is a 1-item list with the file contents.
content[0] = history_new


# Warn about all references to unknown targets
nitpicky = True
Expand Down Expand Up @@ -94,8 +152,9 @@
# built documents.
#
# The short X.Y version.
import trio_asyncio
version = trio_asyncio.__version__
import importlib.metadata

version = importlib.metadata.version("trio_asyncio")
# The full version, including alpha/beta/rc tags.
release = version

Expand Down
70 changes: 70 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,73 @@
[build-system]
# setuptools v77 adds PEP 639 support
requires = ["setuptools >= 77"]
build-backend = "setuptools.build_meta"

[project]
name = "trio_asyncio"
description = "A re-implementation of the asyncio mainloop on top of Trio"
authors = [{name = "Matthias Urlichs", email = "[email protected]"}]
license = "MIT OR Apache-2.0"
license-files = ["LICENSE*"]
keywords = [
"async",
"io",
"trio",
"asyncio",
"trio-asyncio"
]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS :: MacOS X",
"Operating System :: POSIX :: BSD",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: System :: Networking",
"Framework :: Trio",
"Framework :: AsyncIO",
]
requires-python = ">=3.9"
dependencies = [
"trio >= 0.22.0",
"outcome",
"sniffio >= 1.3.0",
"exceptiongroup >= 1.0.0; python_version < '3.11'",
"greenlet",
]
dynamic = ["version"]

[project.readme]
file = "README.rst"
content-type = "text/x-rst"

[project.urls]
Homepage = "https://github.com/python-trio/trio-asyncio"
Documentation = "http://trio-asyncio.readthedocs.io"
Changelog = "https://trio-asyncio.readthedocs.io/en/latest/history.html"

[tool.setuptools]
# This means, just install *everything* you see under trio/, even if it
# doesn't look like a source file, so long as it appears in MANIFEST.in:
include-package-data = true

[tool.setuptools.dynamic]
version = {attr = "trio_asyncio._version.__version__"}

[project.optional-dependencies]
tests = [
"pytest>=5.4",
"pytest-trio >= 0.6",
]

[tool.pytest.ini_options]
addopts = ["-p", "no:asyncio"]
filterwarnings = [
Expand Down
Loading