Skip to content

Commit 194345d

Browse files
committed
Create semver package
Split up changelog to make more sense. Incorporate suggestions and increase coverage to 100% in non-deprecated parts. Bump the dev part Co-authored-by: Tom Schraitle <tomschr@users.noreply.github.com> Run docformatter Fix path for docformatter Add stubby setup.py file for compatibility with python 3.6 Run black Deprecate cli functions imported from root Revert to `pysemver` as console script. Refactor __main__.py * add type hints for correctness * run black Refactor and integrate suggestion from @tomschr * Create :file:`src/semver/cli.py` for all CLI methods * Create :file:`src/semver/_deprecated.py` for the ``deprecated`` decorator and other deprecated functions * Create :file:`src/semver/__main__.py` to allow calling the CLI using :command:`python -m semver` * Create :file:`src/semver/_types.py` to hold type aliases * Create :file:`src/semver/version.py` to hold the :class:`VersionInfo` class and its utility functions * Create :file:`src/semver/__about__.py` for all the metadata variables Adapted infrastructure code to the new project layout. * Replace :file:`setup.py` with :file:`setup.cfg` because the :file:`setup.cfg` is easier to use * Adapt documentation code snippets where needed * Adapt tests * Changed the ``deprecated`` to hardcode the ``semver`` package name in the warning. Change path for docformatter and run it. Remove pyi inclusion from black sine we aren't using them Clean up after messy rebase Run black
1 parent ddf2b30 commit 194345d

21 files changed

+808
-732
lines changed

changelog.d/169.deprecation.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Deprecate CLI functions not imported from ``semver.cli``.

changelog.d/169.feature.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Create semver package and split code among different modules in the packages.
2+
3+
* Remove :file:`semver.py`
4+
* Create :file:`src/semver/__init__.py`
5+
* Create :file:`src/semver/cli.py` for all CLI methods
6+
* Create :file:`src/semver/_deprecated.py` for the ``deprecated`` decorator and other deprecated functions
7+
* Create :file:`src/semver/__main__.py` to allow calling the CLI using :command:`python -m semver`
8+
* Create :file:`src/semver/_types.py` to hold type aliases
9+
* Create :file:`src/semver/version.py` to hold the :class:`VersionInfo` class and its utility functions
10+
* Create :file:`src/semver/__about__.py` for all the metadata variables
11+

changelog.d/169.trivial.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Adapted infrastructure code to the new project layout.
2+
3+
* Replace :file:`setup.py` with :file:`setup.cfg` because the :file:`setup.cfg` is easier to use
4+
* Adapt documentation code snippets where needed
5+
* Adapt tests
6+
* Changed the ``deprecated`` to hardcode the ``semver`` package name in the warning.
7+
8+
Increase coverage to 100% for all non-deprecated APIs

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import os
2020
import sys
2121

22-
sys.path.insert(0, os.path.abspath(".."))
22+
sys.path.insert(0, os.path.abspath("../src/"))
2323

2424
from semver import __version__ # noqa: E402
2525

docs/usage.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Getting the Version of semver
2626
To know the version of semver itself, use the following construct::
2727

2828
>>> semver.__version__
29-
'3.0.0-dev.1'
29+
'3.0.0-dev.2'
3030

3131

3232
Creating a Version

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ build-backend = "setuptools.build_meta"
1010
[tool.black]
1111
line-length = 88
1212
target-version = ['py36', 'py37', 'py38']
13-
include = '\.pyi?$'
1413
# diff = true
1514
exclude = '''
1615
(

setup.cfg

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,46 @@
1+
[metadata]
2+
name = semver
3+
version = attr: semver.__about__.__version__
4+
description = attr: semver.__about__.__description__
5+
long_description = file: README.rst
6+
author = attr: semver.__about__.__author__
7+
author_email = attr: semver.__about__.__author_email__
8+
maintainer = attr: semver.__about__.__maintainer__
9+
maintainer_email = attr: semver.__about__.__maintainer_email__
10+
url = https://github.com/python-semver/python-semver
11+
download_url = https://github.com/python-semver/python-semver/downloads
12+
project_urls =
13+
Documentation = https://python-semver.rtfd.io
14+
Releases = https://github.com/python-semver/python-semver/releases
15+
Bug Tracker = https://github.com/python-semver/python-semver/issues
16+
classifiers =
17+
Environment :: Web Environment
18+
Intended Audience :: Developers
19+
License :: OSI Approved :: BSD License
20+
Operating System :: OS Independent
21+
Programming Language :: Python
22+
Programming Language :: Python :: 3
23+
Programming Language :: Python :: 3.6
24+
Programming Language :: Python :: 3.7
25+
Programming Language :: Python :: 3.8
26+
Programming Language :: Python :: 3.9
27+
Topic :: Software Development :: Libraries :: Python Modules
28+
license = BSD
29+
30+
[options]
31+
package_dir =
32+
=src
33+
packages = find:
34+
python_requires = >=3.6.*
35+
include_package_data = True
36+
37+
[options.entry_points]
38+
console_scripts =
39+
pysemver = semver.cli:main
40+
41+
[options.packages.find]
42+
where = src
43+
144
[tool:pytest]
245
norecursedirs = .git build .env/ env/ .pyenv/ .tmp/ .eggs/ venv/
346
testpaths = tests docs
@@ -15,13 +58,14 @@ addopts =
1558
max-line-length = 88
1659
ignore = F821,W503
1760
exclude =
18-
.env,
19-
venv,
20-
.eggs,
21-
.tox,
22-
.git,
23-
__pycache__,
24-
build,
61+
src/semver/__init__.py
62+
.env
63+
venv
64+
.eggs
65+
.tox
66+
.git
67+
__pycache__
68+
build
2569
dist
2670
docs
2771
conftest.py
@@ -32,6 +76,7 @@ count = False
3276
max-line-length = 88
3377
statistics = True
3478
exclude =
79+
src/semver/__init__.py
3580
.env,
3681
.eggs,
3782
.tox,

setup.py

100755100644
Lines changed: 2 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,4 @@
11
#!/usr/bin/env python3
2-
# import semver as package
3-
from os.path import dirname, join
4-
from setuptools import setup
5-
import re
2+
import setuptools
63

7-
8-
VERSION_MATCH = re.compile(r"__version__ = ['\"]([^'\"]*)['\"]", re.M)
9-
10-
11-
def read_file(filename):
12-
"""
13-
Read RST file and return content
14-
15-
:param filename: the RST file
16-
:return: content of the RST file
17-
"""
18-
with open(join(dirname(__file__), filename)) as f:
19-
return f.read()
20-
21-
22-
def find_meta(meta):
23-
"""
24-
Extract __*meta*__ from META_FILE.
25-
"""
26-
meta_match = re.search(
27-
r"^__{meta}__ = ['\"]([^'\"]*)['\"]".format(meta=meta), META_FILE, re.M
28-
)
29-
if meta_match:
30-
return meta_match.group(1)
31-
raise RuntimeError("Unable to find __{meta}__ string.".format(meta=meta))
32-
33-
34-
NAME = "semver"
35-
META_FILE = read_file("semver.py")
36-
37-
38-
# -----------------------------------------------------------------------------
39-
setup(
40-
name=NAME,
41-
version=find_meta("version"),
42-
description=find_meta("description").strip(),
43-
long_description=read_file("README.rst"),
44-
long_description_content_type="text/x-rst",
45-
author=find_meta("author"),
46-
author_email=find_meta("author_email"),
47-
url="https://github.com/python-semver/python-semver",
48-
download_url="https://github.com/python-semver/python-semver/downloads",
49-
project_urls={
50-
"Documentation": "https://python-semver.rtfd.io",
51-
"Releases": "https://github.com/python-semver/python-semver/releases",
52-
"Bug Tracker": "https://github.com/python-semver/python-semver/issues",
53-
},
54-
py_modules=[NAME],
55-
include_package_data=True,
56-
license="BSD",
57-
classifiers=[
58-
# See https://pypi.org/pypi?%3Aaction=list_classifiers
59-
"Environment :: Web Environment",
60-
"Intended Audience :: Developers",
61-
"License :: OSI Approved :: BSD License",
62-
"Operating System :: OS Independent",
63-
"Programming Language :: Python",
64-
"Programming Language :: Python :: 3",
65-
"Programming Language :: Python :: 3.6",
66-
"Programming Language :: Python :: 3.7",
67-
"Programming Language :: Python :: 3.8",
68-
"Programming Language :: Python :: 3.9",
69-
# "Programming Language :: Python :: Implementation :: PyPy",
70-
"Topic :: Software Development :: Libraries :: Python Modules",
71-
],
72-
python_requires=">=3.6.*",
73-
tests_require=["tox", "virtualenv", "wheel"],
74-
entry_points={"console_scripts": ["pysemver = semver:main"]},
75-
)
4+
setuptools.setup() # For compatibility with python 3.6

src/semver/__about__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
__version__ = "3.0.0-dev.2"
2+
__author__ = "Kostiantyn Rybnikov"
3+
__author_email__ = "k-bx@k-bx.com"
4+
__maintainer__ = ["Sebastien Celles", "Tom Schraitle"]
5+
__maintainer_email__ = "s.celles@gmail.com"
6+
__description__ = "Python helper for Semantic Versioning (http://semver.org)"
7+
8+
SEMVER_SPEC_VERSION = "2.0.0"

src/semver/__init__.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from ._deprecated import (
2+
bump_build,
3+
bump_major,
4+
bump_minor,
5+
bump_patch,
6+
bump_prerelease,
7+
compare,
8+
finalize_version,
9+
format_version,
10+
match,
11+
max_ver,
12+
min_ver,
13+
parse,
14+
parse_version_info,
15+
replace,
16+
cmd_bump,
17+
cmd_compare,
18+
cmd_nextver,
19+
cmd_check,
20+
createparser,
21+
process,
22+
main,
23+
)
24+
from .version import VersionInfo
25+
from .__about__ import (
26+
__version__,
27+
__author__,
28+
__maintainer__,
29+
__author_email__,
30+
__description__,
31+
__maintainer_email__,
32+
SEMVER_SPEC_VERSION,
33+
)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy