Skip to content

Commit 3cad2ab

Browse files
authored
Merge pull request PaddlePaddle#229 from maxhgerlach/local-version
Allow adding an optional local version to the package version
2 parents 40a25c8 + 31f78a9 commit 3cad2ab

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

flash_attn/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "1.0.5"

setup.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import sys
33
import warnings
44
import os
5+
import re
6+
import ast
57
from pathlib import Path
68
from packaging.version import parse, Version
79

@@ -160,9 +162,19 @@ def append_nvcc_threads(nvcc_extra_args):
160162
)
161163
)
162164

165+
def get_package_version():
166+
with open(Path(this_dir) / "flash_attn" / "__init__.py", "r") as f:
167+
version_match = re.search(r"^__version__\s*=\s*(.*)$", f.read(), re.MULTILINE)
168+
public_version = ast.literal_eval(version_match.group(1))
169+
local_version = os.environ.get("FLASH_ATTN_LOCAL_VERSION")
170+
if local_version:
171+
return f"{public_version}+{local_version}"
172+
else:
173+
return str(public_version)
174+
163175
setup(
164176
name="flash_attn",
165-
version="1.0.5",
177+
version=get_package_version(),
166178
packages=find_packages(
167179
exclude=("build", "csrc", "include", "tests", "dist", "docs", "benchmarks", "flash_attn.egg-info",)
168180
),

0 commit comments

Comments
 (0)