Skip to content

Commit

Permalink
[BUGFIX] fix VERSION file not found error, which installed by pip
Browse files Browse the repository at this point in the history
  • Loading branch information
senlyu163 committed Jan 22, 2025
1 parent 04fa448 commit 3fcedba
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

16 changes: 1 addition & 15 deletions bitblas/version.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

import os

# Get the absolute path of the current Python script's directory
current_dir = os.path.dirname(os.path.abspath(__file__))

# Get the absolute path of the project root directory (one level above the current directory)
project_root_dir = os.path.abspath(os.path.join(current_dir, ".."))

# Define the path to the VERSION file located in the project root directory
version_file_path = os.path.join(project_root_dir, "VERSION")

# Read and store the version information from the VERSION file
# Use 'strip()' to remove any leading/trailing whitespace or newline characters
with open(version_file_path, "r") as version_file:
__version__ = version_file.read().strip()
__version__ = "0.1.0"

# Define the public API for the module
__all__ = ["__version__"]
11 changes: 7 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,16 @@ def find_version(version_file_path: str) -> str:
Adapted from https://github.com/ray-project/ray/blob/0b190ee1160eeca9796bc091e07eaebf4c85b511/python/setup.py
"""
# Read and store the version information from the VERSION file
# Read and store the version information from the version.py file
# Use 'strip()' to remove any leading/trailing whitespace or newline characters
if not os.path.exists(version_file_path):
raise FileNotFoundError(f"Version file not found at {version_file_path}")
with open(version_file_path, "r") as version_file:
version = version_file.read().strip()
return version
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")


def get_nvcc_cuda_version():
Expand All @@ -67,7 +70,7 @@ def get_nvcc_cuda_version():


def get_bitblas_version(with_cuda=True, with_system_info=True) -> str:
version = find_version(get_path(".", "VERSION"))
version = find_version(get_path(".", "bitblas", "version.py"))
local_version_parts = []
if with_system_info:
local_version_parts.append(get_system_info().replace("-", "."))
Expand Down Expand Up @@ -271,7 +274,7 @@ def run(self):
shutil.copy2(source_dir, target_dir)

# copy compoable kernel to the package directory
CONFIG_ITEMS = ["VERSION", "README.md", "LICENSE"]
CONFIG_ITEMS = ["README.md", "LICENSE"]
for item in CONFIG_ITEMS:
source_dir = os.path.join(ROOT_DIR, item)
target_dir = os.path.join(self.build_lib, PACKAGE_NAME, item)
Expand Down

0 comments on commit 3fcedba

Please sign in to comment.