Changeset 731406c in sasview for prview/build_prview.py


Ignore:
Timestamp:
Jun 20, 2010 6:25:45 PM (14 years ago)
Author:
Mathieu Doucet <doucetm@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
43db4a8
Parents:
ed90edb
Message:

PrView?: updated build script

File:
1 edited

Legend:

Unmodified
Added
Removed
  • prview/build_prview.py

    re4193d9 r731406c  
    66# SVN must be installed: 
    77# http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91 
    8 # Make sure svn.exe in on the path. You might need to log out and log back in again after installing SVN. 
    9 # 
    10 # Inno Setup must be installed 
    11 # 
    12 # py2exe must be installed  
    13 # 
    14 # mingw must be installed 
     8# 
     9# 
     10# On Windows: 
     11#   - Make sure svn.exe in on the path. You might need to log out and log back in again after installing SVN. 
     12#   - Inno Setup must be installed 
     13#   - py2exe must be installed  
     14#   - mingw must be installed 
     15# 
     16# In Mac: 
     17#   - py2app must be installed 
     18#   - macholib must be installed to use py2app 
     19#   - modulegraph must be installed to use py2app 
    1520# 
    1621# Usage: 
     
    2328#   -n: Print out the dependencies for the release notes 
    2429 
    25  
    26 #TODO: touch site danse/__init__.py 
    27 #TODO: touch site danse/common/__init__.py 
    28  
    29  
    3030import os 
    3131import sys 
     
    3636import time 
    3737timestamp = int(time.time()) 
     38CWD = os.getcwd() 
    3839INSTALL_FOLDER = "install_%s" % str(timestamp) 
     40 
     41# On Windows, the python executable is not always on the path. 
     42# Use its most frequent location as the default. 
     43if sys.platform == 'win32': 
     44    PYTHON = "c:\python25\python" 
     45    LIB_FOLDER = "%s/%s" % (CWD, INSTALL_FOLDER) 
     46else: 
     47    PYTHON = 'python' 
    3948 
    4049logging.basicConfig(level=logging.INFO, 
     
    4352                    filemode='w') 
    4453 
    45 CWD    = os.getcwd() 
    46  
    47 # On Windows, the python executable is not always on the path. 
    48 # Use its most frequent location as the default. 
    49 if sys.platform == 'win32': 
    50     PYTHON = "c:\python25\python" 
    51     BUILD_OPT = '-cmingw32' 
    52 else: 
    53     PYTHON = 'python' 
    54     BUILD_OPT = '' 
    55  
    5654SVN    = "svn" 
    5755INNO   = "\"c:\Program Files\Inno Setup 5\ISCC\"" 
    5856 
    59 # Release version 0.2.3 
    60 DATALOADER = "0.2.4" 
    61 GUICOMM    = "0.1.3" 
    62 GUIFRAME   = "0.1.7" 
    63 PRVIEW     = "0.3.0" 
    64 PLOTTOOLS  = "0.1.6" 
    65 UTIL       = "0.1.2" 
    66 PR_INV = "0.2.2" 
     57# Release version 0.3.3 
     58DATALOADER = "0.2.7" 
     59GUICOMM    = "0.1.5" 
     60GUIFRAME   = "0.2.0" 
     61PRVIEW     = "0.3.3" 
     62PLOTTOOLS  = "0.1.9" 
     63UTIL       = "0.1.5" 
     64PR_INV = "0.2.5" 
    6765 
    6866# URLs for SVN repos 
     
    111109        @param url: URL of the SVN repo 
    112110    """ 
    113     if not os.path.isdir(install_dir): 
    114         os.mkdir(install_dir) 
    115     os.chdir(install_dir)    
    116     os.system("%s checkout -q %s" % (SVN, url))         
    117     os.chdir(setup_dir) 
    118     os.system("%s setup.py -q build %s" % (PYTHON, BUILD_OPT)) 
    119     os.system("%s setup.py -q install" % PYTHON) 
     111    logging.info("Installing %s" % url) 
     112    try: 
     113        if not os.path.isdir(install_dir): 
     114            os.mkdir(install_dir) 
     115        os.chdir(install_dir)    
     116        os.system("%s checkout -q %s" % (SVN, url))         
     117        os.chdir(setup_dir) 
     118        if sys.platform == 'win32': 
     119            os.system("%s setup.py -q build -cmingw32" % PYTHON) 
     120            os.system("%s setup.py -q install --root \"%s\"" % (PYTHON, LIB_FOLDER)) 
     121        else: 
     122            os.system("%s setup.py build" % PYTHON) 
     123            os.system("%s setup.py install --prefix ~/.local" % PYTHON) 
     124    except: 
     125        logging.error("Install failed for %s" % url) 
     126        logging.error(sys.exc_value) 
     127        raw_input("Press enter to continue\n") 
     128        sys.exit() 
    120129     
    121130def checkout(release=False): 
     
    167176        os.system("%s checkout -q svn://danse.us/sans/trunk/prview" % SVN) 
    168177     
    169 def prepare(wipeout = False, install_folder=INSTALL_FOLDER): 
     178def prepare(wipeout = False): 
    170179    """ 
    171180        Prepare the build 
     181         
     182        @param wipeout: If True, the DANSE modules in the standard site-packages will be 
     183        removed to avoid conflicts. 
    172184    """ 
    173185    # Remove existing libraries 
    174186    if wipeout == True: 
    175         print "Deleting old modules" 
     187        logging.info("Deleting DANSES modules in site-packages") 
    176188        from distutils.sysconfig import get_python_lib 
    177189        libdir = get_python_lib() 
     
    187199         
    188200    # Create a fresh installation folder 
    189     if os.path.isdir(install_folder): 
    190         shutil.rmtree(install_folder) 
    191  
    192     os.mkdir(install_folder) 
     201    if os.path.isdir(INSTALL_FOLDER): 
     202        shutil.rmtree(INSTALL_FOLDER) 
     203 
     204    os.mkdir(INSTALL_FOLDER) 
    193205     
    194206    # Check that the dependencies are properly installed 
     
    196208     
    197209    # Move to the installation folder 
    198     os.chdir(install_folder)     
     210    os.chdir(INSTALL_FOLDER)    
    199211 
    200212def warning(): 
     
    218230    print "Build script for PrView %s" % PRVIEW 
    219231     
    220     #TODO: add --prefix option 
    221      
    222232    if len(sys.argv)==1: 
    223         # By default, build release version in site-packages without cleanup 
    224         logging.info("Building release version") 
    225         prepare(install_folder="prview") 
    226         checkout(True) 
    227         # Create run script 
    228         f = open("run_prview.py", 'w') 
    229         buff  = "import os, sys, site\n" 
    230         buff += "if __name__ == \"__main__\":\n" 
    231         buff += "    sys.path.append(os.path.join(os.getcwd(),\"prview-%s\"))\n" % PRVIEW 
    232         buff += "    site.addsitedir(os.path.join(os.getcwd(),\"prview-%s\"))\n" % PRVIEW 
    233         buff += "    os.chdir(\"prview-%s\")\n" % PRVIEW 
    234         buff += "    import sansview\n" 
    235         buff += "    sansview.SansView()\n" 
    236         f.write(buff) 
    237         f.close() 
    238          
    239     elif len(sys.argv)>1: 
     233        # If there is no argument, build the installer 
     234        sys.argv.append("-i") 
     235     
     236    if len(sys.argv)>1: 
    240237        # Help 
    241238        if sys.argv[1]=="-h": 
     
    274271                checkout(True) 
    275272                if sys.platform=='win32': 
    276                     logging.info("Building installer from release version") 
     273                    logging.info("Building Windows installer from release version") 
    277274                    os.chdir("prview-%s" % (PRVIEW)) 
    278                     os.system("%s setup_exe.py -q py2exe" % PYTHON) 
     275                    os.system("%s setup_exe.py py2exe --extrapath \"%s\python25\lib\site-packages\"" % (PYTHON, LIB_FOLDER)) 
    279276                    os.system("%s/Q installer.iss" % INNO) 
    280                     shutil.copy2(os.path.join("Output","setupPrView.exe"),  
    281                                  os.path.join(CWD, "setupPrView_%s.exe" % str(timestamp))) 
     277                    shutil.copy2(os.path.join("Output","setupSansView.exe"),  
     278                                 os.path.join(CWD, "setupSansView_%s.exe" % str(timestamp))) 
     279                elif sys.platform=='darwin': 
     280                    logging.info("Building Mac application from release version") 
     281                    os.chdir("prview-%s" % (PRVIEW)) 
     282                    os.system("%s setup_mac.py py2app" % PYTHON)                     
    282283                     
    283      
     284    raw_input("Press enter to continue\n") 
Note: See TracChangeset for help on using the changeset viewer.