blob: 8a4ffa69bac68525d380d4eb76243260852c74ca [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# IDLE not being imported as a package by its script. It is now being
10# installed as a collection of modules in a directory in .../site-packages/,
11# with a .pth file which will add IDLE to sys.path
12
13# Name of 'package' to be installed in site-packages:
14pkgname = idle_name + "lib"
15
16pkg_dir = "."
17
Neal Norwitz3e0edbf2002-11-30 17:54:17 +000018try:
19 pos = sys.argv.index("--check-tkinter")
20except ValueError:
21 pass
22else:
23 del sys.argv[pos]
24 try:
25 import _tkinter
26 except ImportError:
27 print >>sys.stderr, "Cannot install IDLE without _tkinter"
28 raise SystemExit
29
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +000030# the normal build_py would not incorporate anything but .py files
31txt_files = ['extend.txt', 'help.txt', 'CREDITS.txt', 'LICENSE.txt',
32 'README.txt']
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000033txt_files += ['config-extensions.def', 'config-highlight.def',
34 'config-keys.def', 'config-main.def']
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +000035txt_files += [idle_name + '.bat', idle_name + '.pyw']
36
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000037Icons = glob.glob1("Icons","*.gif")
Kurt B. Kaiserdd70e1b2002-12-21 21:03:06 +000038
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000039class IDLE_Builder(build_py):
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000040 def get_plain_outfile(self, build_dir, package, file):
41 # like get_module_outfile, but does not append .py
42 outfile_path = [build_dir] + list(package) + [file]
43 return apply(os.path.join, outfile_path)
44
45 def run(self):
46 # Copies all .py files, then also copies the txt and gif files
47 build_py.run(self)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000048 for name in txt_files:
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +000049 outfile = self.get_plain_outfile(self.build_lib, [], name)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000050 dir = os.path.dirname(outfile)
51 self.mkpath(dir)
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +000052 self.copy_file(os.path.join(pkg_dir, name), outfile,
Neal Norwitz3e0edbf2002-11-30 17:54:17 +000053 preserve_mode = 0)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000054 for name in Icons:
55 outfile = self.get_plain_outfile(self.build_lib,
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +000056 ["Icons"], name)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000057 dir = os.path.dirname(outfile)
58 self.mkpath(dir)
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000059 self.copy_file(os.path.join("Icons", name),
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000060 outfile, preserve_mode = 0)
61
62 def get_source_files(self):
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000063 # returns the .py files, the .txt and .def files, and the icons
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +000064 icons = [os.path.join(pkg_dir, "Icons",name) for name in Icons]
65 txts = [os.path.join(pkg_dir, name) for name in txt_files]
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000066 return build_py.get_source_files(self) + txt_files + icons
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000067
68 def get_outputs(self, include_bytecode=1):
69 # returns the built files
70 outputs = build_py.get_outputs(self, include_bytecode)
71 if not include_bytecode:
72 return outputs
73 for name in txt_files:
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +000074 filename = self.get_plain_outfile(self.build_lib, [], name)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000075 outputs.append(filename)
76 for name in Icons:
77 filename = self.get_plain_outfile(self.build_lib,
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +000078 ["Icons"], name)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000079 outputs.append(filename)
80 return outputs
81
82# Arghhh. install_lib thinks that all files returned from build_py's
83# get_outputs are bytecode files
Kurt B. Kaiser59e07bd2001-07-17 05:12:42 +000084
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000085class IDLE_Installer(install_lib):
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000086 def _bytecode_filenames(self, files):
87 files = [n for n in files if n.endswith('.py')]
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000088 return install_lib._bytecode_filenames(self, files)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000089
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000090setup(name="IDLEfork",
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000091 version = idlever.IDLE_VERSION,
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000092 description = "IDLEfork, the Developmental Python IDE",
93 author = "Guido van Rossum et. al.",
94 author_email = "idle-dev@python.org",
Kurt B. Kaiser18091542002-12-22 01:48:28 +000095 license = "PSF: www.python.org",
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000096 url = "https://sourceforge.net/projects/idlefork/",
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000097 long_description =
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +000098"""IDLE is a Tkinter based IDE for Python. It is written in 100% pure
99Python and works both on Windows and Unix. It features a multi-window
100text editor with multiple undo, Python colorizing, and many other
101things, as well as a Python shell window and a debugger.
Kurt B. Kaiser59e07bd2001-07-17 05:12:42 +0000102
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +0000103IDLEfork is a separate line of development which was initiated by
104D. Scherer at CMU as part of Visual Python. It features execution in a
105separate process which is newly initiated for each run. At version 0.9
106the RPC was changed to incorporate code by GvR, which supports the
107debugger. IDLEfork also incorporates a GUI configuration utilility.
108For further details, refer to idlefork.sourceforge.net.
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +0000109""",
110
111 cmdclass = {'build_py':IDLE_Builder,
112 'install_lib':IDLE_Installer},
Kurt B. Kaiserda4d3c12002-12-23 03:31:49 +0000113 package_dir = {pkgname: pkg_dir},
114 extra_path = pkgname,
115 py_modules = [f.split('.')[0] for f in glob.glob("*.py")],
116 scripts = [os.path.join(pkg_dir, idle_name)]
Steven M. Gavad7b6ed22001-06-25 07:23:57 +0000117 )