Skip to content

Commit

Permalink
Inline 'get_release_and_version' definition (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarbuzzi authored Jan 13, 2025
1 parent 9938a6e commit e05d8f4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 50 deletions.
38 changes: 32 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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(
Expand All @@ -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"
Expand All @@ -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"]

Expand Down
44 changes: 0 additions & 44 deletions utils/artifacts.py

This file was deleted.

0 comments on commit e05d8f4

Please sign in to comment.