Skip to content
Snippets Groups Projects
Commit d592a165 authored by Todd Gamblin's avatar Todd Gamblin
Browse files

Merge pull request #961 from xjrc/features/flake8-improvements

Enhancement Proposal: Exempt '@when' Functions from Style Redefinition Errors
parents 502420ce 761c5c84
No related branches found
No related tags found
No related merge requests found
...@@ -20,10 +20,18 @@ fi ...@@ -20,10 +20,18 @@ fi
# Check if changed files are flake8 conformant [framework] # Check if changed files are flake8 conformant [framework]
changed=$(git diff --name-only develop... | grep '.py$') changed=$(git diff --name-only develop... | grep '.py$')
# Exempt url lines in changed packages from overlong line errors. # Add approved style exemptions to the changed packages.
for file in $changed; do for file in $changed; do
if [[ $file = *package.py ]]; then if [[ $file = *package.py ]]; then
perl -i~ -pe 's/^(\s*url\s*=.*)$/\1 # NOQA: ignore=E501/' $file; cp "$file" "$file~"
# Exempt lines with urls and descriptions from overlong line errors.
perl -i -pe 's/^(\s*url\s*=.*)$/\1 # NOQA: ignore=E501/' $file
perl -i -pe 's/^(\s*version\(.*\).*)$/\1 # NOQA: ignore=E501/' $file
perl -i -pe 's/^(\s*variant\(.*\).*)$/\1 # NOQA: ignore=E501/' $file
# Exempt '@when' decorated functions from redefinition errors.
perl -i -pe 's/^(\s*\@when\(.*\).*)$/\1 # NOQA: ignore=F811/' $file
fi fi
done done
......
...@@ -22,8 +22,10 @@ ...@@ -22,8 +22,10 @@
# License along with this program; if not, write to the Free Software # License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
############################################################################## ##############################################################################
import os
import re
from spack import * from spack import *
import os, re
class Scotch(Package): class Scotch(Package):
"""Scotch is a software package for graph and mesh/hypergraph """Scotch is a software package for graph and mesh/hypergraph
...@@ -38,10 +40,10 @@ class Scotch(Package): ...@@ -38,10 +40,10 @@ class Scotch(Package):
version('6.0.0', 'c50d6187462ba801f9a82133ee666e8e') version('6.0.0', 'c50d6187462ba801f9a82133ee666e8e')
version('5.1.10b', 'f587201d6cf5cf63527182fbfba70753') version('5.1.10b', 'f587201d6cf5cf63527182fbfba70753')
variant('mpi', default=False, description='Activate the compilation of PT-Scotch') variant('mpi', default=False, description='Activate the compilation of parallel libraries')
variant('compression', default=True, description='Activate the posibility to use compressed files') variant('compression', default=True, description='Activate the posibility to use compressed files')
variant('esmumps', default=False, description='Activate the compilation of the lib esmumps needed by mumps') variant('esmumps', default=False, description='Activate the compilation of esmumps needed by mumps')
variant('shared', default=True, description='Build shared libraries') variant('shared', default=True, description='Build a shared version of the library')
depends_on('flex') depends_on('flex')
depends_on('bison') depends_on('bison')
...@@ -51,7 +53,7 @@ class Scotch(Package): ...@@ -51,7 +53,7 @@ class Scotch(Package):
# NOTE: Versions of Scotch up to version 6.0.0 don't include support for # NOTE: Versions of Scotch up to version 6.0.0 don't include support for
# building with 'esmumps' in their default packages. In order to enable # building with 'esmumps' in their default packages. In order to enable
# support for this feature, we must grab the 'esmumps' enabled archives # support for this feature, we must grab the 'esmumps' enabled archives
# from the Scotch hosting site. These alternative archives include a strict # from the Scotch hosting site. These alternative archives include a
# superset of the behavior in their default counterparts, so we choose to # superset of the behavior in their default counterparts, so we choose to
# always grab these versions for older Scotch versions for simplicity. # always grab these versions for older Scotch versions for simplicity.
@when('@:6.0.0') @when('@:6.0.0')
...@@ -62,32 +64,34 @@ def url_for_version(self, version): ...@@ -62,32 +64,34 @@ def url_for_version(self, version):
def url_for_version(self, version): def url_for_version(self, version):
return super(Scotch, self).url_for_version(version) return super(Scotch, self).url_for_version(version)
# NOTE: Several of the 'esmumps' enabled Scotch releases up to version 6.0.0 # NOTE: Several of the 'esmumps' enabled Scotch releases up to version
# have broken build scripts that don't properly build 'esmumps' as a separate # 6.0.0 have broken build scripts that don't properly build 'esmumps' as a
# target, so we need a patch procedure to remove 'esmumps' from existing targets # separate target, so we need a patch procedure to remove 'esmumps' from
# and to add it as a standalone target. # existing targets and to add it as a standalone target.
@when('@:6.0.0') @when('@:6.0.0')
def patch(self): def patch(self):
makefile_path = os.path.join('src', 'Makefile') makefile_path = os.path.join('src', 'Makefile')
with open(makefile_path, 'r') as makefile: with open(makefile_path, 'r') as makefile:
esmumps_enabled = any(re.search(r'^esmumps(\s*):(.*)$', line) for line in makefile.readlines()) esmumps_enabled = any(re.search(r'^esmumps(\s*):(.*)$', line)
for line in makefile.readlines())
if not esmumps_enabled: if not esmumps_enabled:
mff = FileFilter(makefile_path) mff = FileFilter(makefile_path)
mff.filter(r'^.*((esmumps)|(ptesmumps)).*(install).*$', '') mff.filter(r'^.*((esmumps)|(ptesmumps)).*(install).*$', '')
makefile_esmumps_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'Makefile.esmumps') mfesmumps_dir = os.path.dirname(os.path.realpath(__file__))
mfesmumps_path = os.path.join(mfesmumps_dir, 'Makefile.esmumps')
with open(makefile_path, 'a') as makefile: with open(makefile_path, 'a') as makefile:
makefile.write('\ninclude %s\n' % makefile_esmumps_path) makefile.write('\ninclude %s\n' % mfesmumps_path)
@when('@6.0.1:') @when('@6.0.1:')
def patch(self): def patch(self):
pass pass
# NOTE: Configuration of Scotch is achieved by writing a 'Makefile.inc' file # NOTE: Configuration of Scotch is achieved by writing a 'Makefile.inc'
# that contains all of the configuration variables and their desired values # file that contains all of the configuration variables and their desired
# for the installation. This function writes this file based on the given # values for the installation. This function writes this file based on
# installation variants. # the given installation variants.
def configure(self): def configure(self):
makefile_inc = [] makefile_inc = []
cflags = [ cflags = [
...@@ -96,9 +100,9 @@ def configure(self): ...@@ -96,9 +100,9 @@ def configure(self):
'-DSCOTCH_DETERMINISTIC', '-DSCOTCH_DETERMINISTIC',
'-DSCOTCH_RENAME', '-DSCOTCH_RENAME',
'-DIDXSIZE64' '-DIDXSIZE64'
] ]
## Library Build Type ## # Library Build Type #
if '+shared' in self.spec: if '+shared' in self.spec:
makefile_inc.extend([ makefile_inc.extend([
...@@ -107,7 +111,7 @@ def configure(self): ...@@ -107,7 +111,7 @@ def configure(self):
'RANLIB = echo', 'RANLIB = echo',
'AR = $(CC)', 'AR = $(CC)',
'ARFLAGS = -shared $(LDFLAGS) -o' 'ARFLAGS = -shared $(LDFLAGS) -o'
]) ])
cflags.append('-fPIC') cflags.append('-fPIC')
else: else:
makefile_inc.extend([ makefile_inc.extend([
...@@ -116,21 +120,21 @@ def configure(self): ...@@ -116,21 +120,21 @@ def configure(self):
'RANLIB = ranlib', 'RANLIB = ranlib',
'AR = ar', 'AR = ar',
'ARFLAGS = -ruv ' 'ARFLAGS = -ruv '
]) ])
## Compiler-Specific Options ## # Compiler-Specific Options #
if self.compiler.name == 'gcc': if self.compiler.name == 'gcc':
cflags.append('-Drestrict=__restrict') cflags.append('-Drestrict=__restrict')
elif self.compiler.name == 'intel': elif self.compiler.name == 'intel':
cflags.append('-restrict') cflags.append('-restrict')
mpicc_path = self.spec['mpi'].mpicc if '+mpi' in self.spec else 'mpicc'
makefile_inc.append('CCS = $(CC)') makefile_inc.append('CCS = $(CC)')
makefile_inc.append('CCP = %s' % makefile_inc.append('CCP = %s' % mpicc_path)
(self.spec['mpi'].mpicc if '+mpi' in self.spec else 'mpicc'))
makefile_inc.append('CCD = $(CCS)') makefile_inc.append('CCD = $(CCS)')
## Extra Features ## # Extra Features #
ldflags = [] ldflags = []
...@@ -143,8 +147,10 @@ def configure(self): ...@@ -143,8 +147,10 @@ def configure(self):
makefile_inc.append('LDFLAGS = %s' % ' '.join(ldflags)) makefile_inc.append('LDFLAGS = %s' % ' '.join(ldflags))
## General Features ## # General Features #
flex_path = os.path.join(self.spec['flex'].prefix.bin, 'flex')
bison_path = os.path.join(self.spec['bison'].prefix.bin, 'bison')
makefile_inc.extend([ makefile_inc.extend([
'EXE =', 'EXE =',
'OBJ = .o', 'OBJ = .o',
...@@ -155,10 +161,10 @@ def configure(self): ...@@ -155,10 +161,10 @@ def configure(self):
'MV = mv', 'MV = mv',
'CP = cp', 'CP = cp',
'CFLAGS = %s' % ' '.join(cflags), 'CFLAGS = %s' % ' '.join(cflags),
'LEX = %s -Pscotchyy -olex.yy.c' % os.path.join(self.spec['flex'].prefix.bin , 'flex'), 'LEX = %s -Pscotchyy -olex.yy.c' % flex_path,
'YACC = %s -pscotchyy -y -b y' % os.path.join(self.spec['bison'].prefix.bin, 'bison'), 'YACC = %s -pscotchyy -y -b y' % bison_path,
'prefix = %s' % self.prefix 'prefix = %s' % self.prefix
]) ])
with working_dir('src'): with working_dir('src'):
with open('Makefile.inc', 'w') as fh: with open('Makefile.inc', 'w') as fh:
...@@ -178,7 +184,7 @@ def install(self, spec, prefix): ...@@ -178,7 +184,7 @@ def install(self, spec, prefix):
with working_dir('src'): with working_dir('src'):
for target in targets: for target in targets:
make(target, parallel=(target!='ptesmumps')) make(target, parallel=(target != 'ptesmumps'))
install_tree('bin', prefix.bin) install_tree('bin', prefix.bin)
install_tree('lib', prefix.lib) install_tree('lib', prefix.lib)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment