@@ -5,6 +5,7 @@ use std::str::FromStr;
55
66use bzip2:: read:: BzDecoder ;
77use flate2:: read:: GzDecoder ;
8+ use xz:: read:: XzDecoder ;
89use zip:: ZipArchive ;
910
1011use crate :: { Error , Metadata } ;
@@ -23,8 +24,10 @@ pub enum DistributionType {
2324#[ derive( Debug , Clone , Copy ) ]
2425enum SDistType {
2526 Zip ,
27+ Tar ,
2628 GzTar ,
2729 BzTar ,
30+ XzTar ,
2831}
2932
3033/// Python package distribution
@@ -51,8 +54,10 @@ impl FromStr for SDistType {
5154 fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
5255 let dist_type = match s {
5356 "zip" => SDistType :: Zip ,
57+ "tar" => SDistType :: Tar ,
5458 "gz" => SDistType :: GzTar ,
5559 "bz2" => SDistType :: BzTar ,
60+ "xz" => SDistType :: XzTar ,
5661 _ => return Err ( Error :: UnknownDistributionType ) ,
5762 } ;
5863 Ok ( dist_type)
@@ -65,7 +70,7 @@ impl Distribution {
6570 let path = path. as_ref ( ) ;
6671 if let Some ( ext) = path. extension ( ) . and_then ( |ext| ext. to_str ( ) ) {
6772 let dist_type = match ext {
68- "zip" | "gz" | "bz2" => DistributionType :: SDist ,
73+ "zip" | "tar" | " gz" | "bz2" | "xz " => DistributionType :: SDist ,
6974 "egg" => DistributionType :: Egg ,
7075 "whl" => DistributionType :: Wheel ,
7176 _ => return Err ( Error :: UnknownDistributionType ) ,
@@ -136,9 +141,13 @@ impl Distribution {
136141 SDistType :: GzTar => {
137142 Self :: parse_tar ( GzDecoder :: new ( BufReader :: new ( fs_err:: File :: open ( path) ?) ) )
138143 }
144+ SDistType :: Tar => Self :: parse_tar ( BufReader :: new ( fs_err:: File :: open ( path) ?) ) ,
139145 SDistType :: BzTar => {
140146 Self :: parse_tar ( BzDecoder :: new ( BufReader :: new ( fs_err:: File :: open ( path) ?) ) )
141147 }
148+ SDistType :: XzTar => {
149+ Self :: parse_tar ( XzDecoder :: new ( BufReader :: new ( fs_err:: File :: open ( path) ?) ) )
150+ }
142151 }
143152 }
144153
0 commit comments