build_environment : fixed minor spelling errors and a few style issues
This commit is contained in:
parent
f40c78a064
commit
1d70b590fc
1 changed files with 18 additions and 19 deletions
|
@ -3,7 +3,7 @@
|
||||||
build environment. All of this is set up by package.py just before
|
build environment. All of this is set up by package.py just before
|
||||||
install() is called.
|
install() is called.
|
||||||
|
|
||||||
There are two parts to the bulid environment:
|
There are two parts to the build environment:
|
||||||
|
|
||||||
1. Python build environment (i.e. install() method)
|
1. Python build environment (i.e. install() method)
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
the package's module scope. Ths allows package writers to call
|
the package's module scope. Ths allows package writers to call
|
||||||
them all directly in Package.install() without writing 'self.'
|
them all directly in Package.install() without writing 'self.'
|
||||||
everywhere. No, this isn't Pythonic. Yes, it makes the code more
|
everywhere. No, this isn't Pythonic. Yes, it makes the code more
|
||||||
readable and more like the shell script from whcih someone is
|
readable and more like the shell script from which someone is
|
||||||
likely porting.
|
likely porting.
|
||||||
|
|
||||||
2. Build execution environment
|
2. Build execution environment
|
||||||
|
@ -27,17 +27,16 @@
|
||||||
Skimming this module is a nice way to get acquainted with the types of
|
Skimming this module is a nice way to get acquainted with the types of
|
||||||
calls you can make from within the install() function.
|
calls you can make from within the install() function.
|
||||||
"""
|
"""
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import shutil
|
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
import os
|
||||||
import platform
|
import platform
|
||||||
from llnl.util.filesystem import *
|
import shutil
|
||||||
|
import sys
|
||||||
|
|
||||||
import spack
|
import spack
|
||||||
import spack.compilers as compilers
|
from llnl.util.filesystem import *
|
||||||
from spack.util.executable import Executable, which
|
|
||||||
from spack.util.environment import *
|
from spack.util.environment import *
|
||||||
|
from spack.util.executable import Executable, which
|
||||||
|
|
||||||
#
|
#
|
||||||
# This can be set by the user to globally disable parallel builds.
|
# This can be set by the user to globally disable parallel builds.
|
||||||
|
@ -111,14 +110,15 @@ def set_compiler_environment_variables(pkg):
|
||||||
|
|
||||||
|
|
||||||
def set_build_environment_variables(pkg):
|
def set_build_environment_variables(pkg):
|
||||||
"""This ensures a clean install environment when we build packages.
|
"""
|
||||||
|
This ensures a clean install environment when we build packages
|
||||||
"""
|
"""
|
||||||
# Add spack build environment path with compiler wrappers first in
|
# Add spack build environment path with compiler wrappers first in
|
||||||
# the path. We add both spack.env_path, which includes default
|
# the path. We add both spack.env_path, which includes default
|
||||||
# wrappers (cc, c++, f77, f90), AND a subdirectory containing
|
# wrappers (cc, c++, f77, f90), AND a subdirectory containing
|
||||||
# compiler-specific symlinks. The latter ensures that builds that
|
# compiler-specific symlinks. The latter ensures that builds that
|
||||||
# are sensitive to the *name* of the compiler see the right name
|
# are sensitive to the *name* of the compiler see the right name
|
||||||
# when we're building wtih the wrappers.
|
# when we're building with the wrappers.
|
||||||
#
|
#
|
||||||
# Conflicts on case-insensitive systems (like "CC" and "cc") are
|
# Conflicts on case-insensitive systems (like "CC" and "cc") are
|
||||||
# handled by putting one in the <build_env_path>/case-insensitive
|
# handled by putting one in the <build_env_path>/case-insensitive
|
||||||
|
@ -296,23 +296,23 @@ def child_fun():
|
||||||
# do stuff
|
# do stuff
|
||||||
build_env.fork(pkg, child_fun)
|
build_env.fork(pkg, child_fun)
|
||||||
|
|
||||||
Forked processes are run with the build environemnt set up by
|
Forked processes are run with the build environment set up by
|
||||||
spack.build_environment. This allows package authors to have
|
spack.build_environment. This allows package authors to have
|
||||||
full control over the environment, etc. without offecting
|
full control over the environment, etc. without affecting
|
||||||
other builds that might be executed in the same spack call.
|
other builds that might be executed in the same spack call.
|
||||||
|
|
||||||
If something goes wrong, the child process is expected toprint
|
If something goes wrong, the child process is expected to print
|
||||||
the error and the parent process will exit with error as
|
the error and the parent process will exit with error as
|
||||||
well. If things go well, the child exits and the parent
|
well. If things go well, the child exits and the parent
|
||||||
carries on.
|
carries on.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
pid = os.fork()
|
pid = os.fork()
|
||||||
except OSError, e:
|
except OSError as e:
|
||||||
raise InstallError("Unable to fork build process: %s" % e)
|
raise InstallError("Unable to fork build process: %s" % e)
|
||||||
|
|
||||||
if pid == 0:
|
if pid == 0:
|
||||||
# Give the child process the package's build environemnt.
|
# Give the child process the package's build environment.
|
||||||
setup_package(pkg)
|
setup_package(pkg)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -323,7 +323,7 @@ def child_fun():
|
||||||
# which interferes with unit tests.
|
# which interferes with unit tests.
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
|
|
||||||
except spack.error.SpackError, e:
|
except spack.error.SpackError as e:
|
||||||
e.die()
|
e.die()
|
||||||
|
|
||||||
except:
|
except:
|
||||||
|
@ -338,8 +338,7 @@ def child_fun():
|
||||||
# message. Just make the parent exit with an error code.
|
# message. Just make the parent exit with an error code.
|
||||||
pid, returncode = os.waitpid(pid, 0)
|
pid, returncode = os.waitpid(pid, 0)
|
||||||
if returncode != 0:
|
if returncode != 0:
|
||||||
raise InstallError("Installation process had nonzero exit code."
|
raise InstallError("Installation process had nonzero exit code.".format(str(returncode)))
|
||||||
.format(str(returncode)))
|
|
||||||
|
|
||||||
|
|
||||||
class InstallError(spack.error.SpackError):
|
class InstallError(spack.error.SpackError):
|
||||||
|
|
Loading…
Reference in a new issue