Skip to content

Commit a80f845

Browse files
committed
Added setup.py file.
1 parent 1f1d5be commit a80f845

File tree

5 files changed

+63
-2
lines changed

5 files changed

+63
-2
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
/tarsnapper.wpr
22
/BRANCH_TODO
3-
*.pyc
3+
*.pyc
4+
5+
/build/
6+
/dist/
7+
/tarsnapper.egg-info/

scripts/tarsnapper

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env python
2+
import tarsnapper.script
3+
tarsnapper.script.run()

setup.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env python
2+
# encoding: utf8
3+
"""Adapted from virtualenv's setup.py.
4+
"""
5+
6+
import sys, os
7+
try:
8+
from setuptools import setup
9+
except ImportError:
10+
from distutils.core import setup
11+
kw = {'scripts': ['scripts/tarsnapper']}
12+
else:
13+
kw = {'entry_points':
14+
"""[console_scripts]\ntarsnapper = tarsnapper.script:run\n""",
15+
'zip_safe': False}
16+
import re
17+
18+
here = os.path.dirname(os.path.abspath(__file__))
19+
20+
# Figure out the version
21+
version_re = re.compile(
22+
r'__version__ = (\(.*?\))')
23+
fp = open(os.path.join(here, 'src/tarsnapper/__init__.py'))
24+
version = None
25+
for line in fp:
26+
match = version_re.search(line)
27+
if match:
28+
exec "version = %s" % match.group(1)
29+
version = ".".join(map(str, version))
30+
break
31+
else:
32+
raise Exception("Cannot find version in __init__.py")
33+
fp.close()
34+
35+
setup(name='tarsnapper',
36+
version=version,
37+
description="Manages tarsnap backups",
38+
classifiers=[
39+
'License :: OSI Approved :: BSD License',
40+
],
41+
author='Michael Elsdoerfer',
42+
author_email='[email protected]',
43+
url='http://github.com/miracle2k/tarsnapper',
44+
license='BSD',
45+
packages=['tarsnapper'],
46+
package_dir = {'tarsnapper': 'src/tarsnapper'},
47+
install_requires = ['argparse==1.1',],
48+
**kw
49+
)

src/tarsnapper/__init__.py

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

src/tarsnapper/script.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,5 +180,9 @@ def main(argv):
180180
return 1
181181

182182

183+
def run():
184+
sys.exit(main(sys.argv[1:]) or 0)
185+
186+
183187
if __name__ == '__main__':
184-
sys.exit(main(sys.argv[1:]) or 0)
188+
run()

0 commit comments

Comments
 (0)