summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/mathematica/package.py
blob: 0334eda1bf7832a41f82bbe61f5dc9a409985254 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

import os

from spack import *


class Mathematica(Package):
    """Mathematica: high-powered computation with thousands of Wolfram Language
       functions, natural language input, real-world data, mobile support.

       Note: A manual download is required for Mathematica.
       Spack will search your current directory for the download file.
       Alternatively, add this file to a mirror so that Spack can find it.
       For instructions on how to set up a mirror, see
       http://spack.readthedocs.io/en/latest/mirrors.html"""

    homepage = "https://www.wolfram.com/mathematica/"
    url = 'file://{0}/Mathematica_12.0.0_LINUX.sh'.format(os.getcwd())
    manual_download = True

    version('12.2.0',
            sha256='3b6676a203c6adb7e9c418a5484b037974287b5be09c64e7dfea74ddc0e400d7',
            expand=False)
    version('12.1.1',
            sha256='ad47b886be4a9864d70f523f792615a051d4ebc987d9a0f654b645b4eb43b30a',
            expand=False)
    version('12.0.0',
            sha256='b9fb71e1afcc1d72c200196ffa434512d208fa2920e207878433f504e58ae9d7',
            expand=False)

    # Licensing
    license_required = True
    license_comment  = '#'
    license_files    = ['Configuration/Licensing/mathpass']
    license_url      = 'https://reference.wolfram.com/language/tutorial/RegistrationAndPasswords.html#857035062'

    def install(self, spec, prefix):
        # Backup .spack because Mathematica moves it but never restores it
        copy_tree(join_path(prefix, '.spack'),
                  join_path(self.stage.path, '.spack'))

        sh = which('sh')
        sh(self.stage.archive_file, '--', '-auto', '-verbose',
           '-targetdir={0}'.format(prefix),
           '-execdir={0}'.format(prefix.bin),
           '-selinux=y')
        # This is what most people would use on a cluster but the installer
        # does not symlink it
        ws_link_path = os.path.join(prefix.bin, 'wolframscript')
        if not os.path.exists(ws_link_path):
            ln = which('ln')
            ws_path = os.path.join(prefix, 'Executables', 'wolframscript')
            ln('-s', ws_path, ws_link_path)

        # Move back .spack where it belongs
        copy_tree(join_path(self.stage.path, '.spack'),
                  join_path(prefix, '.spack'))