Last active
October 4, 2021 17:59
-
-
Save xylar/a506a16a474788b27e17f350eef547f8 to your computer and use it in GitHub Desktop.
A hacky script for using mamba to determin the first conda package that leads to an unsolvable environment
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
#!/usr/bin/env python | |
import subprocess | |
import os | |
subdir = 'osx-64' | |
specs = ['python=3.9.*', | |
'setuptools', | |
'cython', | |
'libcdms', | |
'numpy=1.19.*', | |
'libnetcdf=4.8.1.*=nompi_*', | |
'cdat_info', | |
'libdrs_f', | |
'jasper=1.*'] | |
base_command = ['mamba', 'create', '-y', '-n', 'test', '--dry-run'] | |
prevEnd = None | |
highestValid = -1 | |
lowestInvalid = len(specs) | |
endIndex = len(specs) | |
while highestValid != lowestInvalid-1: | |
subset_specs = specs[0:endIndex] | |
print('last: {}'.format(subset_specs[-1])) | |
command = base_command + subset_specs | |
try: | |
env = dict(os.environ) | |
env['CONDA_SUBDIR'] = subdir | |
subprocess.check_call(command, stdout=subprocess.DEVNULL, env=env) | |
highestValid = endIndex-1 | |
endIndex = int(0.5 + 0.5*(highestValid + lowestInvalid)) + 1 | |
print(' Succeeded!') | |
except subprocess.CalledProcessError: | |
lowestInvalid = endIndex-1 | |
endIndex = int(0.5 + 0.5*(highestValid + lowestInvalid)) + 1 | |
print(' Failed!') | |
print(' valid: {}, invalid: {}, end: {}'.format( | |
highestValid, lowestInvalid, endIndex)) | |
if lowestInvalid == len(specs): | |
print('No failures!') | |
else: | |
print('First failing package: {}'.format(specs[lowestInvalid])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment