blob: a7cff9cefecb0daaf585423901bbecb309db8e8b [file] [log] [blame]
Neal Norwitz3e0edbf2002-11-30 17:54:17 +00001import os, glob, sys
Kurt B. Kaiser98b15ab2003-03-10 20:41:07 +00002from distutils.core import setup, Extension
Steven M. Gavad7b6ed22001-06-25 07:23:57 +00003from 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
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +00009# Name of 'package' to be installed in site-packages:
10pkgname = idle_name + "lib"
11
Neal Norwitz3e0edbf2002-11-30 17:54:17 +000012try:
13 pos = sys.argv.index("--check-tkinter")
14except ValueError:
15 pass
16else:
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
23
Kurt B. Kaiser2da75fa2003-01-21 04:42:50 +000024try:
25 pkg_dir = os.path.join(os.environ['SRCDIR'], 'Tools', idle_name)
26except KeyError:
27 pkg_dir = "."
28
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +000029# the normal build_py would not incorporate anything but .py files
Kurt B. Kaiserfe8496c2003-01-02 20:33:26 +000030txt_files = ['extend.txt', 'help.txt', 'CREDITS.txt', 'HISTORY.txt',
31 'INSTALL.txt', 'LICENSE.txt', 'NEWS.txt', 'README.txt']
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000032txt_files += ['config-extensions.def', 'config-highlight.def',
33 'config-keys.def', 'config-main.def']
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +000034txt_files += [idle_name + '.bat', idle_name + '.pyw']
35
Kurt B. Kaiser2da75fa2003-01-21 04:42:50 +000036Icons = glob.glob1(os.path.join(pkg_dir, "Icons"), "*.gif")
Kurt B. Kaiserdd70e1b2002-12-21 21:03:06 +000037
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000038class IDLE_Builder(build_py):
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000039 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)
43
44 def run(self):
45 # Copies all .py files, then also copies the txt and gif files
46 build_py.run(self)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000047 for name in txt_files:
Kurt B. Kaiserf4f42762002-12-24 06:36:19 +000048 outfile = self.get_plain_outfile(self.build_lib, [pkgname], name)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000049 dir = os.path.dirname(outfile)
50 self.mkpath(dir)
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +000051 self.copy_file(os.path.join(pkg_dir, name), outfile,
Neal Norwitz3e0edbf2002-11-30 17:54:17 +000052 preserve_mode = 0)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000053 for name in Icons:
54 outfile = self.get_plain_outfile(self.build_lib,
Kurt B. Kaiserf4f42762002-12-24 06:36:19 +000055 [pkgname, "Icons"], name)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000056 dir = os.path.dirname(outfile)
57 self.mkpath(dir)
Kurt B. Kaiser2da75fa2003-01-21 04:42:50 +000058 self.copy_file(os.path.join(pkg_dir, "Icons", name),
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000059 outfile, preserve_mode = 0)
60
61 def get_source_files(self):
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000062 # returns the .py files, the .txt and .def files, and the icons
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +000063 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]
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000065 return build_py.get_source_files(self) + txt_files + icons
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000066
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:
Kurt B. Kaiserf4f42762002-12-24 06:36:19 +000073 filename = self.get_plain_outfile(self.build_lib, [pkgname], name)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000074 outputs.append(filename)
75 for name in Icons:
76 filename = self.get_plain_outfile(self.build_lib,
Kurt B. Kaiserf4f42762002-12-24 06:36:19 +000077 [pkgname, "Icons"], name)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000078 outputs.append(filename)
79 return outputs
80
81# Arghhh. install_lib thinks that all files returned from build_py's
82# get_outputs are bytecode files
Kurt B. Kaiser59e07bd2001-07-17 05:12:42 +000083
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000084class IDLE_Installer(install_lib):
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000085 def _bytecode_filenames(self, files):
86 files = [n for n in files if n.endswith('.py')]
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000087 return install_lib._bytecode_filenames(self, files)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000088
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000089setup(name="IDLEfork",
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000090 version = idlever.IDLE_VERSION,
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000091 description = "IDLEfork, the Developmental Python IDE",
92 author = "Guido van Rossum et. al.",
93 author_email = "idle-dev@python.org",
Kurt B. Kaiser18091542002-12-22 01:48:28 +000094 license = "PSF: www.python.org",
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000095 url = "https://sourceforge.net/projects/idlefork/",
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000096 long_description =
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +000097"""IDLE is a Tkinter based IDE for Python. It is written in 100% pure
98Python and works both on Windows and Unix. It features a multi-window
99text editor with multiple undo, Python colorizing, and many other
100things, as well as a Python shell window and a debugger.
Kurt B. Kaiser59e07bd2001-07-17 05:12:42 +0000101
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +0000102IDLEfork is a separate line of development which was initiated by
Kurt B. Kaiserfe8496c2003-01-02 20:33:26 +0000103David Scherer at CMU as part of VPython. It features execution in a
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +0000104separate process which is newly initiated for each run. At version 0.9
105the RPC was changed to incorporate code by GvR, which supports the
106debugger. IDLEfork also incorporates a GUI configuration utilility.
107For further details, refer to idlefork.sourceforge.net.
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +0000108""",
109
110 cmdclass = {'build_py':IDLE_Builder,
111 'install_lib':IDLE_Installer},
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +0000112 package_dir = {pkgname: pkg_dir},
Kurt B. Kaiserf4f42762002-12-24 06:36:19 +0000113 packages = [pkgname],
Kurt B. Kaiser98b15ab2003-03-10 20:41:07 +0000114 ext_modules = [Extension("interrupt", ["interruptmodule.c"])],
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +0000115 scripts = [os.path.join(pkg_dir, idle_name)]
Steven M. Gavad7b6ed22001-06-25 07:23:57 +0000116 )