Skip to content

Commit

Permalink
use setuptools_scm (#1810)
Browse files Browse the repository at this point in the history
  • Loading branch information
zariiii9003 authored Jul 15, 2024
1 parent acc90c6 commit 78e4f81
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch tags for setuptools-scm
- name: Set up Python
uses: actions/setup-python@v5
with:
Expand Down
6 changes: 5 additions & 1 deletion can/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
messages on a can bus.
"""

import contextlib
import logging
from importlib.metadata import PackageNotFoundError, version
from typing import Any, Dict

__version__ = "4.4.2"
__all__ = [
"ASCReader",
"ASCWriter",
Expand Down Expand Up @@ -124,6 +125,9 @@
from .thread_safe_bus import ThreadSafeBus
from .util import set_logging_level

with contextlib.suppress(PackageNotFoundError):
__version__ = version("python-can")

log = logging.getLogger("can")

rc: Dict[str, Any] = {}
7 changes: 4 additions & 3 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
import ctypes
import os
import sys
from importlib.metadata import version as get_version
from unittest.mock import MagicMock

# If extensions (or modules to document with autodoc) are in another directory,
# 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.
sys.path.insert(0, os.path.abspath(".."))

import can # pylint: disable=wrong-import-position
from can import ctypesutil # pylint: disable=wrong-import-position

# -- General configuration -----------------------------------------------------
Expand All @@ -27,9 +27,10 @@
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The full version, including alpha/beta/rc tags.
release: str = get_version("python-can")
# The short X.Y version.
version = can.__version__.split("-", maxsplit=1)[0]
release = can.__version__
version = ".".join(release.split(".")[:2])

# General information about the project.
project = "python-can"
Expand Down
2 changes: 1 addition & 1 deletion doc/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Manual release steps (deprecated)
---------------------------------

- Create a temporary virtual environment.
- Create a new tag in the repository. Use `semantic versioning <http://semver.org>`__.
- Build with ``pipx run build``
- Create and upload the distribution: ``python setup.py sdist bdist_wheel``.
- Sign the packages with gpg ``gpg --detach-sign -a dist/python_can-X.Y.Z-py3-none-any.whl``.
- Upload with twine ``twine upload dist/python-can-X.Y.Z*``.
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools >= 67.7"]
requires = ["setuptools >= 67.7", "setuptools_scm>=8"]
build-backend = "setuptools.build_meta"

[project]
Expand Down Expand Up @@ -84,8 +84,6 @@ mf4 = ["asammdf>=6.0.0"]

[tool.setuptools.dynamic]
readme = { file = "README.rst" }
version = { attr = "can.__version__" }

[tool.setuptools.package-data]
"*" = ["README.rst", "CONTRIBUTORS.txt", "LICENSE.txt", "CHANGELOG.md"]
doc = ["*.*"]
Expand All @@ -95,6 +93,9 @@ can = ["py.typed"]
[tool.setuptools.packages.find]
include = ["can*"]

[tool.setuptools_scm]
# can be empty if no extra settings are needed, presence enables setuptools_scm

[tool.mypy]
warn_return_any = true
warn_unused_configs = true
Expand Down

0 comments on commit 78e4f81

Please sign in to comment.