From 27b4305f789e4811f3675799994ea6f9f5b58152 Mon Sep 17 00:00:00 2001 From: Gregor von Laszewski Date: Fri, 15 Dec 2023 22:37:38 -0500 Subject: [PATCH] simplify setup.py --- cloudmesh/common/__init__.py | 1 + cloudmesh/common/util.py | 43 ++++++++++++++++-------------------- requirements.txt | 8 +------ setup.py | 17 +------------- 4 files changed, 22 insertions(+), 47 deletions(-) create mode 100644 cloudmesh/common/__init__.py diff --git a/cloudmesh/common/__init__.py b/cloudmesh/common/__init__.py new file mode 100644 index 0000000..6a92b24 --- /dev/null +++ b/cloudmesh/common/__init__.py @@ -0,0 +1 @@ +__version__ = '5.0.2' diff --git a/cloudmesh/common/util.py b/cloudmesh/common/util.py index 4d67051..8425a46 100644 --- a/cloudmesh/common/util.py +++ b/cloudmesh/common/util.py @@ -15,18 +15,12 @@ from contextlib import contextmanager from getpass import getpass from pathlib import Path - -import psutil import pyfiglet import requests from cloudmesh.common.console import Console -try: - collectionsAbc = collections.abc -except AttributeError: - collectionsAbc = collections - +from collections.abc import Mapping, Iterable @contextmanager def tempdir(*args, **kwargs): @@ -197,8 +191,11 @@ def is_powershell(): # cmd.exe for CMD # powershell.exe for powershell # bash.exe for git bash - return (psutil.Process(os.getppid()).name() == "powershell.exe") - + if platform.system() == "Windows": + import psutil + return (psutil.Process(os.getppid()).name() == "powershell.exe") + else: + return False def is_cmd_exe(): """ @@ -235,21 +232,19 @@ def path_expand(text, slashreplace=True): def convert_from_unicode(data): - """ - converts unicode data to a string - :param data: the data to convert - :return: - """ - # if isinstance(data, basestring): - - if isinstance(data, str): - return str(data) - elif isinstance(data, collectionsAbc.Mapping): - return dict(map(convert_from_unicode, data.items())) - elif isinstance(data, collectionsAbc.Iterable): - return type(data)(map(convert_from_unicode, data)) - else: - return data + """ + Converts unicode data to a string + :param data: the data to convert + :return: converted data + """ + if isinstance(data, str): + return str(data) + elif isinstance(data, Mapping): + return dict(map(convert_from_unicode, data.items())) + elif isinstance(data, Iterable): + return type(data)(map(convert_from_unicode, data)) + else: + return data def yn_choice(message, default='y', tries=None): diff --git a/requirements.txt b/requirements.txt index 1320b20..a49b461 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,3 @@ -# -# This file is autogenerated by pip-compile -# To update, run: -# -# pip-compile setup.py -# -psutil python-dateutil colorama humanize @@ -17,5 +10,6 @@ six tabulate tqdm pyyaml +psutil pywin32; platform_system == "Windows" pyuac; platform_system == "Windows" diff --git a/setup.py b/setup.py index 4050e6b..819babe 100644 --- a/setup.py +++ b/setup.py @@ -20,19 +20,6 @@ from setuptools import find_packages, find_namespace_packages, setup -def check_python(): - if not sys.version_info.major == 3 and \ - sys.version_info.minor >= 7: - print("Python 3.7 or higher is required.") - - print("You are using Python {}.{}." - .format(sys.version_info.major, - sys.version_info.minor)) - - sys.exit(1) - -check_python() - def readfile(filename): with io.open(filename, encoding="utf-8") as stream: return stream.read() @@ -107,9 +94,7 @@ def readfile(filename): "Operating System :: Microsoft :: Windows :: Windows 10", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.12", "Topic :: Internet", "Topic :: Scientific/Engineering", "Topic :: Software Development :: Libraries",