Patch Mathematica (#16019)

* Patch Mathematica

Mathematica installer moves all files and directories from installation directory to a backup one. The problem is that it also moves .spack to this backup location. Once it's done it does not move .spack back where it was.

My patch creates a copy of .spack to /tmp then moves it back right before exiting the install call.

* Make lint happy

* Use Spack native copy()

As suggested in peer-review let's:
- Copy .spack to stage directory so I don't have to use random
- Use Spack native copy() to do these operations

* Use join_path to create paths

As per peer-review suggestion:
- Use join_path to create paths
- Use copy_tree since we're copying a directory that could have sub-directories
This commit is contained in:
Antonio Arena 2020-04-13 21:22:29 +03:00 committed by GitHub
parent 0c28a271ae
commit 0a6d9f4c55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,6 +31,9 @@ class Mathematica(Package):
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'), self.stage)
sh = which('sh')
sh(self.stage.archive_file, '--', '-auto', '-verbose',
'-targetdir={0}'.format(prefix),
@ -43,3 +46,6 @@ def install(self, spec, prefix):
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, '.spack'), prefix)