Skip to content

Commit

Permalink
fix pypa#840 - return to setuptools
Browse files Browse the repository at this point in the history
  • Loading branch information
RonnyPfannschmidt authored and OlenaYefymenko committed May 29, 2023
1 parent 9ee3510 commit 2c26c5f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ breaking
* turn Configuration into a dataclass
* require configuration to always pass into helpers
* hide file-finders implementation in private module
* migrate to hatchling
* renamed setuptools_scm.hacks to setuptools_scm.fallbacks and drop support for pip-egg-info
* remove trace function and use logging instead
* unify distance=None and distance=0 they should mean the same
Expand Down
16 changes: 16 additions & 0 deletions _own_version_helper.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
"""
this module is a hack only in place to allow for setuptools
to use the attribute for the versions
it works only if the backend-path of the build-system section
from pyproject.toml is respected
"""
from __future__ import annotations

import logging
from typing import Callable

from setuptools.build_meta import * # noqa

from setuptools_scm import _types as _t
from setuptools_scm import Configuration
from setuptools_scm import get_version
Expand Down Expand Up @@ -48,3 +53,14 @@ def scm_version() -> str:
version_scheme=guess_next_dev_version,
local_scheme=get_local_node_and_date,
)


version: str


def __getattr__(name: str) -> str:
if name == "version":
global version
version = scm_version()
return version
raise AttributeError(name)
21 changes: 13 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@


[build-system]
build-backend = "hatchling.build"
build-backend = "_own_version_helper"
requires = [
"hatchling>=1.10",
'importlib-metadata>=4.6; python_version < "3.10"',
"packaging>=20",
"setuptools>=55",
"rich",
"setuptools>=61",
'tomli; python_version < "3.11"',
'typing_extensions; python_version < "3.8"',
]
backend-path = [
".",
"src",
]

[project]
name = "setuptools-scm"
Expand Down Expand Up @@ -94,8 +98,9 @@ PKG-INFO = "setuptools_scm.fallbacks:parse_pkginfo"
"python-simplified-semver" = "setuptools_scm.version:simplified_semver_version"
"release-branch-semver" = "setuptools_scm.version:release_branch_semver_version"

[tool.hatch.version]
source = "code"
path = "_own_version_helper.py"
search-paths = ["src"]
expression = "scm_version()"
[tool.setuptools.packages.find]
where = ["src"]
namespaces = false

[tool.setuptools.dynamic]
version = { attr = "_own_version_helper.version"}

0 comments on commit 2c26c5f

Please sign in to comment.