Skip to content

Commit

Permalink
Implement version sourcing from SCM
Browse files Browse the repository at this point in the history
This change integrates setuptools-scm for deriving the dist
version from Git tags
  • Loading branch information
webknjaz committed May 7, 2020
1 parent d273b26 commit 21b6dce
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ per-file-ignores =
# in-tree PEP517 build backend nees a lot of legit `noqa`s
bin/pep517_backend.py: WPS402

# The package has imports exposing private things to the public:
src/pylibsshext/__init__.py: WPS412

# Exclude errors that don't make sense for Cython
# Examples:
# * "E211 whitespace before '('" happening to "typedef int (*smth) ..."
Expand Down
1 change: 1 addition & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ref-names: $Format:%D$
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Force LF line endings for text files
* text=auto eol=lf

# Needed for setuptools-scm-git-archive
.git_archival.txt export-subst
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -393,3 +393,6 @@ $RECYCLE.BIN/

/.github/workflows/.tmp
/.test-results

# setuptools-scm write_to:
/src/pylibsshext/_scm_version.py
22 changes: 20 additions & 2 deletions build-scripts/build-manylinux-wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,26 @@ from __future__ import print_function # needed for file=sys.stderr
import sys
import ${IMPORTABLE_PKG}
from ${IMPORTABLE_PKG}.version import LIBSSH_VERSION
print('libssh version: {!s}\n'.format(LIBSSH_VERSION))
from ${IMPORTABLE_PKG} import (
__full_version__, __libssh_version__,
__version__, __version_info__,
)
print(
'libssh version: {!s}\n'.format(__libssh_version__),
file=sys.stderr,
)
print(
'pylibsshext version: {!s}\n'.format(__version__),
file=sys.stderr,
)
print(
'pylibsshext version tuple: {!r}\n'.format(__version_info__),
file=sys.stderr,
)
print(
'combined pylibsshext version: {!s}\n'.format(__full_version__),
file=sys.stderr,
)
from ${IMPORTABLE_PKG}.channel import Channel
from ${IMPORTABLE_PKG}.errors import LibsshSessionException
Expand Down
10 changes: 8 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ requires = [
"expandvars", # needed by in-tree build backend for env vars interpolation

# Plugins
"setuptools_scm>=1.15",
"setuptools_scm_git_archive>=1.0",
"setuptools_scm[toml]>=3.5",
"setuptools_scm_git_archive>=1.1",
]
backend-path = ["bin"] # requires 'Pip>=20' or 'pep517>=0.6.0'
build-backend = "pep517_backend"
Expand Down Expand Up @@ -58,3 +58,9 @@ keep-going = false
[tool.local.cythonize.kwargs.options]
# This section can contain cythonize options
# NAME = "VALUE"

# ATTENTION: the following section must be kept last in
# `pyproject.toml` because the CI appends one line in
# the end when publishing non-tagged versions.
[tool.setuptools_scm]
write_to = "src/pylibsshext/_scm_version.py"
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ universal = 0

[metadata]
name = ansible-pylibssh
version = 0.0.1.dev1
url = https://github.com/ansible/pylibssh
project_urls =
Bug Tracker = https://github.com/ansible/pylibssh/issues
Expand Down
4 changes: 4 additions & 0 deletions src/pylibsshext/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# -*- coding: utf-8 -*-

"""Python bindings for libssh."""

from ._version import ( # noqa: F401, WPS300, WPS436
__full_version__, __libssh_version__, __version__, __version_info__,
)
File renamed without changes.
18 changes: 18 additions & 0 deletions src/pylibsshext/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-

"""Version definition."""

from ._libssh_version import LIBSSH_VERSION as __libssh_version__ # noqa: N811, WPS300, WPS436

try:
from ._scm_version import version as __version__ # noqa: WPS300, WPS433, WPS436
except ImportError:
from pkg_resources import get_distribution as _get_dist # noqa: WPS433
__version__ = _get_dist('ansible-pylibssh').version # noqa: WPS440


__full_version__ = (
'<pylibsshext v{wrapper_ver!s} with libssh v{backend_ver!s}>'.
format(wrapper_ver=__version__, backend_ver=__libssh_version__)
)
__version_info__ = __version__.split('.')

0 comments on commit 21b6dce

Please sign in to comment.