@@ -47,6 +47,8 @@ public class RequirementsTxtParser implements Parser {
4747 "requirements(-[\\ w-]+)?\\ .(txt|in)"
4848 );
4949
50+ private static final Pattern EXTRA_MARKER_PATTERN = Pattern .compile ("\\ bextra\\ s*==" );
51+
5052 private final PlainTextParser plainTextParser = new PlainTextParser ();
5153
5254 @ Override
@@ -192,6 +194,12 @@ static List<ResolvedDependency> linkDependenciesFromMetadata(List<ResolvedDepend
192194 }
193195
194196 private static @ Nullable Path findSitePackages (Path workspace ) {
197+ // Windows: .venv/Lib/site-packages (no python* subdirectory)
198+ Path windowsSitePackages = workspace .resolve (".venv/Lib/site-packages" );
199+ if (Files .isDirectory (windowsSitePackages )) {
200+ return windowsSitePackages ;
201+ }
202+ // Unix: .venv/lib/python*/site-packages
195203 Path lib = workspace .resolve (".venv/lib" );
196204 if (!Files .isDirectory (lib )) {
197205 return null ;
@@ -235,20 +243,20 @@ private static List<String> readRequiresDist(Path sitePackages, String packageNa
235243 if (Files .exists (direct )) {
236244 return direct ;
237245 }
238- // Fallback: glob for matching dist-info directory
246+ // Fallback: glob for matching dist-info directory (must also match version)
239247 try (DirectoryStream <Path > stream = Files .newDirectoryStream (sitePackages , "*.dist-info" )) {
240248 String normalizedLower = PythonResolutionResult .normalizeName (packageName );
249+ String expectedSuffix = "-" + version + ".dist-info" ;
241250 for (Path distInfo : stream ) {
242251 String dirName = distInfo .getFileName ().toString ();
243- // dirName is like "requests-2.31.0.dist-info"
244- int dashIdx = dirName .indexOf ('-' );
245- if (dashIdx > 0 ) {
246- String dirPkgName = dirName .substring (0 , dashIdx );
247- if (PythonResolutionResult .normalizeName (dirPkgName ).equals (normalizedLower )) {
248- Path metadata = distInfo .resolve ("METADATA" );
249- if (Files .exists (metadata )) {
250- return metadata ;
251- }
252+ if (!dirName .endsWith (expectedSuffix )) {
253+ continue ;
254+ }
255+ String dirPkgName = dirName .substring (0 , dirName .length () - expectedSuffix .length ());
256+ if (PythonResolutionResult .normalizeName (dirPkgName ).equals (normalizedLower )) {
257+ Path metadata = distInfo .resolve ("METADATA" );
258+ if (Files .exists (metadata )) {
259+ return metadata ;
252260 }
253261 }
254262 }
@@ -274,7 +282,7 @@ static List<String> parseRequiresDist(String metadataContent) {
274282 String value = trimmed .substring ("Requires-Dist:" .length ()).trim ();
275283
276284 // Skip entries with "extra ==" markers (optional extras, not always installed)
277- if (value . contains ( "extra ==" ) || value . contains ( "extra=" )) {
285+ if (EXTRA_MARKER_PATTERN . matcher ( value ). find ( )) {
278286 continue ;
279287 }
280288
0 commit comments