test_whitespace_eater_unicode(): Make this test Python 2.1 compatible.
[python/dscho.git] / Tools / idle / setup.py
blobb96909244b6c83be83e4c7cdde9fdae4c18c1afe
1 import os, glob, sys
2 from distutils.core import setup
3 from distutils.command.build_py import build_py
4 from distutils.command.install_lib import install_lib
5 import idlever
7 try:
8 pos = sys.argv.index("--check-tkinter")
9 except ValueError:
10 pass
11 else:
12 del sys.argv[pos]
13 try:
14 import _tkinter
15 except ImportError:
16 print >>sys.stderr, "Cannot install IDLE without _tkinter"
17 raise SystemExit
19 try:
20 package_dir = os.path.join(os.environ["SRCDIR"], "Tools", "idle")
21 except KeyError:
22 package_dir = "."
24 # name of idle package
25 idlelib = "idlelib"
27 # the normal build_py would not incorporate the .txt files
28 txt_files = ['config-unix.txt','config-win.txt','config.txt', 'help.txt']
29 Icons = glob.glob1(os.path.join(package_dir,"Icons"),"*.gif")
30 class idle_build_py(build_py):
31 def get_plain_outfile(self, build_dir, package, file):
32 # like get_module_outfile, but does not append .py
33 outfile_path = [build_dir] + list(package) + [file]
34 return apply(os.path.join, outfile_path)
36 def run(self):
37 # Copies all .py files, then also copies the txt and gif files
38 build_py.run(self)
39 assert self.packages == [idlelib]
40 for name in txt_files:
41 outfile = self.get_plain_outfile(self.build_lib, [idlelib], name)
42 dir = os.path.dirname(outfile)
43 self.mkpath(dir)
44 self.copy_file(os.path.join(package_dir, name), outfile,
45 preserve_mode = 0)
46 for name in Icons:
47 outfile = self.get_plain_outfile(self.build_lib,
48 [idlelib,"Icons"], name)
49 dir = os.path.dirname(outfile)
50 self.mkpath(dir)
51 self.copy_file(os.path.join(package_dir, "Icons", name),
52 outfile, preserve_mode = 0)
54 def get_source_files(self):
55 # returns the .py files, the .txt files, and the icons
56 icons = [os.path.join(package_dir, "Icons",name) for name in Icons]
57 txts = [os.path.join(package_dir, name) for name in txt_files]
58 return build_py.get_source_files(self)+txt_files+icons
60 def get_outputs(self, include_bytecode=1):
61 # returns the built files
62 outputs = build_py.get_outputs(self, include_bytecode)
63 if not include_bytecode:
64 return outputs
65 for name in txt_files:
66 filename = self.get_plain_outfile(self.build_lib,
67 [idlelib], name)
68 outputs.append(filename)
69 for name in Icons:
70 filename = self.get_plain_outfile(self.build_lib,
71 [idlelib,"Icons"], name)
72 outputs.append(filename)
73 return outputs
75 # Arghhh. install_lib thinks that all files returned from build_py's
76 # get_outputs are bytecode files
77 class idle_install_lib(install_lib):
78 def _bytecode_filenames(self, files):
79 files = [n for n in files if n.endswith('.py')]
80 return install_lib._bytecode_filenames(self,files)
83 setup(name="IDLE",
84 version = idlever.IDLE_VERSION,
85 description = "IDLE, the Python IDE",
86 author = "Guido van Rossum",
87 author_email = "guido@python.org",
88 #url =
89 long_description =
90 """IDLE is a Tkinter based IDE for Python. It is written in 100% pure
91 Python and works both on Windows and Unix. It features a multi-window
92 text editor with multiple undo, Python colorizing, and many other things,
93 as well as a Python shell window and a debugger.""",
95 cmdclass = {'build_py':idle_build_py,
96 'install_lib':idle_install_lib},
97 package_dir = {idlelib: package_dir},
98 packages = [idlelib],
99 scripts = [os.path.join(package_dir, 'idle')]