9
9
import os
10
10
import shutil
11
11
import tarfile
12
+ import tempfile
13
+ from pathlib import Path
12
14
13
15
import yaml
14
16
from django .conf import settings
@@ -689,9 +691,12 @@ def setup_base(self):
689
691
if self .project .has_feature (Feature .UPDATE_CONDA_STARTUP ):
690
692
self ._update_conda_startup ()
691
693
694
+ conda_env_file = self .config .conda .environment
692
695
if self .project .has_feature (Feature .CONDA_APPEND_CORE_REQUIREMENTS ):
693
- self ._append_core_requirements ()
694
- self ._show_environment_yaml ()
696
+ conda_env_file = self ._append_core_requirements ()
697
+ log .warning ("Exists: %s" , Path (conda_env_file ).exists ())
698
+ self ._show_environment_yaml (conda_env_file )
699
+ log .warning (self .config )
695
700
696
701
if all ([
697
702
# The project has CONDA_USES_MAMBA feature enabled and,
@@ -710,16 +715,17 @@ def setup_base(self):
710
715
'--name' ,
711
716
self .version .slug ,
712
717
'--file' ,
713
- self . config . conda . environment ,
718
+ conda_env_file ,
714
719
bin_path = None , # Don't use conda bin that doesn't exist yet
715
720
cwd = self .checkout_path ,
716
721
)
717
722
718
- def _show_environment_yaml (self ):
723
+ def _show_environment_yaml (self , conda_env_file = None ):
719
724
"""Show ``environment.yml`` file in the Build output."""
725
+ conda_env_file = conda_env_file or self .config .conda .environment
720
726
self .build_env .run (
721
727
'cat' ,
722
- self . config . conda . environment ,
728
+ conda_env_file ,
723
729
cwd = self .checkout_path ,
724
730
)
725
731
@@ -767,16 +773,16 @@ def _append_core_requirements(self):
767
773
dependencies .append (pip_dependencies )
768
774
dependencies .extend (conda_requirements )
769
775
environment .update ({'dependencies' : dependencies })
776
+ _ , output_filename = tempfile .mkstemp (dir = Path (self .checkout_path ) / ".." / ".." , suffix = ".yml" )
770
777
try :
771
778
outputfile = codecs .open (
772
- os .path .join (
773
- self .checkout_path ,
774
- self .config .conda .environment ,
775
- ),
779
+ output_filename ,
776
780
encoding = 'utf-8' ,
777
781
mode = 'w' ,
778
782
)
779
783
yaml .safe_dump (environment , outputfile )
784
+
785
+ return output_filename
780
786
except IOError :
781
787
log .warning (
782
788
'There was an error while writing the new Conda '
0 commit comments