Skip to content

Commit e05d8f4

Browse files
authored
Inline 'get_release_and_version' definition (#240)
1 parent 9938a6e commit e05d8f4

File tree

2 files changed

+32
-50
lines changed

2 files changed

+32
-50
lines changed

setup.py

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Copyright (c) 2021 - present / Neuralmagic, Inc. All Rights Reserved.
2-
#
2+
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
55
# You may obtain a copy of the License at
6-
#
6+
#
77
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
8+
#
99
# Unless required by applicable law or agreed to in writing,
1010
# software distributed under the License is distributed on an "AS IS" BASIS,
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,7 +15,33 @@
1515
import os
1616
from setuptools import setup, find_packages
1717
from typing import List, Dict, Tuple
18-
from utils.artifacts import get_release_and_version
18+
19+
20+
def get_release_and_version(package_path: str) -> Tuple[bool, bool, str, str, str, str]:
21+
"""
22+
Load version and release info from compressed-tensors package
23+
"""
24+
# compressed-tensors/src/compressed_tensors/version.py always exists, default source of truth
25+
version_path = os.path.join(package_path, "version.py")
26+
27+
# exec() cannot set local variables so need to manually
28+
locals_dict = {}
29+
exec(open(version_path).read(), globals(), locals_dict)
30+
is_release = locals_dict.get("is_release", False)
31+
version = locals_dict.get("version", "unknown")
32+
version_major = locals_dict.get("version_major", "unknown")
33+
version_minor = locals_dict.get("version_minor", "unknown")
34+
version_bug = locals_dict.get("version_bug", "unknown")
35+
36+
print(f"Loaded version {version} from {version_path}")
37+
38+
return (
39+
is_release,
40+
version,
41+
version_major,
42+
version_minor,
43+
version_bug,
44+
)
1945

2046

2147
package_path = os.path.join(
@@ -35,7 +61,7 @@
3561
_PACKAGE_NAME = "compressed-tensors"
3662
else:
3763
_PACKAGE_NAME = "compressed-tensors-nightly"
38-
64+
3965

4066
def _setup_long_description() -> Tuple[str, str]:
4167
return open("README.md", "r", encoding="utf-8").read(), "text/markdown"
@@ -44,7 +70,7 @@ def _setup_packages() -> List:
4470
return find_packages(
4571
"src", include=["compressed_tensors", "compressed_tensors.*"], exclude=["*.__pycache__.*"]
4672
)
47-
73+
4874
def _setup_install_requires() -> List:
4975
return ["torch>=1.7.0", "transformers", "pydantic>=2.0"]
5076

utils/artifacts.py

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)