forked from spack/spack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
encode development requirements in pyproject.toml (spack#32616)
Add a `project` block to the toml config along with development and CI dependencies and a minimal `build-system` block, doing basically nothing, so that spack can be bootstrapped to a full development environment with: ```shell $ hatch -e dev shell ``` or for a minimal environment without hatch: ```shell $ python3 -m venv venv $ source venv/bin/activate $ python3 -m pip install --upgrade pip $ python3 -m pip install -e '.[dev]' ``` This means we can re-use the requirements list throughout the workflow yaml files and otherwise maintain this list in *one place* rather than several disparate ones. We may be stuck with a couple more temporarily to continue supporting python2.7, but aside from that it's less places to get out of sync and a couple new bootstrap options. Co-authored-by: Adam J. Stewart <ajstewart426@gmail.com>
- Loading branch information
1 parent
f15356a
commit a58ecdb
Showing
5 changed files
with
145 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import os | ||
import sys | ||
from os.path import dirname as dn | ||
|
||
|
||
def main(argv=None): | ||
# Find spack's location and its prefix. | ||
this_file = os.path.realpath(os.path.expanduser(__file__)) | ||
spack_prefix = dn(dn(dn(dn(this_file)))) | ||
|
||
# Allow spack libs to be imported in our scripts | ||
spack_lib_path = os.path.join(spack_prefix, "lib", "spack") | ||
sys.path.insert(0, spack_lib_path) | ||
|
||
# Add external libs | ||
spack_external_libs = os.path.join(spack_lib_path, "external") | ||
|
||
if sys.version_info[:2] <= (2, 7): | ||
sys.path.insert(0, os.path.join(spack_external_libs, "py2")) | ||
|
||
sys.path.insert(0, spack_external_libs) | ||
# Here we delete ruamel.yaml in case it has been already imported from site | ||
# (see #9206 for a broader description of the issue). | ||
# | ||
# Briefly: ruamel.yaml produces a .pth file when installed with pip that | ||
# makes the site installed package the preferred one, even though sys.path | ||
# is modified to point to another version of ruamel.yaml. | ||
if "ruamel.yaml" in sys.modules: | ||
del sys.modules["ruamel.yaml"] | ||
|
||
if "ruamel" in sys.modules: | ||
del sys.modules["ruamel"] | ||
|
||
# The following code is here to avoid failures when updating | ||
# the develop version, due to spurious argparse.pyc files remaining | ||
# in the libs/spack/external directory, see: | ||
# https://github.com/spack/spack/pull/25376 | ||
# TODO: Remove in v0.18.0 or later | ||
try: | ||
import argparse # noqa: F401 | ||
except ImportError: | ||
argparse_pyc = os.path.join(spack_external_libs, "argparse.pyc") | ||
if not os.path.exists(argparse_pyc): | ||
raise | ||
try: | ||
os.remove(argparse_pyc) | ||
import argparse # noqa: F401 | ||
except Exception: | ||
msg = ( | ||
"The file\n\n\t{0}\n\nis corrupted and cannot be deleted by Spack. " | ||
"Either delete it manually or ask some administrator to " | ||
"delete it for you." | ||
) | ||
print(msg.format(argparse_pyc)) | ||
sys.exit(1) | ||
|
||
import spack.main # noqa: E402 | ||
|
||
sys.exit(spack.main.main(argv)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters