Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 101 lines (83 sloc) 3.019 kb
c9595b3 @tswicegood Swap out to using a package.json for editable metadata
tswicegood authored
1 """
2 setup.py file for building armstrong components.
3
4 Nothing in this file should need to be edited, please see accompanying
5 package.json file if you need to adjust metadata about this package.
6 """
7
007c23a @tswicegood initial skeleton
tswicegood authored
8 from distutils.core import setup
c9595b3 @tswicegood Swap out to using a package.json for editable metadata
tswicegood authored
9 import json
007c23a @tswicegood initial skeleton
tswicegood authored
10 import os
11
c9595b3 @tswicegood Swap out to using a package.json for editable metadata
tswicegood authored
12 info = json.load(open("./package.json"))
13
14
15 def convert_to_str(d):
16 """
17 Recursively convert all values in a dictionary to strings
18
19 This is required because setup() does not like unicode in
20 the values it is supplied.
21 """
727be5c @tswicegood Fix issue with setup() call and unicode keys
tswicegood authored
22 d2 = {}
c9595b3 @tswicegood Swap out to using a package.json for editable metadata
tswicegood authored
23 for k, v in d.items():
727be5c @tswicegood Fix issue with setup() call and unicode keys
tswicegood authored
24 k = str(k)
c9595b3 @tswicegood Swap out to using a package.json for editable metadata
tswicegood authored
25 if type(v) in [list, tuple]:
727be5c @tswicegood Fix issue with setup() call and unicode keys
tswicegood authored
26 d2[k] = [str(a) for a in v]
c9595b3 @tswicegood Swap out to using a package.json for editable metadata
tswicegood authored
27 elif type(v) is dict:
727be5c @tswicegood Fix issue with setup() call and unicode keys
tswicegood authored
28 d2[k] = convert_to_str(v)
c9595b3 @tswicegood Swap out to using a package.json for editable metadata
tswicegood authored
29 else:
727be5c @tswicegood Fix issue with setup() call and unicode keys
tswicegood authored
30 d2[k] = str(v)
31 return d2
c9595b3 @tswicegood Swap out to using a package.json for editable metadata
tswicegood authored
32
33 info = convert_to_str(info)
34 NAMESPACE_PACKAGES = []
35
36
37 # TODO: simplify this process
38 def generate_namespaces(package):
39 new_package = ".".join(package.split(".")[0:-1])
40 if new_package.count(".") > 0:
41 generate_namespaces(new_package)
42 NAMESPACE_PACKAGES.append(new_package)
43 generate_namespaces(info["name"])
44
45
007c23a @tswicegood initial skeleton
tswicegood authored
46 if os.path.exists("MANIFEST"):
47 os.unlink("MANIFEST")
48
49 # Borrowed and modified from django-registration
50 # Compile the list of packages available, because distutils doesn't have
51 # an easy way to do this.
52 packages, data_files = [], []
53 root_dir = os.path.dirname(__file__)
54 if root_dir:
55 os.chdir(root_dir)
56
57 def build_package(dirpath, dirnames, filenames):
58 # Ignore dirnames that start with '.'
59 for i, dirname in enumerate(dirnames):
60 if dirname.startswith('.'):
61 del dirnames[i]
62 if '__init__.py' in filenames and 'steps.py' not in filenames:
63 pkg = dirpath.replace(os.path.sep, '.')
64 if os.path.altsep:
65 pkg = pkg.replace(os.path.altsep, '.')
66 packages.append(pkg)
e0c6210 making sure template.json goes into package_data
Dave McLain authored
67 # Strip off the length of the package name plus the trailing slash
68 prefix = dirpath[len(info["name"]) + 1:]
69 for f in filenames:
70 # Ignore all dot files and any compiled
71 if f == 'steps.py' or \
72 not (f.startswith(".") or
73 f.endswith(".pyc") or
74 f.endswith(".py")):
007c23a @tswicegood initial skeleton
tswicegood authored
75 data_files.append(os.path.join(prefix, f))
76
77
78 [build_package(dirpath, dirnames, filenames) for dirpath, dirnames, filenames
c9595b3 @tswicegood Swap out to using a package.json for editable metadata
tswicegood authored
79 in os.walk(info["name"].replace(".", "/"))]
80
81 setup_kwargs = {
82 "author": "Bay Citizen & Texas Tribune",
83 "author_email": "dev@armstrongcms.org",
831ed81 @tswicegood update setup.py to use the correct URL
tswicegood authored
84 "url": "http://github.com/armstrong/%s/" % info["name"],
c9595b3 @tswicegood Swap out to using a package.json for editable metadata
tswicegood authored
85 "packages": packages,
86 "package_data": {info["name"]: data_files, },
87 "namespace_packages": NAMESPACE_PACKAGES,
88 "classifiers": [
007c23a @tswicegood initial skeleton
tswicegood authored
89 'Development Status :: 3 - Alpha',
90 'Environment :: Web Environment',
91 'Framework :: Django',
92 'Intended Audience :: Developers',
93 'License :: OSI Approved :: Apache Software License',
94 'Operating System :: OS Independent',
95 'Programming Language :: Python',
96 ],
c9595b3 @tswicegood Swap out to using a package.json for editable metadata
tswicegood authored
97 }
98
99 setup_kwargs.update(info)
100 setup(**setup_kwargs)
Something went wrong with that request. Please try again.