-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow running the GUI w/o pixi install
- Loading branch information
Showing
4 changed files
with
121 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# script to start GSAS-II when not installed via pixi | ||
import os | ||
os.environ["GSASII_YOLO_PATH"] = "True" | ||
from GSASII.GSASII import main | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# modules for use where GSAS-II binaries are not co-located with | ||
# the main GSAS-II files and the path is modified (I can hear Tom | ||
# saying "Shame, Shame!"). | ||
|
||
import glob | ||
import os | ||
import sys | ||
import numpy as np | ||
from . import GSASIIpath | ||
|
||
def _path_discovery(printInfo=False): | ||
def appendIfExists(searchpathlist,loc,subdir): | ||
newpath = os.path.join(loc,subdir) | ||
if os.path.exists(newpath): | ||
if newpath in searchpathlist: return False | ||
searchpathlist.append(newpath) | ||
inpver = GSASIIpath.intver(np.__version__) | ||
|
||
if GSASIIpath.path2GSAS2 not in sys.path: | ||
sys.path.insert(0,GSASIIpath.path2GSAS2) # make sure current path is used | ||
binpath = None | ||
binprfx = GSASIIpath.GetBinaryPrefix() | ||
# places to look for the GSAS-II binary directory | ||
binseapath = [os.path.abspath(sys.path[0])] # where Python is installed | ||
binseapath += [os.path.abspath(os.path.dirname(__file__))] # directory where this file is found | ||
binseapath += [os.path.dirname(binseapath[-1])] # parent of above directory | ||
binseapath += [os.path.expanduser('~/.GSASII')] # directory in user's home | ||
searched = [] | ||
for loc in binseapath: | ||
if loc in searched: continue | ||
if not os.path.exists(loc): continue | ||
searched.append(loc) | ||
# Look at bin directory (created by a local compile) before looking for standard dist files | ||
searchpathlist = [] | ||
appendIfExists(searchpathlist,loc,'bin') | ||
appendIfExists(searchpathlist,loc,'bindist') | ||
appendIfExists(searchpathlist,loc,'GSASII-bin') | ||
# also look for directories named by platform etc in loc/AllBinaries or loc | ||
versions = {} | ||
namedpath = glob.glob(os.path.join(loc,'AllBinaries',binprfx+'*')) | ||
namedpath += glob.glob(os.path.join(loc,'GSASII-bin',binprfx+'*')) | ||
for d in namedpath: | ||
d = os.path.realpath(d) | ||
v = GSASIIpath.intver(d.rstrip('/').split('_')[-1].lstrip('n')) | ||
versions[v] = d | ||
vmin = None | ||
vmax = None | ||
# try to order the search in a way that makes sense | ||
for v in sorted(versions.keys()): | ||
if v <= inpver: | ||
vmin = v | ||
elif v > inpver: | ||
vmax = v | ||
break | ||
if vmin in versions and versions[vmin] not in searchpathlist: | ||
searchpathlist.append(versions[vmin]) | ||
if vmax in versions and versions[vmax] not in searchpathlist: | ||
searchpathlist.append(versions[vmax]) | ||
for fpth in searchpathlist: | ||
if not glob.glob(os.path.join(fpth,'pyspg.*')): continue | ||
if GSASIIpath.TestSPG(fpth): | ||
binpath = fpth # got one that works, look no farther! | ||
break | ||
else: | ||
continue | ||
break | ||
if binpath: # were GSAS-II binaries found? | ||
GSASIIpath.binaryPath = binpath | ||
GSASIIpath.BinaryPathLoaded = True | ||
else: | ||
print('*** ERROR: Unable to find GSAS-II binaries. Much of GSAS-II cannot function') | ||
if GSASIIpath.GetConfigValue('debug'): | ||
print('Searched directories:') | ||
for i in searched: print(f'\t{i}') | ||
print(f'''for subdirectories named .../bin, .../bindist, .../GSASII-bin, | ||
.../AllBinaries/{binprfx}* and .../GSASII-bin/{binprfx}*''') | ||
return True | ||
|
||
# add the data import and export directory to the search path | ||
if binpath not in sys.path: sys.path.insert(0,binpath) | ||
if printInfo: print(f'GSAS-II binary directory: {binpath}') | ||
|
||
# *** Thanks to work by Tom, imports and exports are now found directly | ||
# *** and the code below is no longer needed. | ||
# *** | ||
#newpath = os.path.join(path2GSAS2,'imports') | ||
#if newpath not in sys.path: sys.path.append(newpath) | ||
#newpath = os.path.join(path2GSAS2,'exports') | ||
#if newpath not in sys.path: sys.path.append(newpath) |