blob: 2305adc3f3e5f865970485529ed6b895a39a4447 [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
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +00007idle_name = "idle"
8
Neal Norwitz3e0edbf2002-11-30 17:54:17 +00009try:
10 pos = sys.argv.index("--check-tkinter")
11except ValueError:
12 pass
13else:
14 del sys.argv[pos]
15 try:
16 import _tkinter
17 except ImportError:
18 print >>sys.stderr, "Cannot install IDLE without _tkinter"
19 raise SystemExit
20
21try:
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000022 package_dir = os.path.join(os.environ["SRCDIR"], "Tools", idle_name)
Neal Norwitz3e0edbf2002-11-30 17:54:17 +000023except KeyError:
24 package_dir = "."
25
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000026# name of package to be installed in site-packages
27pkgname = idle_name + "lib"
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000028
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000029# the normal build_py would not incorporate the .txt or config files
30txt_files = ['extend.txt', 'help.txt', 'CREDITS.txt', 'LICENSE.txt']
31txt_files += ['config-extensions.def', 'config-highlight.def',
32 'config-keys.def', 'config-main.def']
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000033Icons = glob.glob1("Icons","*.gif")
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000034class IDLE_Builder(build_py):
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000035 def get_plain_outfile(self, build_dir, package, file):
36 # like get_module_outfile, but does not append .py
37 outfile_path = [build_dir] + list(package) + [file]
38 return apply(os.path.join, outfile_path)
39
40 def run(self):
41 # Copies all .py files, then also copies the txt and gif files
42 build_py.run(self)
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000043 assert self.packages == [pkgname]
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000044 for name in txt_files:
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000045 outfile = self.get_plain_outfile(self.build_lib, [pkgname], name)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000046 dir = os.path.dirname(outfile)
47 self.mkpath(dir)
Neal Norwitz3e0edbf2002-11-30 17:54:17 +000048 self.copy_file(os.path.join(package_dir, name), outfile,
49 preserve_mode = 0)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000050 for name in Icons:
51 outfile = self.get_plain_outfile(self.build_lib,
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000052 [pkgname, "Icons"], name)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000053 dir = os.path.dirname(outfile)
54 self.mkpath(dir)
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000055 self.copy_file(os.path.join("Icons", name),
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000056 outfile, preserve_mode = 0)
57
58 def get_source_files(self):
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000059 # returns the .py files, the .txt and .def files, and the icons
Neal Norwitz3e0edbf2002-11-30 17:54:17 +000060 icons = [os.path.join(package_dir, "Icons",name) for name in Icons]
61 txts = [os.path.join(package_dir, name) for name in txt_files]
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000062 return build_py.get_source_files(self) + txt_files + icons
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000063
64 def get_outputs(self, include_bytecode=1):
65 # returns the built files
66 outputs = build_py.get_outputs(self, include_bytecode)
67 if not include_bytecode:
68 return outputs
69 for name in txt_files:
70 filename = self.get_plain_outfile(self.build_lib,
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000071 [pkgname], name)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000072 outputs.append(filename)
73 for name in Icons:
74 filename = self.get_plain_outfile(self.build_lib,
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000075 [pkgname, "Icons"], name)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000076 outputs.append(filename)
77 return outputs
78
79# Arghhh. install_lib thinks that all files returned from build_py's
80# get_outputs are bytecode files
Kurt B. Kaiser59e07bd2001-07-17 05:12:42 +000081
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000082class IDLE_Installer(install_lib):
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000083 def _bytecode_filenames(self, files):
84 files = [n for n in files if n.endswith('.py')]
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000085 return install_lib._bytecode_filenames(self, files)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000086
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000087setup(name="IDLEfork",
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000088 version = idlever.IDLE_VERSION,
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000089 description = "IDLEfork, the Developmental Python IDE",
90 author = "Guido van Rossum et. al.",
91 author_email = "idle-dev@python.org",
92 url = "https://sourceforge.net/projects/idlefork/",
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000093 long_description =
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000094"""IDLE is a Tkinter based IDE for Python. It is written in 100% pure Python
95and works both on Windows and Unix. It features a multi-window text editor with
96multiple undo, Python colorizing, and many other things, as well as a Python
97shell window and a debugger.
Kurt B. Kaiser59e07bd2001-07-17 05:12:42 +000098
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000099IDLEfork is a separate line of development which was initiated by D. Scherer
100at CMU as part of Visual Python. It features execution in a separate process
101which is newly initiated for each run. At version 0.9 the RPC was changed to
102incorporate code by GvR, which supports the debugger. IDLEfork also
103incorporates a GUI configuration utilility. For further details, refer to
104idlefork.sourceforge.net.
Steven M. Gavad7b6ed22001-06-25 07:23:57 +0000105
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +0000106""",
107
108 cmdclass = {'build_py':IDLE_Builder,
109 'install_lib':IDLE_Installer},
110 package_dir = {pkgname: package_dir},
111 packages = [pkgname],
112 scripts = [os.path.join(package_dir, idle_name)]
Steven M. Gavad7b6ed22001-06-25 07:23:57 +0000113 )