Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/deploy-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
types: [ published ]
jobs:
tox-ci:
uses: QualiSystems/.github/.github/workflows/package-tox-py-37-39.yml@master
uses: QualiSystems/.github/.github/workflows/package-tox-py-39.yml@master
pypi-deploy:
needs: tox-ci
uses: QualiSystems/.github/.github/workflows/package-deploy-pypi.yml@master
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/github-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- master
jobs:
tox-ci:
uses: QualiSystems/.github/.github/workflows/package-tox-py-37-39.yml@master
uses: QualiSystems/.github/.github/workflows/package-tox-py-39.yml@master
pypi-deploy:
needs: tox-ci
uses: QualiSystems/.github/.github/workflows/package-github-release.yml@master
2 changes: 1 addition & 1 deletion .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ on:
- master
jobs:
tox-ci:
uses: QualiSystems/.github/.github/workflows/package-tox-py-37-39.yml@master
uses: QualiSystems/.github/.github/workflows/package-tox-py-39.yml@master
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ colorama
giturlparse.py
ruamel.yaml
cryptography
setuptools; python_version >= '3.12'
packaging
9 changes: 6 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ def get_file_content(file_name):
"vcenter cmp cloudshell quali command-line cli",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Software Development :: Libraries",
"License :: OSI Approved :: Apache Software License",
],
python_requires=">=2.7",
python_requires=">=3.8",
test_suite="tests",
)
7 changes: 3 additions & 4 deletions shellfoundry/bootstrap.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

import importlib.metadata

import click
import pkg_resources

from shellfoundry.commands.config_command import ConfigCommandExecutor
from shellfoundry.commands.delete_command import DeleteCommandExecutor
Expand All @@ -27,9 +28,7 @@ def cli():
@cli.command()
def version():
"""Displays the shellfoundry version."""
click.echo(
"shellfoundry version " + pkg_resources.get_distribution("shellfoundry").version
)
click.echo("shellfoundry version " + importlib.metadata.version("shellfoundry"))


@cli.command() # noqa: A001
Expand Down
2 changes: 1 addition & 1 deletion shellfoundry/commands/new_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import click
from cloudshell.rest.exceptions import FeatureUnavailable
from pkg_resources import parse_version
from packaging.version import parse as parse_version
from requests.exceptions import SSLError

from ..exceptions import FatalError
Expand Down
12 changes: 6 additions & 6 deletions shellfoundry/utilities/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

import importlib.metadata
import json

import pkg_resources
import requests

try:
Expand All @@ -16,7 +16,7 @@
except ImportError:
from urllib2 import HTTPError, URLError

from distutils.version import StrictVersion
from packaging.version import Version

from shellfoundry import PACKAGE_NAME
from shellfoundry.exceptions import ShellFoundryVersionException
Expand All @@ -37,23 +37,23 @@ def __init__(self, url):


def get_installed_version(package_name):
return pkg_resources.get_distribution(package_name).version
return importlib.metadata.version(package_name)


def is_index_version_greater_than_current():
MAJOR_INDEX = 0

installed, index = (
StrictVersion(get_installed_version(PACKAGE_NAME)),
StrictVersion(max_version_from_index()),
Version(get_installed_version(PACKAGE_NAME)),
Version(max_version_from_index()),
)
is_major_release = False

is_greater_version = index > installed
if (
is_greater_version
and get_index_of_biggest_component_between_two_versions(
index.version, installed.version
index.release, installed.release
)
== MAJOR_INDEX
):
Expand Down
4 changes: 2 additions & 2 deletions shellfoundry/utilities/shell_package_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def _add_new_shell(self, client, package_full_path):
def _parse_installation_error(self, base_message, error):
error_str = str(error)
cs_message = error_str # Default to full error string

try:
# Check if it's a PackagingRestApiError with embedded JSON response
if "response:" in error_str:
Expand All @@ -232,7 +232,7 @@ def _parse_installation_error(self, base_message, error):
except (json.JSONDecodeError, KeyError, ValueError):
# If JSON parsing fails, keep the full error string
pass

return "{}. CloudShell responded with: '{}'".format(base_message, cs_message)

def _increase_pbar(self, pbar, time_wait):
Expand Down
2 changes: 1 addition & 1 deletion shellfoundry/utilities/standards/standards_versions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

from pkg_resources import parse_version
from packaging.version import parse as parse_version


class StandardVersionsFactory(object):
Expand Down
8 changes: 2 additions & 6 deletions shellfoundry/utilities/template_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@
import click
import requests
import yaml
from pkg_resources import parse_version

try:
from pkg_resources._vendor.packaging.version import Version
except ImportError:
from packaging.version import Version
from packaging.version import Version
from packaging.version import parse as parse_version

from .filters import CompositeFilter

Expand Down
4 changes: 2 additions & 2 deletions shellfoundry/utilities/template_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@


def is_version(vstr):
from distutils.version import StrictVersion
from packaging.version import Version

try:
StrictVersion(vstr)
Version(vstr)
return True
except Exception:
return False
Expand Down
10 changes: 4 additions & 6 deletions tests/test_bootstrap.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
import traceback
import unittest
from unittest.mock import MagicMock, patch
from unittest.mock import patch

from click.testing import CliRunner

Expand Down Expand Up @@ -29,11 +29,9 @@ def setUp(self):
def tearDown(self):
pass

@patch("shellfoundry.bootstrap.pkg_resources")
def test_version(self, test_dist):
obj = MagicMock()
obj.version = "shellfoundry_version"
test_dist.get_distribution = MagicMock(return_value=obj)
@patch("importlib.metadata.version")
def test_version(self, version_mock):
version_mock.return_value = "shellfoundry_version"
result = self.runner.invoke(version)

assert result.exit_code == 0
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# and then run "tox" from this directory.
[tox]
envlist =
py{37,39}-{master}
py39-{master}
pre-commit
build
distshare = dist
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.28
1.2.29
Loading