blob: 75a839c0c5349e1c0adb35e37f707f9a925bf91e [file] [log] [blame]
Neal Norwitz3e0edbf2002-11-30 17:54:17 +00001import os, glob, sys
Steven M. Gavad7b6ed22001-06-25 07:23:57 +00002from distutils.core import setup
3from distutils.command.build_py import build_py
4from distutils.command.install_lib import install_lib
5import idlever
6
Neal Norwitz3e0edbf2002-11-30 17:54:17 +00007try:
8 pos = sys.argv.index("--check-tkinter")
9except ValueError:
10 pass
11else:
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
18
19try:
20 package_dir = os.path.join(os.environ["SRCDIR"], "Tools", "idle")
21except KeyError:
22 package_dir = "."
23
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000024# name of idle package
25idlelib = "idlelib"
26
27# the normal build_py would not incorporate the .txt files
Kurt B. Kaiser3eb78602001-07-14 05:48:44 +000028txt_files = ['config-unix.txt','config-win.txt','config.txt', 'help.txt']
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000029Icons = glob.glob1("Icons","*.gif")
30class 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)
35
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)
Neal Norwitz3e0edbf2002-11-30 17:54:17 +000044 self.copy_file(os.path.join(package_dir, name), outfile,
45 preserve_mode = 0)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000046 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("Icons",name),
52 outfile, preserve_mode = 0)
53
54 def get_source_files(self):
55 # returns the .py files, the .txt files, and the icons
Neal Norwitz3e0edbf2002-11-30 17:54:17 +000056 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]
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000058 return build_py.get_source_files(self)+txt_files+icons
59
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
74
75# Arghhh. install_lib thinks that all files returned from build_py's
76# get_outputs are bytecode files
Kurt B. Kaiser59e07bd2001-07-17 05:12:42 +000077
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000078class idle_install_lib(install_lib):
79 def _bytecode_filenames(self, files):
80 files = [n for n in files if n.endswith('.py')]
81 return install_lib._bytecode_filenames(self,files)
82
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000083setup(name="IDLE",
84 version = idlever.IDLE_VERSION,
Kurt B. Kaiser59e07bd2001-07-17 05:12:42 +000085 description = "IDLE Fork, the Forked Python IDE",
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000086 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
91Python and works both on Windows and Unix. It features a multi-window
92text editor with multiple undo, Python colorizing, and many other things,
Kurt B. Kaiser59e07bd2001-07-17 05:12:42 +000093as well as a Python shell window and a debugger.
94
95IDLE Fork is a separate line of development which was initiated by D. Scherer
96at CMU as part of Visual Python. It features execution in a separate
97process, with a fresh environment for each run. For further details,
98refer to idlefork.sourceforge.net.""",
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000099
100 cmdclass = {'build_py':idle_build_py,
101 'install_lib':idle_install_lib},
Neal Norwitz3e0edbf2002-11-30 17:54:17 +0000102 package_dir = {idlelib: package_dir},
Steven M. Gavad7b6ed22001-06-25 07:23:57 +0000103 packages = [idlelib],
Neal Norwitz3e0edbf2002-11-30 17:54:17 +0000104 scripts = [os.path.join(package_dir, 'idle')]
Steven M. Gavad7b6ed22001-06-25 07:23:57 +0000105 )