Martin v. Löwis | 646ddec | 2001-01-28 11:01:50 +0000 | [diff] [blame] | 1 | import os,glob |
| 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 | |
| 7 | # name of idle package |
| 8 | idlelib = "idlelib" |
| 9 | |
| 10 | # the normal build_py would not incorporate the .txt files |
| 11 | txt_files = ['config-unix.txt','config-win.txt','config.txt'] |
| 12 | Icons = glob.glob1("Icons","*.gif") |
| 13 | class idle_build_py(build_py): |
| 14 | def get_plain_outfile(self, build_dir, package, file): |
| 15 | # like get_module_outfile, but does not append .py |
| 16 | outfile_path = [build_dir] + list(package) + [file] |
| 17 | return apply(os.path.join, outfile_path) |
| 18 | |
| 19 | def run(self): |
| 20 | # Copies all .py files, then also copies the txt and gif files |
| 21 | build_py.run(self) |
| 22 | assert self.packages == [idlelib] |
| 23 | for name in txt_files: |
| 24 | outfile = self.get_plain_outfile(self.build_lib, [idlelib], name) |
| 25 | dir = os.path.dirname(outfile) |
| 26 | self.mkpath(dir) |
| 27 | self.copy_file(name, outfile, preserve_mode = 0) |
| 28 | for name in Icons: |
| 29 | outfile = self.get_plain_outfile(self.build_lib, |
| 30 | [idlelib,"Icons"], name) |
| 31 | dir = os.path.dirname(outfile) |
| 32 | self.mkpath(dir) |
| 33 | self.copy_file(os.path.join("Icons",name), |
| 34 | outfile, preserve_mode = 0) |
| 35 | |
| 36 | def get_source_files(self): |
| 37 | # returns the .py files, the .txt files, and the icons |
| 38 | icons = [os.path.join("Icons",name) for name in Icons] |
| 39 | return build_py.get_source_files(self)+txt_files+icons |
| 40 | |
| 41 | def get_outputs(self, include_bytecode=1): |
| 42 | # returns the built files |
| 43 | outputs = build_py.get_outputs(self, include_bytecode) |
| 44 | if not include_bytecode: |
| 45 | return outputs |
| 46 | for name in txt_files: |
| 47 | filename = self.get_plain_outfile(self.build_lib, |
| 48 | [idlelib], name) |
| 49 | outputs.append(filename) |
| 50 | for name in Icons: |
| 51 | filename = self.get_plain_outfile(self.build_lib, |
| 52 | [idlelib,"Icons"], name) |
| 53 | outputs.append(filename) |
| 54 | return outputs |
| 55 | |
| 56 | # Arghhh. install_lib thinks that all files returned from build_py's |
| 57 | # get_outputs are bytecode files |
| 58 | class idle_install_lib(install_lib): |
| 59 | def _bytecode_filenames(self, files): |
| 60 | files = [n for n in files if n.endswith('.py')] |
| 61 | return install_lib._bytecode_filenames(self,files) |
| 62 | |
| 63 | |
| 64 | setup(name="IDLE", |
| 65 | version = idlever.IDLE_VERSION, |
| 66 | description = "IDLE, the Python IDE", |
| 67 | author = "Guido van Rossum", |
| 68 | author_email = "guido@python.org", |
| 69 | #url = |
| 70 | long_description = |
| 71 | """IDLE is a Tkinter based IDE for Python. It is written in 100% pure |
| 72 | Python and works both on Windows and Unix. It features a multi-window |
| 73 | text editor with multiple undo, Python colorizing, and many other things, |
| 74 | as well as a Python shell window and a debugger.""", |
| 75 | |
| 76 | cmdclass = {'build_py':idle_build_py, |
Tim Peters | 670fa52 | 2001-02-09 21:23:21 +0000 | [diff] [blame] | 77 | 'install_lib':idle_install_lib}, |
Martin v. Löwis | 646ddec | 2001-01-28 11:01:50 +0000 | [diff] [blame] | 78 | package_dir = {idlelib:'.'}, |
| 79 | packages = [idlelib], |
| 80 | scripts = ['idle'] |
| 81 | ) |