Skip to content

Commit 5c607ca

Browse files
committed
Seamless transition in develop if argparse.pyc is in external
1 parent 7aae78d commit 5c607ca

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

bin/spack

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ exit 1
2828
from __future__ import print_function
2929

3030
import os
31+
import os.path
3132
import sys
3233

3334
min_python3 = (3, 5)
@@ -70,6 +71,21 @@ if "ruamel.yaml" in sys.modules:
7071
if "ruamel" in sys.modules:
7172
del sys.modules["ruamel"]
7273

74+
# The following code is here to avoid failures when updating
75+
# the develop version, due to spurious argparse.pyc files remaining
76+
# in the libs/spack/external directory, see:
77+
# https://github.com/spack/spack/pull/25376
78+
# TODO: Remove in v0.18.0 or later
79+
try:
80+
import argparse
81+
except ImportError:
82+
argparse_pyc = os.path.join(spack_external_libs, 'argparse.pyc')
83+
if not os.path.exists(argparse_pyc):
84+
raise
85+
os.remove(argparse_pyc)
86+
import argparse # noqa
87+
88+
7389
import spack.main # noqa
7490

7591
# Once we've set up the system path, run the spack main method

0 commit comments

Comments
 (0)