Skip to content

Commit

Permalink
Merge pull request easybuilders#3381 from PetrKralCZ/20240704125705_n…
Browse files Browse the repository at this point in the history
…ew_pr_rubygem

Add support for generating `.gem` files from `.gemspec` files and support for `preinstallopts` in the RubyGem easyblock
  • Loading branch information
boegel authored Jul 5, 2024
2 parents 36af558 + 1009921 commit bb86f05
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions easybuild/easyblocks/generic/rubygem.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def run(self):

def extract_step(self):
"""Skip extraction of .gem files, which are installed as downloaded"""

if len(self.src) > 1:
raise EasyBuildError("Don't know how to handle Ruby gems with multiple sources.")
else:
Expand All @@ -83,20 +82,35 @@ def extract_step(self):
# unpack zipped gems, use specified path to gem file
super(RubyGem, self).extract_step()

if self.cfg['gem_file']:
self.ext_src = os.path.join(src['finalpath'], self.cfg['gem_file'])
if not os.path.exists(self.ext_src):
raise EasyBuildError("Gem file not found at %s", self.ext_src)
else:
raise EasyBuildError("Location to gem file in unpacked sources must be specified via gem_file")

def configure_step(self):
"""No separate configuration for Ruby Gems."""
pass

def build_step(self):
"""No separate build procedure for Ruby Gems."""
pass
src = self.src[0]
if self.cfg['gem_file']:
self.ext_src = os.path.join(src['finalpath'], self.cfg['gem_file'])
if not os.path.exists(self.ext_src):
raise EasyBuildError("Gem file not found at %s", self.ext_src)
else:
gemfile = "%s.gem" % self.name
gemfile_lower = "%s.gem" % self.name.lower()
if os.path.exists(gemfile):
self.ext_src = os.path.join(src['finalpath'], gemfile)
elif os.path.exists(gemfile_lower):
self.ext_src = os.path.join(src['finalpath'], gemfile_lower)
else:
gemspec = "%s.gemspec" % self.name
gemspec_lower = "%s.gemspec" % self.name.lower()
if os.path.exists(gemspec):
run_cmd("gem build %s -o %s.gem" % (gemspec, self.name))
self.ext_src = "%s.gem" % self.name
elif os.path.exists(gemspec_lower):
run_cmd("gem build %s -o %s.gem" % (gemspec_lower, self.name.lower()))
self.ext_src = "%s.gem" % self.name.lower()
else:
raise EasyBuildError("No gem_file specified and no"
" %s.gemspec or %s.gemspec found." % (self.name, self.name.lower()))

def test_step(self):
"""No separate (standard) test procedure for Ruby Gems."""
Expand All @@ -113,7 +127,8 @@ def install_step(self):
env.setvar('GEM_HOME', self.installdir)

bindir = os.path.join(self.installdir, 'bin')
run_cmd("gem install --bindir %s --local %s" % (bindir, self.ext_src))
cmd = "%s gem install --bindir %s --local %s" % (self.cfg['preinstallopts'], bindir, self.ext_src)
run_cmd(cmd)

def make_module_extra(self):
"""Extend $GEM_PATH in module file."""
Expand Down

0 comments on commit bb86f05

Please sign in to comment.