Changeset 3201
- Timestamp:
- Dec 22, 2017 7:11:41 PM (5 years ago)
- Location:
- install
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
install/bootstrap.py
r3107 r3201 81 81 out,err = s.communicate() 82 82 if err: 83 print 'subversion error!\nout=',out84 print 'err=',err83 print('subversion error!\nout= '+out) 84 print('err= '+err) 85 85 return None 86 86 return out.strip() … … 100 100 ################################################################################ 101 101 ################################################################################ 102 print 70*'*'102 print(70*'*') 103 103 #testing for incorrect locale code' 104 104 try: … … 106 106 locale.getdefaultlocale() 107 107 except ValueError: 108 print 'Your location is not set properly. This causes problems for matplotlib'109 print ' (see https://github.com/matplotlib/matplotlib/issues/5420.)'110 print 'Will try to bypass problem by setting LC_ALL to en_US.UTF-8 (US English)'108 print('Your location is not set properly. This causes problems for matplotlib') 109 print(' (see https://github.com/matplotlib/matplotlib/issues/5420.)') 110 print('Will try to bypass problem by setting LC_ALL to en_US.UTF-8 (US English)') 111 111 os.environ['LC_ALL'] = 'en_US.UTF-8' 112 112 locale.getdefaultlocale() 113 print 'Preloading matplotlib to build fonts...'113 print('Preloading matplotlib to build fonts...') 114 114 try: 115 115 import matplotlib 116 116 except: 117 117 pass 118 print 'Checking python packages...',118 print('Checking python packages...') 119 119 missing = [] 120 120 for pkg in ['numpy','scipy','matplotlib','wx',]: … … 125 125 126 126 if missing: 127 print"""Sorry, this version of Python cannot be used127 msg = """Sorry, this version of Python cannot be used 128 128 for GSAS-II. It is missing the following package(s): 129 \t""", 130 for pkg in missing: print " ",pkg, 131 print "\nPlease install these package(s) and try running this again." 132 print "Showing first error: " 129 \t""" 130 for pkg in missing: msg += " "+pkg 131 print(msg) 132 print("\nPlease install these package(s) and try running this again.") 133 print("Showing first error: ") 133 134 for pkg in ['numpy','scipy','matplotlib','wx',]: 134 135 exec('import '+pkg) … … 141 142 from setuptools.command import easy_install 142 143 except ImportError: 143 print 'You are missing the OpenGL Python package. This can be '144 print 'installed by this script if the setuptools package is installed'145 print 'Please install either OpenGL (pyopengl) or setuptools'146 print "package and try running this again."144 print('You are missing the OpenGL Python package. This can be ') 145 print('installed by this script if the setuptools package is installed') 146 print('Please install either OpenGL (pyopengl) or setuptools') 147 print("package and try running this again.") 147 148 sys.exit() 148 print "Missing the OpenGL Python package. Will attempt to install this later."149 print("Missing the OpenGL Python package. Will attempt to install this later.") 149 150 def install_with_easyinstall(package): 150 151 try: 151 print "trying system-wide ",152 print("trying system-wide ") 152 153 easy_install.main(['-f',os.path.split(__file__)[0],package]) 153 154 return … … 155 156 pass 156 157 try: 157 print "trying user level ",158 print("trying user level ") 158 159 easy_install.main(['-f',os.path.split(__file__)[0],'--user',package]) 159 160 return 160 161 except: 161 print "\nInstall of "+package+" failed. Error traceback follows:"162 print("\nInstall of "+package+" failed. Error traceback follows:") 162 163 import traceback 163 print traceback.format_exc()164 print(traceback.format_exc()) 164 165 sys.exit() 165 166 166 print '\nChecking for subversion...',167 print('\nChecking for subversion...') 167 168 svn = whichsvn() 168 169 if not svn: 169 print "Sorry, subversion (svn) could not be found on your system."170 print "Please install this or place in path and rerun this."170 print("Sorry, subversion (svn) could not be found on your system.") 171 print("Please install this or place in path and rerun this.") 171 172 #raise Exception('Subversion (svn) not found') 172 173 sys.exit() 173 print ' found svn image: '+svn174 print(' found svn image: '+svn) 174 175 175 176 if install_with_easyinstall: 176 print '\nInstalling PyOpenGL. Lots of warnings will follow... ',177 print('\nInstalling PyOpenGL. Lots of warnings will follow... ') 177 178 install_with_easyinstall('PyOpenGl') 178 print 'done.'179 print('done.') 179 180 180 print 'Ready to bootstrap GSAS-II from repository\n\t',g2home,'\nto '+path2GSAS2181 print('Ready to bootstrap GSAS-II from repository\n\t'+g2home+'\nto '+path2GSAS2) 181 182 proxycmds = [] 182 183 proxyinfo = os.path.join(path2GSAS2,"proxyinfo.txt") … … 190 191 os.remove(proxyinfo) 191 192 print(70*"=") 193 if sys.version_info[0] == 2: 194 getinput = raw_input 195 else: 196 getinput = input 192 197 if host: 193 ans = raw_input("Enter the proxy address (type none to remove) ["+host+"]: ")198 ans = getinput("Enter the proxy address (type none to remove) ["+host+"]: ") 194 199 if ans.strip().lower() == "none": host = ans = "" 195 200 else: 196 ans = raw_input("Enter the proxy address [none needed]: ")201 ans = getinput("Enter the proxy address [none needed]: ") 197 202 if ans.strip() != "" or host: 198 203 proxycmds.append('--config-option') … … 201 206 fp = open(proxyinfo,'w') 202 207 fp.write(ans.strip()+'\n') 203 ans = raw_input("Enter the proxy port ["+port+"]: ")208 ans = getinput("Enter the proxy port ["+port+"]: ") 204 209 if ans.strip() == "": ans=port 205 210 proxycmds.append('--config-option') … … 212 217 p = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE) 213 218 res,err = p.communicate() 214 if '.xor.' in res:219 if '.xor.' in str(res): 215 220 print('Switching previous install with .xor. download location to\n\thttps://subversion.xray.aps.anl.gov/pyGSAS') 216 221 cmd = [svn, 'switch','--relocate','https://subversion.xor.aps.anl.gov/pyGSAS', … … 224 229 print(res) 225 230 # patch: switch GSAS-II location if switched to 2frame version (removed August 2017) 226 if '2frame' in res:231 if '2frame' in str(res): 227 232 print('Switching previous 2frame install to trunk\n\thttps://subversion.xray.aps.anl.gov/pyGSAS') 228 233 cmd = [svn, 'switch',g2home + '/trunk',path2GSAS2, … … 242 247 print('\n'+75*'*') 243 248 print(msg + u' from ' + cmd[2]) 244 print 'svn load command:'245 for item in cmd: print item,246 print ""249 msg = 'svn load command: ' 250 for item in cmd: msg += " "+item 251 print(msg) 247 252 s = subprocess.Popen(cmd,stderr=subprocess.PIPE) 248 253 print('\nsubversion output:') … … 257 262 cmd = [svn, 'co', g2home+ 'trunk/', path2GSAS2] 258 263 if proxycmds: cmd += proxycmds 259 for item in cmd: print item, 260 print "" 264 msg = "" 265 for item in cmd: msg += item 266 print(msg) 261 267 s = subprocess.Popen(cmd,stderr=subprocess.PIPE) 262 268 out,err = s.communicate() … … 313 319 cwd=path2GSAS2) 314 320 res,err = p.communicate() 315 if '==OK==' not in resor p.returncode != 0:321 if '==OK==' not in str(res) or p.returncode != 0: 316 322 print('\n'+75*'=') 317 323 print('Failed when testing the GSAS-II compiled files. GSAS-II will not run') 318 print('without correcting this. ')324 print('without correcting this.\n\nError message:') 319 325 #print(res) 320 #print(err)326 print(err) 321 327 #print('\nAttempting to open a web page on compiling GSAS-II...') 322 328 print('Please see web page\nhttps://subversion.xray.aps.anl.gov/trac/pyGSAS/wiki/CompileGSASII') … … 324 330 #webbrowser.open_new('https://subversion.xray.aps.anl.gov/trac/pyGSAS/wiki/CompileGSASII') 325 331 print(75*'=') 326 if '86' in platform.machine() and (sys.platform.startswith('linux')327 or sys.platform == "darwin"328 or sys.platform.startswith('win')):329 print('Platform '+sys.platform+' with processor type '+platform.machine()+' is supported')330 else:331 print('Platform '+sys.platform+' with processor type '+platform.machine()+' not is supported')332 # if '86' in platform.machine() and (sys.platform.startswith('linux') 333 # or sys.platform == "darwin" 334 # or sys.platform.startswith('win')): 335 # print('Platform '+sys.platform+' with processor type '+platform.machine()+' is supported') 336 # else: 337 # print('Platform '+sys.platform+' with processor type '+platform.machine()+' not is supported') 332 338 sys.exit() 333 339 else: 334 print 'Successfully tested compiled routines'340 print('Successfully tested compiled routines') 335 341 #=========================================================================== 336 342 # import all .py files so that .pyc files get created 337 print 'Byte-compiling all .py files...',343 print('Byte-compiling all .py files...') 338 344 import compileall 339 345 compileall.compile_dir(path2GSAS2,quiet=True) 340 print 'done'346 print('done') 341 347 #=========================================================================== 342 348 # platform-dependent stuff 343 349 #=========================================================================== 350 if sys.version_info[0] > 2: 351 def execfile(file): 352 with open(file) as source_file: 353 exec(source_file.read()) 344 354 # on Windows, make a batch file with Python and GSAS-II location hard-coded 345 355 if sys.platform.startswith('win') and os.path.exists( … … 355 365 #=========================================================================== 356 366 # On linux, make desktop icon 357 elif sys.platform.startswith('linux'): 358 desktop_template = """ 359 [Desktop Entry] 360 Version=1.0 361 Type=Application 362 Terminal=false 363 Exec=xterm -hold -e bash -c "{} {}" 364 Name=GSAS-II 365 Icon={} 366 Categories=Science; 367 """ 368 loc = os.path.expanduser('~/Desktop/') 369 if "XDG_DATA_HOME" in os.environ and os.path.exists(os.path.join(os.environ.get("XDG_DATA_HOME"),"applications")): 370 loc = os.path.join(os.environ.get("XDG_DATA_HOME"),"applications") 371 elif "HOME" in os.environ and os.path.exists(os.path.join(os.environ.get("HOME"),".local/share/applications")): 372 loc = os.path.join(os.environ.get("HOME"),".local/share/applications") 373 elif not os.path.exists(loc): 374 loc = os.path.expanduser('~/') 375 dfile = os.path.join(loc,'GSASII.desktop') 376 icon = os.path.join(path2GSAS2, 'gsas2.png') 377 script = os.path.join(path2GSAS2, 'GSASII.py') 378 os.chmod(script, # make the .py file executable and readable 379 stat.S_IXUSR | stat.S_IRUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IXOTH) 380 try: 381 open(dfile,'w').write(desktop_template.format(sys.executable,script,icon)) 382 os.chmod( 383 dfile, 384 stat.S_IWUSR | stat.S_IXUSR | stat.S_IRUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IXOTH) 385 print("created GNOME/KDE desktop shortcut "+dfile) 386 except: 387 print("creation of file failed: "+dfile) 388 367 elif sys.platform.startswith('linux') and os.path.exists( 368 os.path.join(path2GSAS2,"makeLinux.py")): 369 sys.argv = [os.path.join(path2GSAS2,"makeLinux.py")] 370 print(u'running '+sys.argv[0]) 371 execfile(sys.argv[0]) 372 -
install/g2conda/construct.yaml
r2855 r3201 1 1 name: g2conda 2 2 version: 0.1.2 3 3 #conda install numpy scipy matplotlib pillow h5py pyopengl pywin32 svn wxpython m2w64-gcc-libgfortran 4 4 install_in_dependency_order: True 5 5 -
install/g2pkg/meta.yaml
r2855 r3201 1 1 package: 2 2 name: g2load 3 version: 0. 1.8# remember to change in g2conda/construct.yaml to match this3 version: 0.2.0 # remember to change in g2conda/construct.yaml to match this 4 4 5 5 source:
Note: See TracChangeset
for help on using the changeset viewer.