Merge pull request #229 from maxhgerlach/local-version

Allow adding an optional local version to the package version
This commit is contained in:
Tri Dao 2023-05-19 11:43:24 -04:00 committed by GitHub
commit 3cad2ab35d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -0,0 +1 @@
__version__ = "1.0.5"

View File

@ -2,6 +2,8 @@
import sys
import warnings
import os
import re
import ast
from pathlib import Path
from packaging.version import parse, Version
@ -160,9 +162,19 @@ ext_modules.append(
)
)
def get_package_version():
with open(Path(this_dir) / "flash_attn" / "__init__.py", "r") as f:
version_match = re.search(r"^__version__\s*=\s*(.*)$", f.read(), re.MULTILINE)
public_version = ast.literal_eval(version_match.group(1))
local_version = os.environ.get("FLASH_ATTN_LOCAL_VERSION")
if local_version:
return f"{public_version}+{local_version}"
else:
return str(public_version)
setup(
name="flash_attn",
version="1.0.5",
version=get_package_version(),
packages=find_packages(
exclude=("build", "csrc", "include", "tests", "dist", "docs", "benchmarks", "flash_attn.egg-info",)
),