Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch versioning to be SCM-based #715

Merged
merged 2 commits into from
Nov 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
**

# Except proxy
!.git
!proxy
!requirements.txt
!pyproject.toml
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-release.txt
pip install -r requirements-testing.txt
pip install -r requirements-tunnel.txt
- name: Build
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ repos:
additional_dependencies:
- paramiko == 2.8.0
- types-paramiko == 2.7.3
- types-setuptools == 57.4.2
args:
# FIXME: get rid of missing imports ignore
- --ignore-missing-imports
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
FROM python:3.10-alpine as base
RUN apk add git

FROM base as builder

COPY .git /app/.git
COPY requirements.txt /app/
COPY pyproject.toml /app/
COPY setup.cfg /app/
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ SHELL := /bin/bash

NS ?= abhinavsingh
IMAGE_NAME ?= proxy.py
VERSION ?= v$(shell python -m proxy --version)
#VERSION ?= v$(shell bash -c "python -m setuptools_scm --version \| awk '{print$3}'")
abhinavsingh marked this conversation as resolved.
Show resolved Hide resolved
VERSION ?= v$(shell python -m setuptools_scm --version | awk '{print $$3}' | sed 's/\+/--/')
LATEST_TAG := $(NS)/$(IMAGE_NAME):latest
IMAGE_TAG := $(NS)/$(IMAGE_NAME):$(VERSION)

Expand Down
2 changes: 2 additions & 0 deletions proxy/common/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Build-time setuptools-scm generated version module
/_scm_version.py
3 changes: 3 additions & 0 deletions proxy/common/_scm_version.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This stub file is necessary because `_scm_version.py`
# autogenerated on build and absent on mypy checks time
version: str
11 changes: 11 additions & 0 deletions proxy/common/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""Version definition."""

try:
# pylint: disable=unused-import
from ._scm_version import version as __version__ # noqa: WPS433, WPS436
except ImportError:
from pkg_resources import get_distribution as _get_dist # noqa: WPS433
__version__ = _get_dist('proxy.py').version # noqa: WPS440


__all__ = ('__version__',)
23 changes: 21 additions & 2 deletions proxy/common/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,24 @@
:copyright: (c) 2013-present by Abhinav Singh and contributors.
:license: BSD, see LICENSE for more details.
"""
VERSION = (2, 4, 0)
__version__ = '.'.join(map(str, VERSION[0:3]))
from typing import Tuple, Union

from ._version import __version__ # noqa: WPS436


def _to_int_or_str(inp: str) -> Union[int, str]:
try:
return int(inp)
except ValueError:
return inp


def _split_version_parts(inp: str) -> Tuple[str, ...]:
public_version, _plus, local_version = inp.partition('+')
return (*public_version.split('.'), local_version)


VERSION = tuple(map(_to_int_or_str, _split_version_parts(__version__)))


__all__ = '__version__', 'VERSION'
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@
requires = [
# Essentials
"setuptools",

# Plugins
"setuptools-scm[toml] >= 6",
"setuptools-scm-git-archive >= 1.1",
]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "proxy/common/_scm_version.py"
3 changes: 2 additions & 1 deletion requirements-release.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
twine==3.5.0
setuptools-scm == 6.3.2
twine==3.5.0