@@ -65,25 +65,40 @@ def get_module_sources(parsed_lockfile: dict, include_devel: bool = True) -> lis
6565 for section , packages in parsed_lockfile .items ():
6666 if section == "package" :
6767 for package in packages :
68- # Check for old metadata format (poetry version < 1.0.0b2)
69- if "hashes" in parsed_lockfile ["metadata" ]:
70- hashes = parsed_lockfile ["metadata" ]["hashes" ][package ["name" ]]
71- # Else new metadata format
72- else :
73- hashes = []
74- for package_name in parsed_lockfile ["metadata" ]["files" ]:
75- if package_name == package ["name" ]:
76- package_files = parsed_lockfile ["metadata" ]["files" ][
77- package ["name" ]
78- ]
79- num_files = len (package_files )
80- for num in range (num_files ):
81- match = hash_re .search (package_files [num ]["hash" ])
82- if match :
83- hashes .append (match .group (2 ))
84- url , hash = get_pypi_source (package ["name" ], package ["version" ], hashes )
85- source = {"type" : "file" , "url" : url , "sha256" : hash }
86- sources .append (source )
68+ if (
69+ package .get ("category" ) == "dev"
70+ and include_devel
71+ and not package ["optional" ]
72+ or package .get ("category" ) == "main"
73+ and not package ["optional" ]
74+ ):
75+ # Check for old metadata format (poetry version < 1.0.0b2)
76+ if "hashes" in parsed_lockfile ["metadata" ]:
77+ hashes = parsed_lockfile ["metadata" ]["hashes" ][package ["name" ]]
78+ # Else new metadata format
79+ else :
80+ hashes = []
81+ for package_name in parsed_lockfile ["metadata" ]["files" ]:
82+ if package_name == package ["name" ]:
83+ package_files = parsed_lockfile ["metadata" ]["files" ][
84+ package ["name" ]
85+ ]
86+ num_files = len (package_files )
87+ for num in range (num_files ):
88+ match = hash_re .search (package_files [num ]["hash" ])
89+ if match :
90+ hashes .append (match .group (2 ))
91+ package_source = package .get ("source" )
92+ if package_source and package_source ["type" ] == "directory" :
93+ print (
94+ f'Skipping download url and hash extraction for { package ["name" ]} , source type is directory'
95+ )
96+ continue
97+ url , hash = get_pypi_source (
98+ package ["name" ], package ["version" ], hashes
99+ )
100+ source = {"type" : "file" , "url" : url , "sha256" : hash }
101+ sources .append (source )
87102 return sources
88103
89104
@@ -101,7 +116,14 @@ def get_dep_names(parsed_lockfile: dict, include_devel: bool = True) -> list:
101116 for section , packages in parsed_lockfile .items ():
102117 if section == "package" :
103118 for package in packages :
104- dep_names .append (package ["name" ])
119+ if (
120+ package .get ("category" ) == "dev"
121+ and include_devel
122+ and not package ["optional" ]
123+ or package .get ("category" ) == "main"
124+ and not package ["optional" ]
125+ ):
126+ dep_names .append (package ["name" ])
105127 return dep_names
106128
107129
@@ -126,7 +148,6 @@ def main():
126148 pip_command = [
127149 "pip3" ,
128150 "install" ,
129- "--use-pep517" ,
130151 "--no-index" ,
131152 '--find-links="file://${PWD}"' ,
132153 "--prefix=${FLATPAK_DEST}" ,
0 commit comments