Skip to content
This repository was archived by the owner on Feb 20, 2023. It is now read-only.

Commit da5a902

Browse files
authored
Merge pull request #39 from kevinywlui/develop
Actually install the cheat sheet when using setup.py
2 parents 2fd52e5 + c981690 commit da5a902

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

git_trac/cmdline.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,27 @@ def xdg_open(uri):
4444

4545

4646
def show_cheat_sheet():
47+
# case where `git-trac` was just symbolically linked
4748
root_dir = os.path.dirname(os.path.dirname(__file__))
4849
cheat_sheet = os.path.join(root_dir, 'doc', 'git-cheat-sheet.pdf')
50+
# case of `python setup.py install --user`
51+
if not os.path.exists(cheat_sheet):
52+
root_dir = __import__('site').USER_BASE
53+
cheat_sheet = os.path.join(root_dir,
54+
'share',
55+
'git-trac-command',
56+
'git-cheat-sheet.pdf')
57+
# case of `python setup.py install`
58+
if not os.path.exists(cheat_sheet):
59+
root_dir = sys.prefix
60+
cheat_sheet = os.path.join(root_dir,
61+
'share',
62+
'git-trac-command',
63+
'git-cheat-sheet.pdf')
64+
# go to internet if not found
65+
if not os.path.exists(cheat_sheet):
66+
cheat_sheet = "http://github.com/sagemath/git-trac-command/raw/master/doc/git-cheat-sheet.pdf"
67+
print('Cheat sheet not found locally. Trying the internet.')
4968
xdg_open(cheat_sheet)
5069

5170

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
author='Volker Braun',
99
author_email='[email protected]',
1010
packages=['git_trac'],
11+
data_files=[('share/git-trac-command', ['doc/git-cheat-sheet.pdf'])],
1112
scripts=['git-trac'],
1213
version='1.0',
1314
url='https://github.com/sagemath/git-trac-command',

0 commit comments

Comments
 (0)