test_whitespace_eater_unicode(): Make this test Python 2.1 compatible.
[python/dscho.git] / Lib / idlelib / setup.py
bloba7cff9cefecb0daaf585423901bbecb309db8e8b
1 import os, glob, sys
2 from distutils.core import setup, Extension
3 from distutils.command.build_py import build_py
4 from distutils.command.install_lib import install_lib
5 import idlever
7 idle_name = "idle"
9 # Name of 'package' to be installed in site-packages:
10 pkgname = idle_name + "lib"
12 try:
13 pos = sys.argv.index("--check-tkinter")
14 except ValueError:
15 pass
16 else:
17 del sys.argv[pos]
18 try:
19 import _tkinter
20 except ImportError:
21 print >>sys.stderr, "Cannot install IDLE without _tkinter"
22 raise SystemExit
24 try:
25 pkg_dir = os.path.join(os.environ['SRCDIR'], 'Tools', idle_name)
26 except KeyError:
27 pkg_dir = "."
29 # the normal build_py would not incorporate anything but .py files
30 txt_files = ['extend.txt', 'help.txt', 'CREDITS.txt', 'HISTORY.txt',
31 'INSTALL.txt', 'LICENSE.txt', 'NEWS.txt', 'README.txt']
32 txt_files += ['config-extensions.def', 'config-highlight.def',
33 'config-keys.def', 'config-main.def']
34 txt_files += [idle_name + '.bat', idle_name + '.pyw']
36 Icons = glob.glob1(os.path.join(pkg_dir, "Icons"), "*.gif")
38 class IDLE_Builder(build_py):
39 def get_plain_outfile(self, build_dir, package, file):
40 # like get_module_outfile, but does not append .py
41 outfile_path = [build_dir] + list(package) + [file]
42 return apply(os.path.join, outfile_path)
44 def run(self):
45 # Copies all .py files, then also copies the txt and gif files
46 build_py.run(self)
47 for name in txt_files:
48 outfile = self.get_plain_outfile(self.build_lib, [pkgname], name)
49 dir = os.path.dirname(outfile)
50 self.mkpath(dir)
51 self.copy_file(os.path.join(pkg_dir, name), outfile,
52 preserve_mode = 0)
53 for name in Icons:
54 outfile = self.get_plain_outfile(self.build_lib,
55 [pkgname, "Icons"], name)
56 dir = os.path.dirname(outfile)
57 self.mkpath(dir)
58 self.copy_file(os.path.join(pkg_dir, "Icons", name),
59 outfile, preserve_mode = 0)
61 def get_source_files(self):
62 # returns the .py files, the .txt and .def files, and the icons
63 icons = [os.path.join(pkg_dir, "Icons",name) for name in Icons]
64 txts = [os.path.join(pkg_dir, name) for name in txt_files]
65 return build_py.get_source_files(self) + txt_files + icons
67 def get_outputs(self, include_bytecode=1):
68 # returns the built files
69 outputs = build_py.get_outputs(self, include_bytecode)
70 if not include_bytecode:
71 return outputs
72 for name in txt_files:
73 filename = self.get_plain_outfile(self.build_lib, [pkgname], name)
74 outputs.append(filename)
75 for name in Icons:
76 filename = self.get_plain_outfile(self.build_lib,
77 [pkgname, "Icons"], name)
78 outputs.append(filename)
79 return outputs
81 # Arghhh. install_lib thinks that all files returned from build_py's
82 # get_outputs are bytecode files
84 class IDLE_Installer(install_lib):
85 def _bytecode_filenames(self, files):
86 files = [n for n in files if n.endswith('.py')]
87 return install_lib._bytecode_filenames(self, files)
89 setup(name="IDLEfork",
90 version = idlever.IDLE_VERSION,
91 description = "IDLEfork, the Developmental Python IDE",
92 author = "Guido van Rossum et. al.",
93 author_email = "idle-dev@python.org",
94 license = "PSF: www.python.org",
95 url = "https://sourceforge.net/projects/idlefork/",
96 long_description =
97 """IDLE is a Tkinter based IDE for Python. It is written in 100% pure
98 Python and works both on Windows and Unix. It features a multi-window
99 text editor with multiple undo, Python colorizing, and many other
100 things, as well as a Python shell window and a debugger.
102 IDLEfork is a separate line of development which was initiated by
103 David Scherer at CMU as part of VPython. It features execution in a
104 separate process which is newly initiated for each run. At version 0.9
105 the RPC was changed to incorporate code by GvR, which supports the
106 debugger. IDLEfork also incorporates a GUI configuration utilility.
107 For further details, refer to idlefork.sourceforge.net.
108 """,
110 cmdclass = {'build_py':IDLE_Builder,
111 'install_lib':IDLE_Installer},
112 package_dir = {pkgname: pkg_dir},
113 packages = [pkgname],
114 ext_modules = [Extension("interrupt", ["interruptmodule.c"])],
115 scripts = [os.path.join(pkg_dir, idle_name)]