@@ -31,6 +31,7 @@ use pixi_core::repodata::Repodata;
31
31
use pixi_manifest:: PrioritizedChannel ;
32
32
use pixi_progress:: global_multi_progress;
33
33
use pixi_reporters:: TopLevelProgress ;
34
+ use pixi_spec:: { BinarySpec , PathBinarySpec } ;
34
35
use pixi_spec_containers:: DependencyMap ;
35
36
use pixi_utils:: {
36
37
executable_from_path,
@@ -40,7 +41,7 @@ use pixi_utils::{
40
41
} ;
41
42
use rattler_conda_types:: {
42
43
ChannelConfig , GenericVirtualPackage , MatchSpec , PackageName , Platform , PrefixRecord ,
43
- menuinst:: MenuMode ,
44
+ menuinst:: MenuMode , package :: ArchiveIdentifier ,
44
45
} ;
45
46
use rattler_repodata_gateway:: Gateway ;
46
47
// Removed unused rattler_solve imports
@@ -120,7 +121,7 @@ pub struct Project {
120
121
/// The manifest for the project
121
122
pub manifest : Manifest ,
122
123
/// The global configuration as loaded from the config file(s)
123
- config : Config ,
124
+ pub config : Config ,
124
125
/// Root directory of the global environments
125
126
pub ( crate ) env_root : EnvRoot ,
126
127
/// Binary directory
@@ -303,7 +304,10 @@ impl Project {
303
304
. expect ( "manifest path should always have a parent" )
304
305
. to_owned ( ) ;
305
306
306
- let config = Config :: load ( & root) ;
307
+ // Load the global config and ensure
308
+ // that the root_dir is relative to the manifest directory
309
+ let mut config = Config :: load_global ( ) ;
310
+ config. channel_config . root_dir = root. clone ( ) ;
307
311
308
312
let client = OnceCell :: new ( ) ;
309
313
let repodata_gateway = OnceCell :: new ( ) ;
@@ -1361,26 +1365,18 @@ impl Project {
1361
1365
} )
1362
1366
}
1363
1367
1364
- /// Infer the package name from a PixiSpec (path or git) by examining build
1365
- /// outputs
1366
- pub async fn infer_package_name_from_spec (
1368
+ /// Infer the package name from a SourceSpec by examining build outputs
1369
+ async fn infer_package_name_from_source_spec (
1367
1370
& self ,
1368
- pixi_spec : & pixi_spec:: PixiSpec ,
1371
+ source_spec : pixi_spec:: SourceSpec ,
1369
1372
) -> Result < PackageName , InferPackageNameError > {
1370
- let pinned_source_spec = match pixi_spec. clone ( ) . into_source_or_binary ( ) {
1371
- Either :: Left ( source_spec) => {
1372
- let command_dispatcher = self . command_dispatcher ( ) ?;
1373
- let checkout = command_dispatcher
1374
- . pin_and_checkout ( source_spec)
1375
- . await
1376
- . map_err ( |e| InferPackageNameError :: BuildBackendMetadata ( Box :: new ( e) ) ) ?;
1373
+ let command_dispatcher = self . command_dispatcher ( ) ?;
1374
+ let checkout = command_dispatcher
1375
+ . pin_and_checkout ( source_spec)
1376
+ . await
1377
+ . map_err ( |e| InferPackageNameError :: BuildBackendMetadata ( Box :: new ( e) ) ) ?;
1377
1378
1378
- checkout. pinned
1379
- }
1380
- Either :: Right ( _) => {
1381
- return Err ( InferPackageNameError :: UnsupportedSpecType ) ;
1382
- }
1383
- } ;
1379
+ let pinned_source_spec = checkout. pinned ;
1384
1380
1385
1381
// Create the metadata spec
1386
1382
let metadata_spec = BuildBackendMetadataSpec {
@@ -1422,6 +1418,27 @@ impl Project {
1422
1418
}
1423
1419
}
1424
1420
}
1421
+
1422
+ /// Infer the package name from a PixiSpec (path or git) by examining build
1423
+ /// outputs
1424
+ pub async fn infer_package_name_from_spec (
1425
+ & self ,
1426
+ pixi_spec : & pixi_spec:: PixiSpec ,
1427
+ ) -> Result < PackageName , InferPackageNameError > {
1428
+ match pixi_spec. clone ( ) . into_source_or_binary ( ) {
1429
+ Either :: Left ( source_spec) => {
1430
+ self . infer_package_name_from_source_spec ( source_spec) . await
1431
+ }
1432
+ Either :: Right ( binary_spec) => match binary_spec {
1433
+ BinarySpec :: Path ( PathBinarySpec { path } ) => path
1434
+ . file_name ( )
1435
+ . and_then ( ArchiveIdentifier :: try_from_filename)
1436
+ . and_then ( |iden| PackageName :: from_str ( & iden. name ) . ok ( ) )
1437
+ . ok_or ( InferPackageNameError :: UnsupportedSpecType ) ,
1438
+ _ => Err ( InferPackageNameError :: UnsupportedSpecType ) ,
1439
+ } ,
1440
+ }
1441
+ }
1425
1442
}
1426
1443
1427
1444
impl Repodata for Project {
0 commit comments