Skip to content

Commit

Permalink
Refine
Browse files Browse the repository at this point in the history
  • Loading branch information
hattya committed Feb 20, 2024
1 parent 06601c9 commit 552fbb9
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pyproject.toml
[build-system]
requires = [
"setuptools >= 42.0",
"scmver[toml] >= 1.5",
"scmver[toml] >= 1.7",
]
build-backend = "setuptools.build_meta"
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ readme = "README.rst"
authors = [
{name = "Akinori Hattori", email = "[email protected]"},
]
license = {"text" = "MIT"}
license = {text = "MIT"}
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
Expand Down Expand Up @@ -66,7 +66,9 @@ Homepage = "https://github.com/hattya/scmver"

[tool.setuptools]
include-package-data = false
packages = ["scmver"]
packages = [
"scmver",
]

[tool.setuptools.package-data]
scmver = [
Expand Down
6 changes: 2 additions & 4 deletions scmver/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ def take(d: Mapping[str, str], *keys: str) -> Dict[str, Any]:
return {k: d[k] for k in d if k in keys}

root = os.path.abspath(root)
info = stat(root, **{k: kwargs[k] for k in kwargs if k.endswith('.tag')})
if info:
if info := stat(root, **{k: kwargs[k] for k in kwargs if k.endswith('.tag')}):
version = next_version(info, **take(kwargs, 'spec', 'local', 'version'))
if 'write_to' in kwargs:
generate(os.path.join(root, kwargs['write_to']), version, info, **take(kwargs, 'template'))
Expand Down Expand Up @@ -205,8 +204,7 @@ def stat(path: Path, **kwargs: Any) -> Optional[SCMInfo]:
for name, parse in impls:
if (kwargs.get(name, True)
and os.path.exists(os.path.join(path, name))):
info = parse(path, name=name, **kwargs)
if info:
if info := parse(path, name=name, **kwargs):
return info
p, path = path, os.path.dirname(path)
if path == p:
Expand Down
5 changes: 2 additions & 3 deletions scmver/setuptools.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# scmver.setuptools
#
# Copyright (c) 2019-2023 Akinori Hattori <[email protected]>
# Copyright (c) 2019-2024 Akinori Hattori <[email protected]>
#
# SPDX-License-Identifier: MIT
#
Expand All @@ -18,8 +18,7 @@


def finalize_version(dist: setuptools.Distribution) -> None:
scmver = core.load_project()
if scmver is not None:
if (scmver := core.load_project()) is not None:
dist.metadata.version = core.get_version(**scmver)


Expand Down
5 changes: 2 additions & 3 deletions scmver/subversion.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# scmver.subversion
#
# Copyright (c) 2019-2023 Akinori Hattori <[email protected]>
# Copyright (c) 2019-2024 Akinori Hattori <[email protected]>
#
# SPDX-License-Identifier: MIT
#
Expand Down Expand Up @@ -167,8 +167,7 @@ def version() -> Tuple[Union[int, str], ...]:


def run(*args: str, **kwargs: Any) -> Tuple[Union[str, ET.Element], str]:
xml = '--xml' in args
if xml:
if xml := '--xml' in args:
kwargs['encoding'] = 'utf-8'
out, err = util.exec_((cast(str, util.which('svn')), '--non-interactive') + args, **kwargs)
return ET.fromstring(out.encode('utf-8')) if xml else out, err
3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
formats = zip
group = users

[bdist_wheel]
universal = 1

[flake8]
extend-ignore = E129, E741
max-line-length = 160
Expand Down
23 changes: 11 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def finalize_options(self):
def run(self):
import unittest

self.run_command('egg_info')
# run unittest discover
argv = [sys.argv[0], 'discover', '--start-directory', 'tests']
if self.verbose:
Expand All @@ -40,14 +39,14 @@ def run(self):
unittest.main(None, argv=argv)


cmdclass = {
'test': test,
}

setup(version=scmver.get_version(**{
'root': os.path.dirname(os.path.abspath(__file__)),
'spec': 'micro',
'write_to': os.path.join('scmver', '__version__.py'),
'fallback': 'scmver:__version__',
}),
cmdclass=cmdclass)
setup(
version=scmver.get_version(**{
'root': os.path.dirname(os.path.abspath(__file__)),
'spec': 'micro',
'write_to': os.path.join('scmver', '__version__.py'),
'fallback': 'scmver:__version__',
}),
cmdclass={
'test': test,
},
)
5 changes: 2 additions & 3 deletions tests/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# base
#
# Copyright (c) 2019-2022 Akinori Hattori <[email protected]>
# Copyright (c) 2019-2024 Akinori Hattori <[email protected]>
#
# SPDX-License-Identifier: MIT
#
Expand Down Expand Up @@ -30,8 +30,7 @@ def tearDownClass(cls):
locale.setlocale(locale.LC_ALL, cls._lc)

def check_locale(self):
encoding = locale.getpreferredencoding(False)
if encoding.lower() not in ('cp932', 'euc-jp', 'utf-8'):
if locale.getpreferredencoding(False).lower() not in ('cp932', 'euc-jp', 'utf-8'):
self.skipTest('requires UTF-8 or Japanese locale')

def tempdir(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def test_load_project(self):
[build-system]
requires = [
"setuptools >= 42.0",
"scmver[toml] >= 1.5",
"scmver[toml] >= 1.7",
]
build-backend = "setuptools.build_meta"
"""))
Expand Down
2 changes: 1 addition & 1 deletion tests/test_setuptools.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def finalize_version(self, scmver):
[build-system]
requires = [
"setuptools >= 42.0",
"scmver[toml] >= 1.5",
"scmver[toml] >= 1.7",
]
build-backend = "setuptools.build_meta"
"""))
Expand Down

0 comments on commit 552fbb9

Please sign in to comment.