Neal Norwitz | 3e0edbf | 2002-11-30 17:54:17 +0000 | [diff] [blame] | 1 | import os, glob, sys |
Steven M. Gava | d7b6ed2 | 2001-06-25 07:23:57 +0000 | [diff] [blame] | 2 | from distutils.core import setup |
| 3 | from distutils.command.build_py import build_py |
| 4 | from distutils.command.install_lib import install_lib |
| 5 | import idlever |
| 6 | |
Neal Norwitz | 3e0edbf | 2002-11-30 17:54:17 +0000 | [diff] [blame] | 7 | try: |
| 8 | pos = sys.argv.index("--check-tkinter") |
| 9 | except ValueError: |
| 10 | pass |
| 11 | else: |
| 12 | del sys.argv[pos] |
| 13 | try: |
| 14 | import _tkinter |
| 15 | except ImportError: |
| 16 | print >>sys.stderr, "Cannot install IDLE without _tkinter" |
| 17 | raise SystemExit |
| 18 | |
| 19 | try: |
| 20 | package_dir = os.path.join(os.environ["SRCDIR"], "Tools", "idle") |
| 21 | except KeyError: |
| 22 | package_dir = "." |
| 23 | |
Steven M. Gava | d7b6ed2 | 2001-06-25 07:23:57 +0000 | [diff] [blame] | 24 | # name of idle package |
| 25 | idlelib = "idlelib" |
| 26 | |
| 27 | # the normal build_py would not incorporate the .txt files |
Kurt B. Kaiser | 3eb7860 | 2001-07-14 05:48:44 +0000 | [diff] [blame] | 28 | txt_files = ['config-unix.txt','config-win.txt','config.txt', 'help.txt'] |
Steven M. Gava | d7b6ed2 | 2001-06-25 07:23:57 +0000 | [diff] [blame] | 29 | Icons = glob.glob1("Icons","*.gif") |
| 30 | class idle_build_py(build_py): |
| 31 | def get_plain_outfile(self, build_dir, package, file): |
| 32 | # like get_module_outfile, but does not append .py |
| 33 | outfile_path = [build_dir] + list(package) + [file] |
| 34 | return apply(os.path.join, outfile_path) |
| 35 | |
| 36 | def run(self): |
| 37 | # Copies all .py files, then also copies the txt and gif files |
| 38 | build_py.run(self) |
| 39 | assert self.packages == [idlelib] |
| 40 | for name in txt_files: |
| 41 | outfile = self.get_plain_outfile(self.build_lib, [idlelib], name) |
| 42 | dir = os.path.dirname(outfile) |
| 43 | self.mkpath(dir) |
Neal Norwitz | 3e0edbf | 2002-11-30 17:54:17 +0000 | [diff] [blame] | 44 | self.copy_file(os.path.join(package_dir, name), outfile, |
| 45 | preserve_mode = 0) |
Steven M. Gava | d7b6ed2 | 2001-06-25 07:23:57 +0000 | [diff] [blame] | 46 | for name in Icons: |
| 47 | outfile = self.get_plain_outfile(self.build_lib, |
| 48 | [idlelib,"Icons"], name) |
| 49 | dir = os.path.dirname(outfile) |
| 50 | self.mkpath(dir) |
| 51 | self.copy_file(os.path.join("Icons",name), |
| 52 | outfile, preserve_mode = 0) |
| 53 | |
| 54 | def get_source_files(self): |
| 55 | # returns the .py files, the .txt files, and the icons |
Neal Norwitz | 3e0edbf | 2002-11-30 17:54:17 +0000 | [diff] [blame] | 56 | icons = [os.path.join(package_dir, "Icons",name) for name in Icons] |
| 57 | txts = [os.path.join(package_dir, name) for name in txt_files] |
Steven M. Gava | d7b6ed2 | 2001-06-25 07:23:57 +0000 | [diff] [blame] | 58 | return build_py.get_source_files(self)+txt_files+icons |
| 59 | |
| 60 | def get_outputs(self, include_bytecode=1): |
| 61 | # returns the built files |
| 62 | outputs = build_py.get_outputs(self, include_bytecode) |
| 63 | if not include_bytecode: |
| 64 | return outputs |
| 65 | for name in txt_files: |
| 66 | filename = self.get_plain_outfile(self.build_lib, |
| 67 | [idlelib], name) |
| 68 | outputs.append(filename) |
| 69 | for name in Icons: |
| 70 | filename = self.get_plain_outfile(self.build_lib, |
| 71 | [idlelib,"Icons"], name) |
| 72 | outputs.append(filename) |
| 73 | return outputs |
| 74 | |
| 75 | # Arghhh. install_lib thinks that all files returned from build_py's |
| 76 | # get_outputs are bytecode files |
Kurt B. Kaiser | 59e07bd | 2001-07-17 05:12:42 +0000 | [diff] [blame] | 77 | |
Steven M. Gava | d7b6ed2 | 2001-06-25 07:23:57 +0000 | [diff] [blame] | 78 | class idle_install_lib(install_lib): |
| 79 | def _bytecode_filenames(self, files): |
| 80 | files = [n for n in files if n.endswith('.py')] |
| 81 | return install_lib._bytecode_filenames(self,files) |
| 82 | |
Steven M. Gava | d7b6ed2 | 2001-06-25 07:23:57 +0000 | [diff] [blame] | 83 | setup(name="IDLE", |
| 84 | version = idlever.IDLE_VERSION, |
Kurt B. Kaiser | 59e07bd | 2001-07-17 05:12:42 +0000 | [diff] [blame] | 85 | description = "IDLE Fork, the Forked Python IDE", |
Steven M. Gava | d7b6ed2 | 2001-06-25 07:23:57 +0000 | [diff] [blame] | 86 | author = "Guido van Rossum", |
| 87 | author_email = "guido@python.org", |
| 88 | #url = |
| 89 | long_description = |
| 90 | """IDLE is a Tkinter based IDE for Python. It is written in 100% pure |
| 91 | Python and works both on Windows and Unix. It features a multi-window |
| 92 | text editor with multiple undo, Python colorizing, and many other things, |
Kurt B. Kaiser | 59e07bd | 2001-07-17 05:12:42 +0000 | [diff] [blame] | 93 | as well as a Python shell window and a debugger. |
| 94 | |
| 95 | IDLE Fork is a separate line of development which was initiated by D. Scherer |
| 96 | at CMU as part of Visual Python. It features execution in a separate |
| 97 | process, with a fresh environment for each run. For further details, |
| 98 | refer to idlefork.sourceforge.net.""", |
Steven M. Gava | d7b6ed2 | 2001-06-25 07:23:57 +0000 | [diff] [blame] | 99 | |
| 100 | cmdclass = {'build_py':idle_build_py, |
| 101 | 'install_lib':idle_install_lib}, |
Neal Norwitz | 3e0edbf | 2002-11-30 17:54:17 +0000 | [diff] [blame] | 102 | package_dir = {idlelib: package_dir}, |
Steven M. Gava | d7b6ed2 | 2001-06-25 07:23:57 +0000 | [diff] [blame] | 103 | packages = [idlelib], |
Neal Norwitz | 3e0edbf | 2002-11-30 17:54:17 +0000 | [diff] [blame] | 104 | scripts = [os.path.join(package_dir, 'idle')] |
Steven M. Gava | d7b6ed2 | 2001-06-25 07:23:57 +0000 | [diff] [blame] | 105 | ) |