Refactor: Split config objects to Gui and Probe
[mentor.git] / build.py
blob14096e3960691d1e9c4123210453f0b1dd53d6e8
1 #!/usr/bin/env python
4 # version.py of releases is embedded somewhere
5 # it is used
7 # WARNING!
8 # files from utils/misc must be included in this directory if I want a redistributable
9 # project
12 # This is a general script for building distribution of mentor project
13 # the following options are available:
14 # build.py website - builds html pages for output to sourceforge repository
15 # using rest2html (restructuredText)
16 # from website and doc directories
17 # build.py egg - builds an egg out of python to be installed by setuptools
20 # build.py source - builds source distribution Releases/source.zip and Releases/source.tar.gz
21 # for building manually under windows and linux
22 # instructions and prerequisites for building are detailed in INSTALL file
23 # build.py windows - builds windows binary and nsis/nullsoft installer
24 # only one exe needed
25 # build.py deb - creates a debian deb file for automatic debian/ubuntu package installation
26 # build.py rpm - creates a rpm file for automatic fedora/redhat/opensuse installation
27 # build.py all - all of the above are built automatically
29 # build.py tests - run all unittests and doctests for source files
34 # TODO
35 # add current version number to releases
36 # TODO
37 # add NSIS installer
39 import subprocess
40 import shutil
41 import os
42 import sys
43 from src.utils import save_stamped_buildno, delete_stamped_buildno
45 # generating mentor_rc if necessary
46 if not os.path.isfile('src/mentor_rc.py'):
47 print "Generating resources file..."
48 os.chdir('src')
49 f = open("mentor_rc.py", "wt")
50 subprocess.call("pyrcc4.exe mentor.qrc", stdout=f)
51 f.close()
52 os.chdir('..')
55 print "Generating new version number..."
56 save_stamped_buildno()
58 print "Preparing..."
60 def removetree(dirname):
61 if os.path.isdir(dirname):
62 shutil.rmtree(dirname)
65 removetree("build")
66 removetree("dist")
68 print "Building exe file..."
69 subprocess.call("python.exe setup.py py2exe")
71 print "Building doc file..."
72 subprocess.call("c:/Programs/MiKTeX/miktex/bin/latex.exe -output-directory=dist doc/mentor.tex")
73 subprocess.call("c:/Programs/MiKTeX/miktex/bin/dvipdfm.exe -o dist/mentor.pdf dist/mentor.dvi")
74 os.remove("dist/mentor.aux")
75 os.remove("dist/mentor.dvi")
76 os.remove("dist/mentor.log")
80 print "Clearing temp files..."
81 removetree("../../Releases/current/dist")
82 removetree("build")
84 print "Moving dist to Releases..."
85 removetree("../../Releases/current")
86 shutil.move("dist", "../../Releases/current")
89 # This deletes the stamp to avoid showing build number
90 # in non built version
91 delete_stamped_buildno()
93 print "Done."