Skip to content

Commit

Permalink
Replace stripDrive with pathlib
Browse files Browse the repository at this point in the history
Remove unused functions
  • Loading branch information
bryanwweber committed Apr 12, 2021
1 parent 4c79834 commit e0327a1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 41 deletions.
23 changes: 15 additions & 8 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -1472,16 +1472,23 @@ addInstallActions = ('install' in COMMAND_LINE_TARGETS or

# Directories where things will be staged for package creation. These
# variables should always be used by the Install(...) targets
if env['stage_dir']:
instRoot = pjoin(os.getcwd(), env['stage_dir'],
stripDrive(env['prefix']).strip('/\\'))
if env['python_prefix']:
env['python_prefix'] = pjoin(os.getcwd(), env['stage_dir'],
stripDrive(env['python_prefix']).strip('/\\'))
if env["stage_dir"]:
stage_prefix = Path(env["prefix"])
# Strip the root off the prefix if it's absolute
if stage_prefix.is_absolute():
stage_prefix = Path(*stage_prefix.parts[1:])

instRoot = Path.cwd().joinpath(env["stage_dir"], stage_prefix)

if env["python_prefix"]:
stage_py_prefix = Path(env["python_prefix"])
if stage_py_prefix.is_absolute():
stage_py_prefix = Path(*stage_py_prefix.parts[1:])
env["python_prefix"] = Path.cwd().joinpath(env["stage_dir"], stage_py_prefix)
else:
env['python_prefix'] = pjoin(os.getcwd(), env['stage_dir'])
env["python_prefix"] = Path.cwd().joinpath(env["stage_dir"])
else:
instRoot = env['prefix']
instRoot = env["prefix"]

# Prevent setting Cantera installation path to source directory
if os.path.abspath(instRoot) == Dir('.').abspath:
Expand Down
33 changes: 0 additions & 33 deletions site_scons/buildutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,39 +526,6 @@ def mglob(env, subdir, *args):
return matches


def psplit(s):
"""
Split a path given as a string into a list.
This is the inverse of os.path.join.
"""
s = s.strip('/\\')
head, tail = os.path.split(s)
path = [tail]
while head:
head, tail = os.path.split(head)
path.append(tail)

path.reverse()
return path


def subdirs(path):
""" Get the subdirectories of a specified directory """
for subdir in os.listdir(path):
dirpath = pjoin(path, subdir)
if os.path.isdir(dirpath):
yield subdir

def stripDrive(s):
"""
Remove a Windows drive letter specification from a path.
"""
if len(s) > 1 and s[1] == ':':
return s[2:]
else:
return s


def which(program):
""" Replicates the functionality of the 'which' shell command """
def is_exe(fpath):
Expand Down

0 comments on commit e0327a1

Please sign in to comment.