blob: 02fd99745dcc94f07fa827be5a87c9d32a125487 [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. Kaiserdd70e1b2002-12-21 21:03:06 +000034
35# Create a .pth file to live in site-packages; Python will add IDLE to
36# sys.path:
37
38pathfile = idle_name + ".pth"
39pfile = open(pathfile, 'w')
40pfile.write(pkgname +'\n')
41pfile.close()
42
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000043class IDLE_Builder(build_py):
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000044 def get_plain_outfile(self, build_dir, package, file):
45 # like get_module_outfile, but does not append .py
46 outfile_path = [build_dir] + list(package) + [file]
47 return apply(os.path.join, outfile_path)
48
49 def run(self):
50 # Copies all .py files, then also copies the txt and gif files
51 build_py.run(self)
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000052 assert self.packages == [pkgname]
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000053 for name in txt_files:
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000054 outfile = self.get_plain_outfile(self.build_lib, [pkgname], name)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000055 dir = os.path.dirname(outfile)
56 self.mkpath(dir)
Neal Norwitz3e0edbf2002-11-30 17:54:17 +000057 self.copy_file(os.path.join(package_dir, name), outfile,
58 preserve_mode = 0)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000059 for name in Icons:
60 outfile = self.get_plain_outfile(self.build_lib,
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000061 [pkgname, "Icons"], name)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000062 dir = os.path.dirname(outfile)
63 self.mkpath(dir)
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000064 self.copy_file(os.path.join("Icons", name),
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000065 outfile, preserve_mode = 0)
Kurt B. Kaiserdd70e1b2002-12-21 21:03:06 +000066 # Copy the .pth file to the same level as the package directory
67 outfile = self.get_plain_outfile(self.build_lib, [], pathfile)
68 dir = os.path.dirname(outfile)
69 self.mkpath(dir)
70 self.copy_file(os.path.join(package_dir, pathfile), outfile,
71 preserve_mode=0)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000072
73 def get_source_files(self):
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000074 # returns the .py files, the .txt and .def files, and the icons
Neal Norwitz3e0edbf2002-11-30 17:54:17 +000075 icons = [os.path.join(package_dir, "Icons",name) for name in Icons]
76 txts = [os.path.join(package_dir, name) for name in txt_files]
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000077 return build_py.get_source_files(self) + txt_files + icons
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000078
79 def get_outputs(self, include_bytecode=1):
80 # returns the built files
81 outputs = build_py.get_outputs(self, include_bytecode)
82 if not include_bytecode:
83 return outputs
84 for name in txt_files:
85 filename = self.get_plain_outfile(self.build_lib,
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000086 [pkgname], name)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000087 outputs.append(filename)
88 for name in Icons:
89 filename = self.get_plain_outfile(self.build_lib,
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000090 [pkgname, "Icons"], name)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000091 outputs.append(filename)
92 return outputs
93
94# Arghhh. install_lib thinks that all files returned from build_py's
95# get_outputs are bytecode files
Kurt B. Kaiser59e07bd2001-07-17 05:12:42 +000096
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +000097class IDLE_Installer(install_lib):
Steven M. Gavad7b6ed22001-06-25 07:23:57 +000098 def _bytecode_filenames(self, files):
99 files = [n for n in files if n.endswith('.py')]
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +0000100 return install_lib._bytecode_filenames(self, files)
Steven M. Gavad7b6ed22001-06-25 07:23:57 +0000101
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +0000102setup(name="IDLEfork",
Steven M. Gavad7b6ed22001-06-25 07:23:57 +0000103 version = idlever.IDLE_VERSION,
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +0000104 description = "IDLEfork, the Developmental Python IDE",
105 author = "Guido van Rossum et. al.",
106 author_email = "idle-dev@python.org",
107 url = "https://sourceforge.net/projects/idlefork/",
Steven M. Gavad7b6ed22001-06-25 07:23:57 +0000108 long_description =
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +0000109"""IDLE is a Tkinter based IDE for Python. It is written in 100% pure Python
110and works both on Windows and Unix. It features a multi-window text editor with
111multiple undo, Python colorizing, and many other things, as well as a Python
112shell window and a debugger.
Kurt B. Kaiser59e07bd2001-07-17 05:12:42 +0000113
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +0000114IDLEfork is a separate line of development which was initiated by D. Scherer
115at CMU as part of Visual Python. It features execution in a separate process
116which is newly initiated for each run. At version 0.9 the RPC was changed to
117incorporate code by GvR, which supports the debugger. IDLEfork also
118incorporates a GUI configuration utilility. For further details, refer to
119idlefork.sourceforge.net.
Steven M. Gavad7b6ed22001-06-25 07:23:57 +0000120
Kurt B. Kaiserf39f59a2002-12-20 22:40:30 +0000121""",
122
123 cmdclass = {'build_py':IDLE_Builder,
124 'install_lib':IDLE_Installer},
125 package_dir = {pkgname: package_dir},
126 packages = [pkgname],
127 scripts = [os.path.join(package_dir, idle_name)]
Steven M. Gavad7b6ed22001-06-25 07:23:57 +0000128 )