Skip to content
This repository was archived by the owner on Jul 2, 2025. It is now read-only.

Commit 8ca33d7

Browse files
fixed setup.py to build not in a git repo
1 parent 9684cb2 commit 8ca33d7

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

setup.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import sys
44
import fnmatch
55
import shutil
6+
from datetime import datetime
67

78
from setuptools import setup, find_packages
89
from distutils.command.clean import clean
@@ -12,20 +13,28 @@
1213
from setuptools.command.test import test as TestCommand
1314

1415
from git import Repo
16+
from git.exc import InvalidGitRepositoryError
1517

1618
here = os.path.abspath(os.path.dirname(__file__))
1719
README = open(os.path.join(here, 'README.md')).read()
1820
pkg_name = 'oil_library'
19-
pkg_version = '1.1.0'
21+
pkg_version = '1.1.1'
2022

21-
repo = Repo('.')
2223

24+
# try to get update date from repo
2325
try:
24-
branch_name = repo.active_branch.name
25-
except TypeError:
26+
repo = Repo('.')
27+
try:
28+
branch_name = repo.active_branch.name
29+
except TypeError:
30+
branch_name = 'no-branch'
31+
last_update = repo.iter_commits().next().committed_datetime.isoformat()
32+
except InvalidGitRepositoryError:
33+
# not builiding in a valid git repo
34+
# use today's date.
35+
print "not in a valid git repo -- using today's date as build date"
2636
branch_name = 'no-branch'
27-
28-
last_update = repo.iter_commits().next().committed_datetime.isoformat(),
37+
last_update = datetime.now().isoformat()
2938

3039

3140
def clean_files(del_db=False):

0 commit comments

Comments
 (0)