blob: 060f8ff2f67b2b19830c5b153a5f4a4212af9604 [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
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +00009# Name of 'package' to be installed in site-packages:
10pkgname = idle_name + "lib"
11
12pkg_dir = "."
13
Neal Norwitz3e0edbf2002-11-30 17:54:17 +000014try:
15 pos = sys.argv.index("--check-tkinter")
16except ValueError:
17 pass
18else:
19 del sys.argv[pos]
20 try:
21 import _tkinter
22 except ImportError:
23 print >>sys.stderr, "Cannot install IDLE without _tkinter"
24 raise SystemExit
25
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +000026# the normal build_py would not incorporate anything but .py files
Kurt B. Kaiserfe8496c2003-01-02 20:33:26 +000027txt_files = ['extend.txt', 'help.txt', 'CREDITS.txt', 'HISTORY.txt',
28 'INSTALL.txt', 'LICENSE.txt', 'NEWS.txt', 'README.txt']
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000029txt_files += ['config-extensions.def', 'config-highlight.def',
30 'config-keys.def', 'config-main.def']
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +000031txt_files += [idle_name + '.bat', idle_name + '.pyw']
32
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000033Icons = glob.glob1("Icons","*.gif")
Kurt B. Kaiserdd70e1b2002-12-21 21:03:06 +000034
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000035class IDLE_Builder(build_py):
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000036 def get_plain_outfile(self, build_dir, package, file):
37 # like get_module_outfile, but does not append .py
38 outfile_path = [build_dir] + list(package) + [file]
39 return apply(os.path.join, outfile_path)
40
41 def run(self):
42 # Copies all .py files, then also copies the txt and gif files
43 build_py.run(self)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000044 for name in txt_files:
Kurt B. Kaiserf4f42762002-12-24 06:36:19 +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)
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +000048 self.copy_file(os.path.join(pkg_dir, name), outfile,
Neal Norwitz3e0edbf2002-11-30 17:54:17 +000049 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. Kaiserf4f42762002-12-24 06:36:19 +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
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +000060 icons = [os.path.join(pkg_dir, "Icons",name) for name in Icons]
61 txts = [os.path.join(pkg_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:
Kurt B. Kaiserf4f42762002-12-24 06:36:19 +000070 filename = self.get_plain_outfile(self.build_lib, [pkgname], name)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000071 outputs.append(filename)
72 for name in Icons:
73 filename = self.get_plain_outfile(self.build_lib,
Kurt B. Kaiserf4f42762002-12-24 06:36:19 +000074 [pkgname, "Icons"], name)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000075 outputs.append(filename)
76 return outputs
77
78# Arghhh. install_lib thinks that all files returned from build_py's
79# get_outputs are bytecode files
Kurt B. Kaiser59e07bd2001-07-17 05:12:42 +000080
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000081class IDLE_Installer(install_lib):
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000082 def _bytecode_filenames(self, files):
83 files = [n for n in files if n.endswith('.py')]
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000084 return install_lib._bytecode_filenames(self, files)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000085
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000086setup(name="IDLEfork",
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000087 version = idlever.IDLE_VERSION,
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000088 description = "IDLEfork, the Developmental Python IDE",
89 author = "Guido van Rossum et. al.",
90 author_email = "idle-dev@python.org",
Kurt B. Kaiser18091542002-12-22 01:48:28 +000091 license = "PSF: www.python.org",
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000092 url = "https://sourceforge.net/projects/idlefork/",
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000093 long_description =
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +000094"""IDLE is a Tkinter based IDE for Python. It is written in 100% pure
95Python and works both on Windows and Unix. It features a multi-window
96text editor with multiple undo, Python colorizing, and many other
97things, as well as a Python shell window and a debugger.
Kurt B. Kaiser59e07bd2001-07-17 05:12:42 +000098
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +000099IDLEfork is a separate line of development which was initiated by
Kurt B. Kaiserfe8496c2003-01-02 20:33:26 +0000100David Scherer at CMU as part of VPython. It features execution in a
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +0000101separate process which is newly initiated for each run. At version 0.9
102the RPC was changed to incorporate code by GvR, which supports the
103debugger. IDLEfork also incorporates a GUI configuration utilility.
104For further details, refer to idlefork.sourceforge.net.
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +0000105""",
106
107 cmdclass = {'build_py':IDLE_Builder,
108 'install_lib':IDLE_Installer},
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +0000109 package_dir = {pkgname: pkg_dir},
Kurt B. Kaiserf4f42762002-12-24 06:36:19 +0000110 packages = [pkgname],
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +0000111 scripts = [os.path.join(pkg_dir, idle_name)]
Steven M. Gavad7b6ed22001-06-25 07:23:57 +0000112 )