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

Find externals/ compilers #108

Merged
merged 29 commits into from
Jun 16, 2023

Conversation

chapman39
Copy link
Collaborator

@chapman39 chapman39 commented Mar 17, 2023

  • Introduces 2 new arguments:
    • spack-compiler-paths: Space delimited string of paths for Spack to search for compilers (if spack_setup_environment is True)
    • spack-externals: Space delimited string of packages for Spack to search for externals (if spack_setup_environment is True)
  • If Uberenv cannot find a spack.yaml, it will automatically create one, search for compilers/ externals, and copy it over to package_source_dir.
  • Uberenv no longer stops if it cannot find a spack.yaml
  • Using argparse instead of optparse

Misc Notes:

  • I've found that hdf5-1.14.1-2 inconsistently works. It often gets a FetchError, which is why I try to build @1.14.0 in CI.

Fixes #105
Fixes #104

@chapman39 chapman39 self-assigned this Mar 17, 2023
@chapman39
Copy link
Collaborator Author

@white238 Was wondering about the workflow of --spack-create-environment (or maybe spack-setup-environment makes more sense?)

Were you thinking the user would run uberenv with --spack-setup-environment first, and uberenv would copy the spack.yaml over to a user-specified location (like `/scripts/spack/configs/)? And then later on you'd modify the spack.yaml and run uberenv again.

uberenv.py Outdated Show resolved Hide resolved
@@ -5,6 +5,7 @@
"spack_build_mode" : "install",
"spack_configs_path": "spack_configs",
"spack_packages_path": "packages",
"spack_not_buildable_packages": "cmake pkg-config zlib",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this name but can't come up with a better one right now. Let me ponder this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spack_packages_to_find ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spack_externals ?

@chapman39
Copy link
Collaborator Author

i've noticed spack compiler find finds way more compilers than users would probably want to find. unlike external find, you cant ask for a specific compiler to look for (e.g. gcc)-- as far as i know

[exe: /usr/WS2/meemee/uberenv/repo/.ci/test-project/uberenv_libs/spack/bin/spack -D /usr/WS2/meemee/uberenv/repo/.ci/test-project/uberenv_libs/spack_env compiler find]
==> Added 61 new compilers to /usr/WS2/meemee/uberenv/repo/.ci/test-project/uberenv_libs/spack_env/spack.yaml

@white238
Copy link
Member

i've noticed spack compiler find finds way more compilers than users would probably want to find. unlike external find, you cant ask for a specific compiler to look for (e.g. gcc)-- as far as i know

[exe: /usr/WS2/meemee/uberenv/repo/.ci/test-project/uberenv_libs/spack/bin/spack -D /usr/WS2/meemee/uberenv/repo/.ci/test-project/uberenv_libs/spack_env compiler find]
==> Added 61 new compilers to /usr/WS2/meemee/uberenv/repo/.ci/test-project/uberenv_libs/spack_env/spack.yaml

LC machines are very special that they have a million compilers. I don't think this is going to be true on most peoples machines.

But we might want to add how to specify a specific family, gcc vs clang

@cyrush
Copy link
Member

cyrush commented Apr 20, 2023

In the past when no config was given, uberenv would look for compilers and a user could ask for the family they wanted as part of the spec passed via command line args (--spec=clang,etc).

It would be good to know how to do that easily with the env setup.

@chapman39
Copy link
Collaborator Author

also, running plain spack compiler find on ruby doesn't even find the gcc versions we want. (it only found gcc@4.8.5)

the only way i could find the gcc compilers with compiler find is including the compiler path directly.

[meemee@ruby967:test-project]$ spack compiler find /usr/tce/packages/gcc/*
==> Added 7 new compilers to /usr/WS2/meemee/uberenv/repo/.ci/test-project/uberenv_libs/spack_env/spack.yaml
    gcc@10.2.1  gcc@9.3.1  gcc@8.3.1  gcc@8.1.0  gcc@7.3.0  gcc@7.1.0  gcc@6.1.0
==> Compilers are defined in the following files:
    /usr/WS2/meemee/uberenv/repo/.ci/test-project/uberenv_libs/spack_env/spack.yaml

@chapman39
Copy link
Collaborator Author

as far as i know spack compiler find doesn't have an option to search for a specific family
https://spack.readthedocs.io/en/latest/command_index.html#spack-compiler-find

@cyrush
Copy link
Member

cyrush commented Apr 20, 2023

correct, but there was still an easy path to select from what was found. Seems I restated Chris' suggestion. Just need to know how to select.

@white238
Copy link
Member

as far as i know spack compiler find doesn't have an option to search for a specific family https://spack.readthedocs.io/en/latest/command_index.html#spack-compiler-find

There is a way to tell it to search a different prefix. My guess is by default it only searches in /usr or /opt. For LC, it also needs to search in /usr/tce/packages.

@adrienbernede
Copy link
Member

adrienbernede commented Apr 21, 2023

We can pass a path to the find command, that’s correct.
Also, my main issue with spack compilers find is that it will not find certain compilers, you would have to load the appropriate module.

So, here is the work around I can suggest:
given a compiler family (gcc), or a compiler module name (gcc/8.3.1), look for the PATH prepend in the module files and use those paths to instruct spack where to find the compilers.

@adrienbernede
Copy link
Member

adrienbernede commented Apr 21, 2023

I guess since Spack is meant to install a full software stack on a machine from scratch, they can’t assume modules are already set.

I think we can make that assumption. It is true that this may not be portable to machines where modules are not set, but that could be tested by the script.

@chapman39
Copy link
Collaborator Author

I've been having trouble implementing spack_externals and spack_compiler_paths as a command line argument due to the fact that for some reason when I have spaces in the argument it only takes the first thing.

For example:
uberenv.py --spack-externals="cmake hdf5 zlib", will only take cmake.

I believe this could be fixed it we switched from OptParse (which has been deprecated since Python 3.2) to ArgParse.

Alternatively of course, we can delimit the argument without spaces (with ; or ,).

@white238
Copy link
Member

I've been having trouble implementing spack_externals and spack_compiler_paths as a command line argument due to the fact that for some reason when I have spaces in the argument it only takes the first thing.

For example: uberenv.py --spack-externals="cmake hdf5 zlib", will only take cmake.

I believe this could be fixed it we switched from OptParse (which has been deprecated since Python 3.2) to ArgParse.

Alternatively of course, we can delimit the argument without spaces (with ; or ,).

Please upgrade to argparse.

@chapman39
Copy link
Collaborator Author

chapman39 commented Apr 27, 2023

Also, thoughts on new variable names?

  • spack-compiler-paths: Space delimited string of paths for Spack to search for compilers (if spack_setup_environment is True)
  • spack-externals: Space delimited string of packages for Spack to search for externals (if spack_setup_environment is True)

@chapman39 chapman39 changed the title WIP: Find externals/ compilers Find externals/ compilers Apr 28, 2023
@chapman39 chapman39 added the enhancement New feature or request label Apr 28, 2023
Copy link
Member

@kennyweiss kennyweiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @chapman39 for this nice addition!

We should probably add some new CI tests to ensure this continues to work.

uberenv.py Outdated Show resolved Hide resolved
uberenv.py Outdated Show resolved Hide resolved
Comment on lines +913 to +916
if self.spack_compiler_paths is None:
spack_compiler_find_cmd = "{0} compiler find".format(self.spack_exe())
else:
spack_compiler_find_cmd = "{0} compiler find {1}".format(self.spack_exe(), self.spack_compiler_paths)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meta-question (outside the scope of this PR):

Should we have a spack_command(command, additional_args) function in uberenv?
That way, this line could be written as something like:

    spack_compiler_find_cmd = spack_command("compiler find", self.spack_compiler_paths)

uberenv.py Outdated Show resolved Hide resolved
@white238
Copy link
Member

white238 commented Jun 9, 2023

The documentation needs to be updated

@white238
Copy link
Member

white238 commented Jun 9, 2023

./scripts/uberenv/uberenv.py --prefix=../libs

produces the following error:

Traceback (most recent call last):
  File "/mnt/c/Users/white238/projects/serac/repo/./scripts/uberenv/uberenv.py", line 1380, in <module>
    sys.exit(main())
  File "/mnt/c/Users/white238/projects/serac/repo/./scripts/uberenv/uberenv.py", line 1319, in main
    env.setup_paths_and_dirs()
  File "/mnt/c/Users/white238/projects/serac/repo/./scripts/uberenv/uberenv.py", line 758, in setup_paths_and_dirs
    if self.spack_env_file is None:
AttributeError: 'SpackEnv' object has no attribute 'spack_env_file'. Did you mean: 'spack_env_name'?

@white238
Copy link
Member

@white238
Copy link
Member

Thanks @chapman39 !

@chapman39 chapman39 merged commit d934c61 into main Jun 16, 2023
@chapman39 chapman39 deleted the feature/chapman39/find_externals_and_compilers branch June 16, 2023 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to create a useful Spack environment via command line optparse -> argparse
5 participants