Skip to content
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

Update numpy easyblock for numpy>=2.0 #3508

Open
jpecar opened this issue Nov 14, 2024 · 1 comment
Open

Update numpy easyblock for numpy>=2.0 #3508

jpecar opened this issue Nov 14, 2024 · 1 comment

Comments

@jpecar
Copy link

jpecar commented Nov 14, 2024

Current numpy easyblock is a child of fortranpythonpackage and this one wants to run "python setup.py build" to build it. Newer numpy comes without setup.py and seems to be using meson build system. Therefore numpy easyblock needs to be adapted.

Not sure how to even start here. Would adapted numpy easyblock need to become a child of mesonninja easyblock? Can import lines at the top be also selected by "if LooseVersion..." conditions? How would that then affect the rest of the code?

@Thyre
Copy link
Contributor

Thyre commented Nov 15, 2024

If we want to keep a single Python file, we could do something like with QuantumESPRESSO, where two separate EasyBlocks exist, which get selected from an EasyBlock wrapping both, see https://github.com/easybuilders/easybuild-easyblocks/blob/57c0eaed8dc29e223fe68a75f7bf195cca0c2d04/easybuild/easyblocks/q/quantumespresso.py

class EB_QuantumESPRESSO(EasyBlock):
    @staticmethod
    def extra_options():
        """Custom easyconfig parameters for Quantum ESPRESSO."""
        extra_opts = EB_QuantumESPRESSOconfig.extra_options()
        extra_opts.update(EB_QuantumESPRESSOcmake.extra_options())

        return extra_opts

    def __getattribute__(self, name):
        try:
            ebclass = object.__getattribute__(self, 'ebclass')
        except AttributeError:
            ebclass = None
        if name == 'ebclass':
            return ebclass
        if ebclass is None:
            return object.__getattribute__(self, name)
        return ebclass.__getattribute__(name)

    def __init__(self, ec, *args, **kwargs):
        """Select the correct EB depending on version."""
        super(EB_QuantumESPRESSO, self).__init__(ec, *args, **kwargs)

        if LooseVersion(self.version) < LooseVersion('7.3.1'):
            self.log.info('Using legacy easyblock for Quantum ESPRESSO')
            eb = EB_QuantumESPRESSOconfig
        else:
            self.log.info('Using CMake easyblock for Quantum ESPRESSO')
            eb = EB_QuantumESPRESSOcmake

        # Required to avoid CMakeMake default extra_opts to override the ConfigMake ones
        new_ec = EasyConfig(ec.path, extra_options=eb.extra_options())
        self.ebclass = eb(new_ec, *args, **kwargs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants