-
Notifications
You must be signed in to change notification settings - Fork 31
/
setup.py
103 lines (76 loc) · 3.04 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
from setuptools import setup, Command, find_packages
import glob
import os.path
import os
import subprocess
PACKAGE = "anyconfig"
VERSION = "0.0.13" # see anyconfig.globals.VERSION
# For daily snapshot versioning mode:
if os.environ.get("_SNAPSHOT_BUILD", None) is not None:
import datetime
VERSION = VERSION + datetime.datetime.now().strftime(".%Y%m%d")
def list_filepaths(tdir):
return [f for f in glob.glob(os.path.join(tdir, '*')) if os.path.isfile(f)]
data_files = [("share/man/man1", list_filepaths("docs/"))]
class SrpmCommand(Command):
user_options = []
build_stage = "s"
curdir = os.path.abspath(os.curdir)
rpmspec = os.path.join(curdir, "pkg/package.spec")
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
self.pre_sdist()
self.run_command('sdist')
self.build_rpm()
def pre_sdist(self):
c = open(self.rpmspec + ".in").read()
open(self.rpmspec, "w").write(c.replace("@VERSION@", VERSION))
def build_rpm(self):
rpmbuild = os.path.join(self.curdir, "pkg/rpmbuild-wrapper.sh")
workdir = os.path.join(self.curdir, "dist")
cmd_s = "%s -w %s -s %s %s" % (rpmbuild, workdir, self.build_stage,
self.rpmspec)
subprocess.check_call(cmd_s, shell=True)
class RpmCommand(SrpmCommand):
build_stage = "b"
_CLASSIFIERS = ["Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Environment :: Console",
"Operating System :: OS Independent",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Text Processing :: Markup",
"Topic :: Utilities",
"License :: OSI Approved :: MIT License"]
TESTS_REQ = [l.rstrip() for l in open("pkg/test_requirements.txt").readlines()
if l and not l.startswith('#')]
setup(name=PACKAGE,
version=VERSION,
description="Generic access to configuration files in some formats",
long_description=open("docs/introduction.rst").read(),
author="Satoru SATOH",
author_email="ssato@redhat.com",
license="MIT",
url="https://github.com/ssato/python-anyconfig",
classifiers=_CLASSIFIERS,
tests_require=TESTS_REQ,
packages=find_packages(),
include_package_data=True,
cmdclass={
"srpm": SrpmCommand,
"rpm": RpmCommand,
},
entry_points=open(os.path.join(os.curdir, "pkg/entry_points.txt")).read(),
data_files=data_files,
)
# vim:sw=4:ts=4:et: