New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add easyblock for OCaml with support for extensions + generic OCamlPackage easyblock #467
Merged
Merged
Changes from 17 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
3238025
add easyblock for Xmlm OCaml library
boegel c780b05
add missing @author in Xmlm easyblock
boegel b584b5a
add easyblock for OCaml with support for extensions + generic OCamlPa…
boegel 3673721
Merge branch 'develop' into Xmlm
boegel 0d4d44f
use different $OPAMROOM for OCaml packages installed as extension, an…
boegel 425ec1f
Merge branch 'develop' into Xmlm
boegel 0ef4dc2
Merge branch 'develop' into Xmlm
boegel 53e8f0e
use 'opam list --installed' to check for *installed* OCaml packages (…
boegel c75c436
install OCaml packages using 'opam install'
boegel 7fea141
update $OCAMLPATH in OCamlPackage generic easyblock
boegel 08d604e
fix use of prepend_paths in OCamlPackage
boegel 9a63ebe
no stand-alone install of OCaml packages (for now)
boegel dcc1ced
move 'opam init' to prepare_for_extensions
boegel ac07f2d
fix sanity check for OCaml extensions
boegel d7adfaf
always source 'opam config env'
boegel f28b842
skip an 'opam init'
boegel 77c0b30
fix 'opam init --root'
boegel c6475b5
fix $PATH for OCaml + extensions
boegel File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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,49 @@ | ||
## | ||
# Copyright 2015-2015 Ghent University | ||
# | ||
# This file is part of EasyBuild, | ||
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en), | ||
# with support of Ghent University (http://ugent.be/hpc), | ||
# the Flemish Supercomputer Centre (VSC) (https://vscentrum.be/nl/en), | ||
# the Hercules foundation (http://www.herculesstichting.be/in_English) | ||
# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en). | ||
# | ||
# http://github.com/hpcugent/easybuild | ||
# | ||
# EasyBuild is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation v2. | ||
# | ||
# EasyBuild is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with EasyBuild. If not, see <http://www.gnu.org/licenses/>. | ||
## | ||
""" | ||
EasyBuild support for OCaml packages, implemented as an easyblock | ||
|
||
@author: Kenneth Hoste (Ghent University) | ||
""" | ||
from easybuild.framework.extensioneasyblock import ExtensionEasyBlock | ||
from easybuild.tools.build_log import EasyBuildError | ||
from easybuild.tools.run import run_cmd | ||
|
||
|
||
class OCamlPackage(ExtensionEasyBlock): | ||
"""Builds and installs OCaml packages using OPAM package manager.""" | ||
|
||
def configure_step(self): | ||
"""Raise error when configure step is run: installing OCaml packages stand-alone is not supported (yet)""" | ||
raise EasyBuildError("Installing OCaml packages stand-alone is not supported (yet)") | ||
|
||
def run(self): | ||
"""Perform OCaml package installation (as extension).""" | ||
# install using 'opam install' | ||
run_cmd("eval `opam config env` && opam install -yv %s.%s" % (self.name, self.version)) | ||
|
||
# 'opam pin add' fixes the version of the package | ||
# see https://opam.ocaml.org/doc/Usage.html#opampin | ||
run_cmd("eval `opam config env` && opam pin -yv add %s %s" % (self.name, self.version)) |
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,129 @@ | ||
## | ||
# Copyright 2015-2015 Ghent University | ||
# | ||
# This file is part of EasyBuild, | ||
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en), | ||
# with support of Ghent University (http://ugent.be/hpc), | ||
# the Flemish Supercomputer Centre (VSC) (https://vscentrum.be/nl/en), | ||
# the Hercules foundation (http://www.herculesstichting.be/in_English) | ||
# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en). | ||
# | ||
# http://github.com/hpcugent/easybuild | ||
# | ||
# EasyBuild is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation v2. | ||
# | ||
# EasyBuild is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with EasyBuild. If not, see <http://www.gnu.org/licenses/>. | ||
## | ||
""" | ||
EasyBuild support for building and installing OCaml + opam (+ extensions), implemented as an easyblock | ||
|
||
@author: Kenneth Hoste (Ghent University) | ||
""" | ||
import os | ||
|
||
import easybuild.tools.environment as env | ||
from easybuild.easyblocks.generic.configuremake import ConfigureMake | ||
from easybuild.tools.build_log import EasyBuildError | ||
from easybuild.tools.run import run_cmd | ||
|
||
|
||
EXTS_FILTER_OCAML_PACKAGES = ("eval `opam config env` && opam list --installed %(ext_name)s.%(ext_version)s", '') | ||
OPAM_SUBDIR = 'opam' | ||
|
||
|
||
class EB_OCaml(ConfigureMake): | ||
"""Support for building/installing OCaml + opam (+ additional extensions).""" | ||
|
||
def __init__(self, *args, **kwargs): | ||
"""Initialisation of custom class variables for OCaml.""" | ||
super(EB_OCaml, self).__init__(*args, **kwargs) | ||
self.with_opam = False | ||
|
||
def configure_step(self): | ||
"""Custom configuration procedure for OCaml.""" | ||
self.cfg['prefix_opt'] = '-prefix ' | ||
self.cfg.update('configopts', '-cc "%s %s"' % (os.environ['CC'], os.environ['CFLAGS'])) | ||
|
||
if not 'world.opt' in self.cfg['buildopts']: | ||
self.cfg.update('buildopts', 'world.opt') | ||
|
||
super(EB_OCaml, self).configure_step() | ||
|
||
def install_step(self): | ||
""" | ||
Custom install procedure for OCaml. | ||
First install OCaml using 'make install', then install OPAM (if sources are provided). | ||
""" | ||
super(EB_OCaml, self).install_step() | ||
|
||
fake_mod_data = self.load_fake_module(purge=True) | ||
|
||
try: | ||
all_dirs = os.listdir(self.builddir) | ||
except OSError, err: | ||
raise EasyBuildError("Failed to check contents of %s: %s", self.builddir, err) | ||
|
||
opam_dirs = [d for d in all_dirs if d.startswith('opam')] | ||
if len(opam_dirs) == 1: | ||
opam_dir = os.path.join(self.builddir, opam_dirs[0]) | ||
self.log.info("Found unpacked OPAM sources at %s, so installing it.", opam_dir) | ||
self.with_opam = True | ||
try: | ||
os.chdir(opam_dir) | ||
except OSError, err: | ||
raise EasyBuildError("Failed to move to %s: %s", opam_dir, err) | ||
|
||
run_cmd("./configure --prefix=%s" % self.installdir) | ||
run_cmd("make lib-ext") # locally build/install required dependencies | ||
run_cmd("make") | ||
run_cmd("make install") | ||
run_cmd("opam init --root %s" % os.path.join(self.installdir, OPAM_SUBDIR)) | ||
else: | ||
self.log.warning("OPAM sources not found in %s: %s", self.builddir, all_dirs) | ||
|
||
self.clean_up_fake_module(fake_mod_data) | ||
|
||
def prepare_for_extensions(self): | ||
"""Set default class and filter for OCaml packages.""" | ||
# build and install additional packages with OCamlPackage easyblock | ||
self.cfg['exts_defaultclass'] = "OCamlPackage" | ||
self.cfg['exts_filter'] = EXTS_FILTER_OCAML_PACKAGES | ||
super(EB_OCaml, self).prepare_for_extensions() | ||
|
||
def fetch_extension_sources(self): | ||
"""Don't fetch extension sources, OPAM takes care of that (and archiving too).""" | ||
return [{'name': ext_name, 'version': ext_version} for ext_name, ext_version in self.cfg['exts_list']] | ||
|
||
def sanity_check_step(self): | ||
"""Custom sanity check for OCaml.""" | ||
binaries = ['bin/ocaml', 'bin/ocamlc', 'bin/ocamlopt', 'bin/ocamlrun'] | ||
dirs = [] | ||
if self.with_opam: | ||
binaries.append('bin/opam') | ||
dirs.append(OPAM_SUBDIR) | ||
|
||
custom_paths = { | ||
'files': binaries, | ||
'dirs': dirs, | ||
} | ||
|
||
super(EB_OCaml, self).sanity_check_step(custom_paths=custom_paths) | ||
|
||
def make_module_req_guess(self): | ||
"""Custom extra paths/variables to define in generated module for OCaml.""" | ||
guesses = super(EB_OCaml, self).make_module_req_guess() | ||
|
||
guesses.update({ | ||
'CAML_LD_LIBRARY_PATH': ['lib'], | ||
'OPAMROOT': [OPAM_SUBDIR], | ||
}) | ||
|
||
return guesses |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OPAM
is the package manager?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, there's pretty much no other way to install OCaml packages (somewhat reliably)