@@ -94,7 +94,7 @@ def ensure_conan_app():
9494 """Ensure Conan is installed."""
9595 if not (res := shutil .which ("conan" )):
9696 fail ("Conan not found!" )
97- return res
97+ return Path ( res )
9898
9999
100100def run_conan (
@@ -103,22 +103,15 @@ def run_conan(
103103):
104104 """Run conan statement."""
105105 conan_app = ensure_conan_app ()
106- if "env" not in kwargs :
107- kwargs ["env" ] = CONAN_ENV
108- else :
109- kwargs ["env" ].update (CONAN_ENV )
110- kwargs ["env" ].update (os .environ )
111- kwargs ["text" ] = kwargs .get (
112- "text" ,
113- True ,
114- )
106+ kwargs ["env" ] = os .environ .update (CONAN_ENV )
107+ kwargs ["text" ] = kwargs .get ("text" , True )
115108 args = [conan_app ] + args
116109 logger .debug (args )
117110 res = subprocess .run (
118111 args ,
119112 shell = False ,
120113 check = False ,
121- ** kwargs ,
114+ ** kwargs
122115 )
123116 if res .returncode :
124117 fail ("Error while executing conan:\n %s\n %s" , res .stdout , res .stderr )
@@ -260,7 +253,6 @@ def install(
260253
261254def conan_home ():
262255 """Get Conan home path."""
263- conan_app = ensure_conan_app ()
264256 res = run_conan (
265257 ["config" , "home" ],
266258 capture_output = True ,
@@ -288,13 +280,9 @@ def copy_global_conf(
288280 )
289281
290282
291- def set_global_conf (
292- cache_dir ,
293- ):
283+ def set_global_conf (cache_dir ):
294284 """Set global.conf file."""
295- home = Path (CONAN_ENV ["CONAN_HOME" ])
296- home .mkdir (parents = True , exist_ok = True )
297- global_conf = home / "global.conf"
285+ global_conf = conan_home () / "global.conf"
298286 global_conf .touch ()
299287
300288 logger .info ("Writing configuration file: '%s'" , str (global_conf ))
@@ -388,12 +376,18 @@ def main(
388376 # Check requirements
389377 check_requirements ()
390378
379+ # Workaround: in Windows, conan home and deployment cannot be in
380+ # different drives...
381+ preset_dir = output_dir .absolute () if os .name == "nt" else None
382+ output_dir .mkdir (parents = True , exist_ok = True )
383+
391384 # Process
392- with tempfile .TemporaryDirectory () as tmpdir :
385+ with tempfile .TemporaryDirectory (dir = preset_dir ) as tmpdir :
393386
394387 tmpdir = Path (tmpdir )
395388
396389 _conan_home = tmpdir / ".conan2"
390+ _conan_home .mkdir (parents = True , exist_ok = True )
397391
398392 CONAN_ENV .update (
399393 {
@@ -403,10 +397,11 @@ def main(
403397 "BUILD_TYPE" : "Release" ,
404398 }
405399 )
400+ os .putenv ("CONAN_HOME" , str (_conan_home ))
406401 del _conan_home
407402
408403 logger_step ("Checking conan home" )
409- logger .info ("Conan home is %s" , str (conan_home ()))
404+ logger .info ("Temporary conan home is %s" , str (conan_home ()))
410405
411406 # Set global.conf
412407 logger_step ("Setting conan configuration" )
0 commit comments