Skip to content

Commit

Permalink
Add git version suffix to package name (pytorch#547)
Browse files Browse the repository at this point in the history
* Add git version suffix to package name

* push
  • Loading branch information
msaroufim authored Jul 31, 2024
1 parent 00b76c4 commit 0cc1c4d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,19 @@
import os
import glob
from datetime import datetime
import subprocess

from setuptools import find_packages, setup

current_date = datetime.now().strftime("%Y.%m.%d")


def get_git_commit_id():
try:
return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('ascii').strip()
except Exception:
return ""

def read_requirements(file_path):
with open(file_path, "r") as file:
return file.read().splitlines()
Expand All @@ -21,7 +29,12 @@ def read_version(file_path="version.txt"):

# Determine the package name based on the presence of an environment variable
package_name = "torchao-nightly" if os.environ.get("TORCHAO_NIGHTLY") else "torchao"
version_suffix = os.getenv("VERSION_SUFFIX", "")

# Use Git commit ID if VERSION_SUFFIX is not set
version_suffix = os.getenv("VERSION_SUFFIX")
if version_suffix is None:
version_suffix = f"+git{get_git_commit_id()}"

use_cpp = os.getenv('USE_CPP')


Expand Down

0 comments on commit 0cc1c4d

Please sign in to comment.