Skip to content
/ spack Public
forked from spack/spack

Commit

Permalink
Update remaining packages to use Stage.source_path (spack#11662)
Browse files Browse the repository at this point in the history
spack#11528 updated Stage to always store a Package's source in a fixed
directory accessible via `Stage.source_path` This left behind a
number of packages which were expecting to access the source code
via `Stage.path`. This Updates those packages to use
`Stage.source_path` instead.

This also updates the name of the fixed directory: The original name
of the fixed directory was "src", so if an expanded archive created a
"src" directory, then users inspecting the directory structure could
see paths like "src/src" (which wasn't wrong but could be confusing).
Therefore this also updates the name of the fixed directory to
"spack-src".
  • Loading branch information
tldahlgren authored and dev-zero committed Aug 13, 2019
1 parent 6386007 commit 2ce9e54
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 30 deletions.
2 changes: 1 addition & 1 deletion lib/spack/spack/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from spack.util.path import canonicalize_path
from spack.util.crypto import prefix_bits, bit_length

_source_path_subdir = 'src'
_source_path_subdir = 'spack-src'
_stage_prefix = 'spack-stage-'


Expand Down
4 changes: 2 additions & 2 deletions lib/spack/spack/test/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@
# to have the following structure:
#
# TMPDIR/ temp stage dir
# src/ well-known stage source directory
# spack-src/ well-known stage source directory
# _readme_fn Optional test_readme (contains _readme_contents)
# _hidden_fn Optional hidden file (contains _hidden_contents)
# _archive_fn archive_url = file:///path/to/_archive_fn
#
# while exploding tarball directories are expected to be structured as follows:
#
# TMPDIR/ temp stage dir
# src/ well-known stage source directory
# spack-src/ well-known stage source directory
# archive_name/ archive dir
# _readme_fn test_readme (contains _readme_contents)
# _extra_fn test_extra file (contains _extra_contents)
Expand Down
2 changes: 1 addition & 1 deletion var/spack/repos/builtin/packages/aspera-cli/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def setup_environment(self, spack_env, run_env):
run_env.prepend_path('PATH', self.prefix.cli.bin)

def install(self, spec, prefix):
runfile = glob(join_path(self.stage.path, 'aspera-cli*.sh'))[0]
runfile = glob(join_path(self.stage.source_path, 'aspera-cli*.sh'))[0]
# Update destination path
filter_file('INSTALL_DIR=~/.aspera',
'INSTALL_DIR=%s' % prefix,
Expand Down
34 changes: 24 additions & 10 deletions var/spack/repos/builtin/packages/bcl2fastq2/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from spack import *
import os
import shutil
import glob
import llnl.util.tty as tty

Expand Down Expand Up @@ -70,19 +69,34 @@ def do_stage(self, mirror_only=False):
def unpack_it(self, f):
def wrap():
f() # call the original expand_archive()

# The tarfile should now reside in the well-known source
# directory (i.e., self.stage.source_path).
with working_dir(self.stage.path):
if os.path.isdir('bcl2fastq'):
tty.msg("The tarball has already been unpacked")
else:
source_subdir = os.path.relpath(self.stage.source_path,
self.stage.path)
files = glob.glob(os.path.join(source_subdir,
'bcl2fastq2*.tar.gz'))
if len(files) == 1:
# Rename the tarball so it resides in self.stage.path
# alongside the original zip file before unpacking it.
tarball = files[0]
basename = os.path.basename(tarball)
os.rename(tarball, basename)
tty.msg("Unpacking bcl2fastq2 tarball")
tarball = glob.glob(join_path('spack-expanded-archive',
'bcl2fastq2*.tar.gz'))[0]
copy(tarball, '.')
shutil.rmtree('spack-expanded-archive')
tar = which('tar')
tarball = os.path.basename(tarball)
tar('-xf', tarball)
tar('-xf', basename)

# Rename the unpacked directory to the well-known
# source path self.stage.source_path.
os.rename('bcl2fastq', source_subdir)
tty.msg("Finished unpacking bcl2fastq2 tarball")

elif self.stage.expanded:
# The unpacked files already reside in the "well known"
# source directory (i.e., self.stage.source_path).
tty.msg("The tarball has already been unpacked.")

return wrap

def install(self, spec, prefix):
Expand Down
9 changes: 5 additions & 4 deletions var/spack/repos/builtin/packages/catalyst/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def do_stage(self, mirror_only=False):
super(Catalyst, self).do_stage(mirror_only)

# extract the catalyst part
paraview_dir = os.path.join(self.stage.path,
paraview_dir = os.path.join(self.stage.source_path,
'ParaView-v' + str(self.version))
catalyst_script = os.path.join(paraview_dir, 'Catalyst', 'catalyze.py')
editions_dir = os.path.join(paraview_dir, 'Catalyst', 'Editions')
Expand All @@ -135,10 +135,10 @@ def do_stage(self, mirror_only=False):
if not os.path.isdir(catalyst_source_dir):
os.mkdir(catalyst_source_dir)
subprocess.check_call(command)
tty.msg("Generated catalyst source in %s" % self.stage.path)
tty.msg("Generated catalyst source in %s" % self.stage.source_path)
else:
tty.msg("Already generated %s in %s" % (self.name,
self.stage.path))
self.stage.source_path))

def setup_environment(self, spack_env, run_env):
# paraview 5.5 and later
Expand Down Expand Up @@ -174,7 +174,8 @@ def root_cmakelists_dir(self):
:return: directory containing CMakeLists.txt
"""
return os.path.join(self.stage.path, 'Catalyst-v' + str(self.version))
return os.path.join(self.stage.source_path,
'Catalyst-v' + str(self.version))

@property
def build_directory(self):
Expand Down
2 changes: 1 addition & 1 deletion var/spack/repos/builtin/packages/charmpp/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,5 +241,5 @@ def install(self, spec, prefix):
@run_after('install')
@on_package_attributes(run_tests=True)
def check_build(self):
make('-C', join_path(self.stage.path, 'charm/tests'),
make('-C', join_path(self.stage.source_path, 'charm/tests'),
'test', parallel=False)
3 changes: 1 addition & 2 deletions var/spack/repos/builtin/packages/clhep/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ class Clhep(CMakePackage):
def patch(self):
filter_file('SET CMP0042 OLD',
'SET CMP0042 NEW',
'%s/%s/CLHEP/CMakeLists.txt'
% (self.stage.path, self.spec.version))
'%s/CLHEP/CMakeLists.txt' % self.stage.source_path)

def cmake_args(self):
cmake_args = ['-DCLHEP_BUILD_CXXSTD=-std=c++{0}'.format(
Expand Down
2 changes: 1 addition & 1 deletion var/spack/repos/builtin/packages/cuda/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def setup_environment(self, spack_env, run_env):
run_env.set('CUDA_HOME', self.prefix)

def install(self, spec, prefix):
runfile = glob(join_path(self.stage.path, 'cuda*_linux*'))[0]
runfile = glob(join_path(self.stage.source_path, 'cuda*_linux*'))[0]
chmod = which('chmod')
chmod('+x', runfile)
runfile = which(runfile)
Expand Down
2 changes: 1 addition & 1 deletion var/spack/repos/builtin/packages/lmod/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Lmod(AutotoolsPackage):

def setup_environment(self, spack_env, run_env):
stage_lua_path = join_path(
self.stage.path, 'Lmod-{version}', 'src', '?.lua')
self.stage.source_path, 'src', '?.lua')
spack_env.append_path('LUA_PATH', stage_lua_path.format(
version=self.version), separator=';')

Expand Down
2 changes: 1 addition & 1 deletion var/spack/repos/builtin/packages/nseg/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def prepare_source(self):
for key in self.resources:
for res in self.resources[key]:
res_name = res.name
res_path = join_path(res.fetcher.stage.path, res.name)
res_path = join_path(res.fetcher.stage.source_path, res.name)
copy(res_path, join_path(self.build_directory, res_name))

def install(self, spec, prefix):
Expand Down
14 changes: 8 additions & 6 deletions var/spack/repos/builtin/packages/singularity/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Singularity(MakefilePackage):
# tree into the proper subdir in our overridden do_stage below.
@property
def gopath(self):
return join_path(self.stage.path)
return self.stage.path

@property
def sylabs_gopath_dir(self):
Expand All @@ -52,13 +52,15 @@ def singularity_gopath_dir(self):
# its home within GOPATH.
def do_stage(self, mirror_only=False):
super(Singularity, self).do_stage(mirror_only)
source_path = self.stage.source_path
if not os.path.exists(self.singularity_gopath_dir):
# Move the expanded source to its destination
tty.debug("Moving {0} to {1}".format(
source_path, self.singularity_gopath_dir))
mkdirp(self.sylabs_gopath_dir)
shutil.move(source_path,
self.singularity_gopath_dir)
self.stage.source_path, self.singularity_gopath_dir))
shutil.move(self.stage.source_path, self.singularity_gopath_dir)

# The build process still needs access to the source path,
# so create a symlink.
force_symlink(self.singularity_gopath_dir, self.stage.source_path)

# MakefilePackage's stages use this via working_dir()
@property
Expand Down

0 comments on commit 2ce9e54

Please sign in to comment.