From e05d8f4e817d0a47ef73b8cbcf3ae828757973ef Mon Sep 17 00:00:00 2001 From: Domenic Barbuzzi Date: Mon, 13 Jan 2025 13:35:01 -0500 Subject: [PATCH] Inline 'get_release_and_version' definition (#240) --- setup.py | 38 ++++++++++++++++++++++++++++++++------ utils/artifacts.py | 44 -------------------------------------------- 2 files changed, 32 insertions(+), 50 deletions(-) delete mode 100644 utils/artifacts.py diff --git a/setup.py b/setup.py index eed23404..5206d75b 100644 --- a/setup.py +++ b/setup.py @@ -1,11 +1,11 @@ # Copyright (c) 2021 - present / Neuralmagic, Inc. All Rights Reserved. -# +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,7 +15,33 @@ import os from setuptools import setup, find_packages from typing import List, Dict, Tuple -from utils.artifacts import get_release_and_version + + +def get_release_and_version(package_path: str) -> Tuple[bool, bool, str, str, str, str]: + """ + Load version and release info from compressed-tensors package + """ + # compressed-tensors/src/compressed_tensors/version.py always exists, default source of truth + version_path = os.path.join(package_path, "version.py") + + # exec() cannot set local variables so need to manually + locals_dict = {} + exec(open(version_path).read(), globals(), locals_dict) + is_release = locals_dict.get("is_release", False) + version = locals_dict.get("version", "unknown") + version_major = locals_dict.get("version_major", "unknown") + version_minor = locals_dict.get("version_minor", "unknown") + version_bug = locals_dict.get("version_bug", "unknown") + + print(f"Loaded version {version} from {version_path}") + + return ( + is_release, + version, + version_major, + version_minor, + version_bug, + ) package_path = os.path.join( @@ -35,7 +61,7 @@ _PACKAGE_NAME = "compressed-tensors" else: _PACKAGE_NAME = "compressed-tensors-nightly" - + def _setup_long_description() -> Tuple[str, str]: return open("README.md", "r", encoding="utf-8").read(), "text/markdown" @@ -44,7 +70,7 @@ def _setup_packages() -> List: return find_packages( "src", include=["compressed_tensors", "compressed_tensors.*"], exclude=["*.__pycache__.*"] ) - + def _setup_install_requires() -> List: return ["torch>=1.7.0", "transformers", "pydantic>=2.0"] diff --git a/utils/artifacts.py b/utils/artifacts.py deleted file mode 100644 index d16e0f44..00000000 --- a/utils/artifacts.py +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright (c) 2021 - present / Neuralmagic, Inc. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -import os -from typing import Tuple - - -def get_release_and_version(package_path: str) -> Tuple[bool, bool, str, str, str, str]: - """ - Load version and release info from deepsparse package - """ - # deepsparse/src/deepsparse/version.py always exists, default source of truth - version_path = os.path.join(package_path, "version.py") - - # exec() cannot set local variables so need to manually - locals_dict = {} - exec(open(version_path).read(), globals(), locals_dict) - is_release = locals_dict.get("is_release", False) - version = locals_dict.get("version", "unknown") - version_major = locals_dict.get("version_major", "unknown") - version_minor = locals_dict.get("version_minor", "unknown") - version_bug = locals_dict.get("version_bug", "unknown") - - print(f"Loaded version {version} from {version_path}") - - return ( - is_release, - version, - version_major, - version_minor, - version_bug, - )