Skip to content
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
6 changes: 3 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# force LF for pyproject to make hashFiles in CI consistent (windows <3)
# (see https://github.com/actions/runner/issues/498)
pyproject.toml text eol=lf
# - `eol=lf` to make hashFiles in CI consistent (windows <3) (see https://github.com/actions/runner/issues/498)
# - `export-subst` makes git expand/replace the `describe-subst` field value when creating an archive
pyproject.toml text eol=lf export-subst
3 changes: 3 additions & 0 deletions .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ jobs:
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: '0'
persist-credentials: false

- name: Set up environment
Expand Down Expand Up @@ -243,6 +244,7 @@ jobs:
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: '0'
persist-credentials: false

- name: Set up environment
Expand All @@ -256,6 +258,7 @@ jobs:
run: |
nox -s slotscheck

# This only runs if the previous steps were successful, no point in running it otherwise
- name: Try building package
if: (success() || failure()) && steps.setup.outcome == 'success'
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: '0'
persist-credentials: false

- name: Set up environment
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ coverage.xml
__pypackages__/
.python-version
uv.lock
disnake/_version.py
10 changes: 10 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ build:
- UV_PROJECT_ENVIRONMENT=$READTHEDOCS_VIRTUALENV_PATH uv sync --no-default-groups --extra docs
install:
- "true"
post_checkout:
- |
while true; do
TAG=$(git tag --merged HEAD --sort=-committerdate 'v*' | head -n 1)
if [ -n "$TAG" ]; then
echo "✅ Found first reachable tag: $TAG"
break
fi
git fetch --deepen=50
done

sphinx:
configuration: docs/conf.py
Expand Down
7 changes: 0 additions & 7 deletions MANIFEST.in

This file was deleted.

1 change: 1 addition & 0 deletions changelog/1323.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use hatchling and versioningit for building disnake rather than using setuptools.
20 changes: 5 additions & 15 deletions disnake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@
__author__ = "Rapptz, EQUENOS"
__license__ = "MIT"
__copyright__ = "Copyright 2015-present Rapptz, 2021-present EQUENOS"
__version__ = "2.12.0a"

__path__ = __import__("pkgutil").extend_path(__path__, __name__)

import logging
from typing import Literal, NamedTuple

from . import abc as abc, opus as opus, ui as ui, utils as utils # explicitly re-export modules
from ._version import (
VersionInfo as VersionInfo,
__version__ as __version__,
version_info as version_info,
)
from .activity import *
from .app_commands import *
from .appinfo import *
Expand Down Expand Up @@ -77,17 +80,4 @@
from .welcome_screen import *
from .widget import *


class VersionInfo(NamedTuple):
major: int
minor: int
micro: int
releaselevel: Literal["alpha", "beta", "candidate", "final"]
serial: int


# fmt: off
version_info: VersionInfo = VersionInfo(major=2, minor=12, micro=0, releaselevel="alpha", serial=0)
# fmt: on

logging.getLogger(__name__).addHandler(logging.NullHandler())
14 changes: 14 additions & 0 deletions disnake/_version.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SPDX-License-Identifier: MIT

from typing import Literal, NamedTuple

__version__: str

class VersionInfo(NamedTuple):
major: int
minor: int
micro: int
releaselevel: Literal["alpha", "beta", "candidate", "final"]
serial: int

version_info: VersionInfo
10 changes: 9 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import sys
from typing import Any, Optional

import versioningit
from sphinx.application import Sphinx

# If extensions (or modules to document with autodoc) are in another directory,
Expand Down Expand Up @@ -109,9 +110,16 @@
#
# The full version, including alpha/beta/rc tags.
release = importlib.metadata.version("disnake")

# The short X.Y version.
version = ".".join(release.split(".")[:2])
# The release for the next release
next_release = versioningit.get_next_version(os.path.abspath(".."))
next_version = ".".join((next_release).split(".", 2)[:2])

rst_prolog += f"""
.. |vnext_full| replace:: {next_release}
.. |vnext| replace:: {next_version}
"""

_IS_READTHEDOCS = bool(os.getenv("READTHEDOCS"))

Expand Down
5 changes: 3 additions & 2 deletions docs/extensions/versionchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ def run(self):
# If the argument is |vnext|, replace with config version
if self.arguments and self.arguments[0] == "|vnext|":
# Get the version from the Sphinx config
version = self.env.config.version
self.arguments[0] = version
self.arguments[0] = self.env.config.next_version
return super().run()


Expand All @@ -28,6 +27,8 @@ def setup(app: Sphinx) -> SphinxExtensionMeta:
app.add_directive("versionchanged", VersionAddedNext, override=True)
app.add_directive("deprecated", VersionAddedNext, override=True)

app.add_config_value("next_version", None, "env", types=[str])

return {
"parallel_read_safe": True,
"parallel_write_safe": True,
Expand Down
2 changes: 1 addition & 1 deletion docs/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Changelog
This page keeps a detailed human friendly rendering of what's new and changed
in specific versions. Please see :ref:`version_guarantees` for more information.

.. towncrier-draft-entries:: |release| [UNRELEASED]
.. towncrier-draft-entries:: |vnext_full| [UNRELEASED]

.. towncrier release notes start

Expand Down
20 changes: 7 additions & 13 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ def __post_init__(self) -> None:
ExecutionGroup(
sessions=("pyright",),
python=python,
pyright_paths=("disnake", "tests", "examples", "noxfile.py", "setup.py"),
pyright_paths=("disnake", "tests", "examples", "noxfile.py"),
project=True,
extras=("speed", "voice"),
groups=("test", "nox"),
dependencies=("setuptools", "pytz", "requests"), # needed for type checking
dependencies=("pytz", "requests"), # needed for type checking
)
for python in ALL_PYTHONS
),
Expand All @@ -91,17 +91,18 @@ def __post_init__(self) -> None:
# codemodding and pyright
ExecutionGroup(
sessions=("codemod", "autotyping", "pyright"),
pyright_paths=("scripts",),
pyright_paths=("scripts/codemods", "scripts/ci"),
groups=("codemod",),
),
# the other sessions, they don't need pyright, but they need to run
ExecutionGroup(
sessions=("lint", "slotscheck", "check-manifest"),
sessions=("lint", "slotscheck"),
groups=("tools",),
),
# build
ExecutionGroup(
sessions=("build",),
sessions=("build", "pyright"),
pyright_paths=("scripts/versioning.py",),
groups=("build",),
),
## testing
Expand Down Expand Up @@ -250,21 +251,14 @@ def lint(session: nox.Session) -> None:
session.run("prek", "run", "--all-files", *session.posargs)


@nox.session(name="check-manifest")
def check_manifest(session: nox.Session) -> None:
"""Run check-manifest."""
install_deps(session)
session.run("check-manifest", "-v")


@nox.session(python=get_version_for_session("slotscheck"))
def slotscheck(session: nox.Session) -> None:
"""Run slotscheck."""
install_deps(session)
session.run("python", "-m", "slotscheck", "--verbose", "-m", "disnake")


@nox.session(requires=["check-manifest"])
@nox.session
def build(session: nox.Session) -> None:
"""Build a dist."""
install_deps(session)
Expand Down
79 changes: 52 additions & 27 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# SPDX-License-Identifier: MIT

[build-system]
requires = ["setuptools>=77.0.3"]
build-backend = "setuptools.build_meta"
requires = ["hatchling>=1.27.0", "versioningit>=3.3.0,<4"]
build-backend = "hatchling.build"

[project]
name = "disnake"
Expand Down Expand Up @@ -62,6 +62,7 @@ docs = [
"towncrier==23.6.0",
"sphinx-notfound-page==0.8.3",
"sphinxext-opengraph==0.9.1",
"versioningit>=3.3.0,<4",
]

[dependency-groups]
Expand All @@ -84,7 +85,6 @@ ruff = [
tools = [
"prek>=0.2.0",
"slotscheck==0.19.1",
"check-manifest==0.50",
{ include-group = "ruff" },
]
changelog = [
Expand Down Expand Up @@ -112,15 +112,60 @@ test = [
build = [
"build>=1.2.2.post1",
"twine>=6.1.0",
"versioningit>=3.3.0,<4",
]

[tool.setuptools.packages.find]
where = ["."]
include = ["disnake*"]

[tool.uv]
required-version = ">=0.9.2"

[tool.hatch.build]
artifacts = ["disnake/_version.py"]

[tool.hatch.build.targets.sdist]
only-include = [
"disnake",
"scripts/versioning.py",
]

[tool.hatch.version]
source = "versioningit"

[tool.versioningit]
default-version = "0.0.0"

[tool.versioningit.vcs]
method = "git-archive"
describe-subst = "$Format:%(describe:tags,match=v*)$"

[tool.versioningit.format]
distance = "{base_version}a{distance}+{vcs}{rev}"
dirty = "{base_version}+d{build_date:%Y%m%d}"
distance-dirty = "{base_version}a{distance}+{vcs}{rev}.d{build_date:%Y%m%d}"

[tool.versioningit.template-fields]
method = { module = "scripts.versioning", value = "template_fields"}

[tool.versioningit.write]
file = "disnake/_version.py"
template = """
# SPDX-License-Identifier: MIT

from typing import Literal, NamedTuple

__version__ = "{version}"


class VersionInfo(NamedTuple):
major: int
minor: int
micro: int
releaselevel: Literal["alpha", "beta", "candidate", "final"]
serial: int

version_info: VersionInfo = VersionInfo{version_tuple}
"""


[tool.ruff]
line-length = 100

Expand Down Expand Up @@ -415,23 +460,3 @@ exclude_lines = [
"^\\s*raise NotImplementedError$",
"^\\s*\\.\\.\\.$",
]


[tool.check-manifest]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We obviously don't have a MANIFEST.in anymore, but could it be worth considering finding a replacement for check-manifest somehow, that at least checks the sdist against a preset list of files we expect in there?

ignore = [
# CI
".pre-commit-config.yaml",
".readthedocs.yml",
".libcst.codemod.yaml",
"noxfile.py",
# docs
"CONTRIBUTING.md",
"RELEASE.md",
"assets/**",
"changelog/**",
"docs/**",
"examples/**",
# tests
"tests/**",
"scripts/**",
]
Loading