Skip to content

Commit

Permalink
Fix behavior and checks for unspecified source files
Browse files Browse the repository at this point in the history
* Resolves conda#231, reviewing and extending the logic for supporting .yaml extension (conda#99).
  • Loading branch information
riccardoporreca committed Aug 10, 2022
1 parent 7d9bd6d commit 3318dd4
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions conda_lock/conda_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,9 +939,18 @@ def run_lock(
file=sys.stderr,
)
else:
long_ext_file = pathlib.Path("environment.yaml")
if long_ext_file.exists() and not environment_files[0].exists():
environment_files = [long_ext_file]
# bail out if we do not encounter any default .y(a)ml files
candidates = [
p if p.exists() else p.with_suffix(".yaml") for p in DEFAULT_FILES
]
environment_files = [p for p in candidates if p.exists()]
if len(environment_files) == 0:
print(
f"No files exist matching the defaults"
f" ({[str(p.with_suffix('.y(a)ml')) for p in DEFAULT_FILES]}).",
file=sys.stderr,
)
sys.exit(1)

_conda_exe = determine_conda_executable(
conda_exe, mamba=mamba, micromamba=micromamba
Expand Down Expand Up @@ -1131,17 +1140,6 @@ def lock(
if pypi_to_conda_lookup_file:
set_lookup_location(pypi_to_conda_lookup_file)

# bail out if we do not encounter the default file if no files were passed
if ctx.get_parameter_source("files") == click.core.ParameterSource.DEFAULT:
candidates = list(files)
candidates += [f.with_name(f.name.replace(".yml", ".yaml")) for f in candidates]
for f in candidates:
if f.exists():
break
else:
print(ctx.get_help())
sys.exit(1)

if pdb:
sys.excepthook = _handle_exception_post_mortem

Expand Down

0 comments on commit 3318dd4

Please sign in to comment.