Changeset 5285 for trunk/GSASIIphsGUI.py
- Timestamp:
- May 20, 2022 12:35:20 PM (19 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIphsGUI.py
r5278 r5285 103 103 Angstr = chr(0x00c5) 104 104 105 RMCmisc = {} 105 106 #### phase class definitions ################################################################################ 106 107 class SymOpDialog(wx.Dialog): … … 4941 4942 def OnSeqReverse(event): 4942 4943 RMCPdict['SeqReverse'] = not RMCPdict['SeqReverse'] 4943 4944 4945 # --- FileSizer starts here 4944 4946 Indx = {} 4945 4947 mainSizer = wx.BoxSizer(wx.VERTICAL) … … 6241 6243 RMCsel.Bind(wx.EVT_RADIOBOX, OnRMCselect) 6242 6244 mainSizer.Add(RMCsel,0) 6245 RMCmisc['RMCnote'] = wx.StaticText(G2frame.FRMC) 6246 mainSizer.Add(RMCmisc['RMCnote']) 6243 6247 G2G.HorizontalLine(mainSizer,G2frame.FRMC) 6244 6248 mainSizer.Add(wx.StaticText(G2frame.FRMC, … … 6259 6263 bigSizer.Add(G2G.HelpButton(G2frame.FRMC,helpIndex=G2frame.dataWindow.helpKey)) 6260 6264 SetPhaseWindow(G2frame.FRMC,bigSizer) 6261 if G2frame.RMCchoice == 'fullrmc' and G2pwd.findfullrmc() is None: 6265 if G2frame.RMCchoice == 'PDFfit' and not checkPDFfit(G2frame): 6266 RMCmisc['RMCnote'].SetLabel('PDFfit may not be installed or operational') 6267 elif G2frame.RMCchoice == 'fullrmc' and G2pwd.findfullrmc() is None: 6262 6268 dlg = wx.MessageDialog(G2frame, 6263 6269 'The fullrmc code is not installed or could not be' … … 6385 6391 if sys.platform.lower().startswith('win'): 6386 6392 batch = open('pdffit2.bat','w') 6393 # TODO: should probably include an activate command here 6387 6394 batch.write(PDFfit_exec+' '+rname+'\n') 6388 6395 # batch.write('pause') … … 6393 6400 batch = open('pdffit2.sh','w') 6394 6401 batch.write('#!/bin/bash\n') 6402 # TODO: should probably include an activate command here 6395 6403 batch.write('cd ' + os.path.split(os.path.abspath(rname))[0] + '\n') 6396 6404 batch.write(PDFfit_exec + ' ' + os.path.abspath(rname) + '\n') … … 14565 14573 return 14566 14574 ChangePage(0) 14575 14576 def checkPDFfit(G2frame): 14577 '''Checks to see if PDFfit2 is available and can be imported. PDFfit2 can be installed 14578 in a separate Python interpreter (saved in the pdffit2_exec config variable). If this is 14579 defined, no attempt is made to check that it actually runs. 14580 Otherwise, if diffpy.PDFfit has been installed with conda/pip, it is checked if the 14581 install command. The fallback is to check if a .so/.pyd file has been supplied with 14582 GSAS-II. This requires that GSL (GNU Scientific Library) be installed. If the current 14583 Python is being run from conda, this will be loaded. 14584 14585 :returns: False if PDFfit2 cannot be run/accessed. True if it appears it can be run. 14586 ''' 14587 # if a separate Python interpreter has been specified, just use it, no checking 14588 if GSASIIpath.GetConfigValue('pdffit2_exec') is not None and is_exe( 14589 GSASIIpath.GetConfigValue('pdffit2_exec')): 14590 return True 14591 14592 # see if diffpy has been installed directly 14593 try: 14594 from diffpy.pdffit2 import PdfFit 14595 return True 14596 except: 14597 pass 14598 14599 # See if if we can import the GSAS-II supplied PDFfit 14600 pdffitloc = os.path.join(GSASIIpath.path2GSAS2,'PDFfit2') 14601 if pdffitloc not in sys.path: sys.path.append(pdffitloc) 14602 try: 14603 from diffpy.pdffit2 import PdfFit 14604 #pf = PdfFit() 14605 return True 14606 except Exception as err: 14607 pass 14608 #print('Failed to import PDFfit2 with error\n:'+str(err)) 14609 14610 if not os.path.exists(pdffitloc): 14611 print('PDFfit2 not found in GSAS-II \n\t(expected in '+pdffitloc+')') 14612 return False 14613 import glob 14614 if not glob.glob(os.path.join(GSASIIpath.binaryPath,'pdffit*')): 14615 msg = 'GSAS-II does not supply PDFfit2 for the version of Python that you are using' 14616 G2G.G2MessageBox(G2frame,msg,'Need PDFfit2') 14617 return False 14618 14619 # see if we can fix things so the GSAS-II version can be used 14620 if not GSASIIpath.condaTest(): 14621 msg = ('PDFfit2 is not running with this Python installation. '+ 14622 'Since Python was not installed under conda you need to install this yourself. '+ 14623 'pip install diffpy.pdffit2" may do this for you. You will likely need to '+ 14624 'install the GSL (GNU Software Library).') 14625 G2G.G2MessageBox(G2frame,msg,'No conda') 14626 return False 14627 # can we access conda? 14628 try: 14629 import conda.cli.python_api 14630 except: 14631 msg = ('You do not have the conda package installed in this '+ 14632 'environment so nothing can be installed.', 14633 '\n\nConsider using the "conda install conda" command') 14634 G2G.G2MessageBox(G2frame,msg,'conda import error') 14635 return False 14636 14637 if 'gsl' not in conda.cli.python_api.run_command(conda.cli.python_api.Commands.LIST,'gsl')[0].lower(): 14638 msg = ('The gsl (GNU Software Library), needed by PDFfit2, '+ 14639 ' is not installed in this Python. Do you want to have this installed?') 14640 dlg = wx.MessageDialog(G2frame,msg,caption='Install?', 14641 style=wx.YES_NO|wx.ICON_QUESTION) 14642 if dlg.ShowModal() != wx.ID_YES: 14643 dlg.Destroy() 14644 return False 14645 dlg.Destroy() 14646 wx.BeginBusyCursor() 14647 print('Preparing to install gsl. This may take a few minutes...') 14648 res = GSASIIpath.condaInstall(['gsl']) 14649 wx.EndBusyCursor() 14650 if res: 14651 msg = 'Installation of the GSL package failed with error:\n' + str(res) 14652 G2G.G2MessageBox(G2frame,msg,'Install GSL Error') 14653 14654 # GSAS-II supplied version for PDFfit now runs? 14655 if pdffitloc not in sys.path: sys.path.append(pdffitloc) 14656 try: 14657 from diffpy.pdffit2 import PdfFit 14658 #pf = PdfFit() 14659 except Exception as err: 14660 msg = 'Failed to import PDFfit2 with error\n:'+str(err) 14661 G2G.G2MessageBox(G2frame,msg,'PDFfit2 import error') 14662 return False 14663 return True
Note: See TracChangeset
for help on using the changeset viewer.