Skip to content

Commit

Permalink
Merge pull request #48 from ArieLevs/python-support-eol
Browse files Browse the repository at this point in the history
Python support eol
  • Loading branch information
ArieLevs authored Mar 9, 2024
2 parents aa2cfd7 + 7d18272 commit 6a24bac
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 18 deletions.
22 changes: 12 additions & 10 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ jobs:
strategy:
max-parallel: 2
matrix:
python-version: ["3.9", "3.11"]
python-version:
- "3.8" # EOL 2024-10
- "3.12"

steps:
- uses: actions/checkout@v4
Expand All @@ -38,16 +40,16 @@ jobs:

- name: Lint with flake8
run: |
pip install flake8==5.0.4
pip install flake8==7.0.0
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=venv
flake8 . --count --show-source --statistics --exclude=venv
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude=venv
- name: Test with unittest (codecov)
run: |
pip install -r requirements.txt
pip install coverage==6.5
pip install coverage==7.4
# discover all tests in the test directory
coverage run --omit 'venv/*' -m unittest discover test -vv -t .
Expand All @@ -68,7 +70,7 @@ jobs:

- name: Check distribution valid and test publish
run: |
pip install wheel twine
pip install wheel twine setuptools
python setup.py bdist_wheel
twine check dist/*
Expand All @@ -80,10 +82,10 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.12'
- name: Check distribution valid and test publish
run: |
pip install wheel twine
pip install wheel twine setuptools
python setup.py bdist_wheel
twine check dist/*
twine upload dist/* --skip-existing
Expand All @@ -106,7 +108,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.12'
- name: Bump version using self app
id: app_version_bump
run: |
Expand All @@ -115,7 +117,7 @@ jobs:
- name: Publish to global pypi
run: |
pip install wheel twine
pip install wheel twine setuptools
python setup.py bdist_wheel
twine upload dist/*
env:
Expand Down Expand Up @@ -166,7 +168,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.12'
# currently there is no way of passing data between jobs except using artifact,
# this might be an option, but just do another bump for now,
# and anyway setup.py file will need to have some change since we checked out again
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11-slim
FROM python:3.12-slim

LABEL maintainer="Arie Lev <[email protected]>" \
description="Python version bumper"
Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

setuptools.setup(
name="pybump",
version="1.11.6",
version="1.12.0",
author="Arie Lev",
author_email="[email protected]",
description="Python version bumper",
Expand All @@ -24,12 +24,11 @@
install_requires=requirements,
classifiers=[
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
],
Expand Down
8 changes: 5 additions & 3 deletions src/pybump.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from sys import stderr

from ruamel.yaml import YAML, YAMLError
from pkg_resources import get_distribution, DistributionNotFound

try:
from .pybump_version import PybumpVersion
except ImportError:
Expand Down Expand Up @@ -59,8 +59,10 @@ def get_self_version(dist_name):
:return: version as string
"""
try:
return get_distribution(dist_name).version
except DistributionNotFound:
# https://docs.python.org/3/library/importlib.metadata.html#distribution-versions
from importlib.metadata import version
return version(dist_name)
except ModuleNotFoundError:
return 'version not found'


Expand Down
2 changes: 1 addition & 1 deletion src/pybump_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def validate_semantic_string(self, version):
"""
orig_version = version
# only if passed version is non-empty string
if type(version) == str and len(version) != 0:
if isinstance(version, str) and len(version) != 0:
# In case the version if of type 'v2.2.5' then save 'v' prefix and cut it for further 'semver' validation
if version[0] == 'v':
version = version[1:]
Expand Down
10 changes: 10 additions & 0 deletions test/test_simulate_pybump.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,3 +325,13 @@ def test_yaml_sort_comments_preservation(self):
'- a\n'
'- b\n'
'- c\n')

def test_package_version(self):
"""
Test case when user is passing the version flag
"""
# Verify valid string
completed_process_object = run(["python", "src/pybump.py", "--version"],
stdout=PIPE, stderr=PIPE)
self.assertIs(completed_process_object.returncode, 0,
msg="tested 'version' flag that should always return exist 0, even on exceptions")

0 comments on commit 6a24bac

Please sign in to comment.