Skip to content

Commit

Permalink
Include git hash and install date in version
Browse files Browse the repository at this point in the history
ghstack-source-id: 4fb6bf321356e40c8066351c7a28c55675d3a27a
Pull Request resolved: facebookresearch#511
  • Loading branch information
danthe3rd committed Nov 10, 2022
1 parent 3cae847 commit 86e3db2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.

import datetime
import distutils.command.clean
import glob
import os
Expand Down Expand Up @@ -33,12 +34,22 @@ def fetch_requirements():
return reqs


def get_local_version_suffix() -> str:
date_suffix = datetime.datetime.now().strftime("%Y%m%d")
git_hash = subprocess.check_output(
["git", "rev-parse", "--short", "HEAD"], cwd=Path(__file__).parent
).decode("ascii")[:-1]
return f"+{git_hash}.d{date_suffix}"


if os.getenv("BUILD_VERSION"):
# In CI
version = os.getenv("BUILD_VERSION")
else:
version_txt = os.path.join(this_dir, "version.txt")
with open(version_txt) as f:
version = f.readline().strip()
version += get_local_version_suffix()


def write_version_file():
Expand Down Expand Up @@ -256,7 +267,6 @@ def run(self):
name="xformers",
description="XFormers: A collection of composable Transformer building blocks.",
version=version,
setup_requires=[],
install_requires=fetch_requirements(),
packages=setuptools.find_packages(exclude=("tests", "tests.*")),
ext_modules=get_extensions(),
Expand All @@ -267,7 +277,7 @@ def run(self):
url="https://facebookresearch.github.io/xformers/",
python_requires=">=3.6",
author="Facebook AI Research",
author_email="lefaudeux@fb.com",
author_email="[email protected].com",
long_description="XFormers: A collection of composable Transformer building blocks."
+ "XFormers aims at being able to reproduce most architectures in the Transformer-family SOTA,"
+ "defined as compatible and combined building blocks as opposed to monolithic models",
Expand Down

0 comments on commit 86e3db2

Please sign in to comment.