diff --git a/utils/scanpypi b/utils/scanpypi
index 1f3326cf4d..4164a52db3 100755
--- a/utils/scanpypi
+++ b/utils/scanpypi
@@ -296,21 +296,67 @@ class BuildrootPackage():
         current_dir = os.getcwd()
         os.chdir(self.tmp_extract)
         sys.path.insert(0, self.tmp_extract)
-        s_file, s_path, s_desc = imp.find_module('setup', [self.tmp_extract])
-        imp.load_module('__main__', s_file, s_path, s_desc)
-        if self.metadata_name in self.setup_args:
-            pass
-        elif self.metadata_name.replace('_', '-') in self.setup_args:
-            self.metadata_name = self.metadata_name.replace('_', '-')
-        elif self.metadata_name.replace('-', '_') in self.setup_args:
-            self.metadata_name = self.metadata_name.replace('-', '_')
         try:
-            self.setup_metadata = self.setup_args[self.metadata_name]
-        except KeyError:
-            # This means setup was not called
-            print('ERROR: Could not determine package metadata for {pkg}.\n'
-                  .format(pkg=self.real_name))
+            s_file, s_path, s_desc = imp.find_module('setup', [self.tmp_extract])
+            imp.load_module('__main__', s_file, s_path, s_desc)
+            if self.metadata_name in self.setup_args:
+                pass
+            elif self.metadata_name.replace('_', '-') in self.setup_args:
+                self.metadata_name = self.metadata_name.replace('_', '-')
+            elif self.metadata_name.replace('-', '_') in self.setup_args:
+                self.metadata_name = self.metadata_name.replace('-', '_')
+            try:
+                self.setup_metadata = self.setup_args[self.metadata_name]
+            except KeyError:
+                # This means setup was not called
+                print('ERROR: Could not determine package metadata for {pkg}.\n'
+                      .format(pkg=self.real_name))
+                raise
+        finally:
+            os.chdir(current_dir)
+            sys.path.remove(self.tmp_extract)
+
+    def load_pyproject(self):
+        """
+        Loads the corresponding pyproject.toml and store its metadata
+        """
+        from pprint import pprint
+        current_dir = os.getcwd()
+        os.chdir(self.tmp_extract)
+        sys.path.insert(0, self.tmp_extract)
+        try:
+            pyproject = open('pyproject.toml')
+        except FileNotFoundError:
             raise
+        else:
+            try:
+                from pip._vendor.tomli import load as toml_load
+            except ImportError:
+                try:
+                    from toml import load as _toml_load  # noqa: F401
+                    def toml_load(f):
+                        w = io.TextIOWrapper(f, encoding="utf8", newline="")
+                        try:
+                            return _toml_load(w)
+                        finally:
+                            w.detach()
+                except ImportError:
+                    print('This package needs toml')
+                    raise
+            with pyproject:
+                pyproject_data = toml_load(pyproject)
+                try:
+                    self.setup_metadata = pyproject_data.get('project', {})
+                    self.metadata_name = self.setup_metadata.get('name', self.real_name)
+                    build_backend = pyproject_data.get('build-system', {}).get('build-backend', None)
+                    if build_backend is not None:
+                        if build_backend == 'flit_core.buildapi':
+                            self.setup_metadata['method'] = 'flit'
+                except KeyError:
+                    # This means setup was not called
+                    print('ERROR: Could not determine package metadata for {pkg}.\n'
+                          .format(pkg=self.real_name))
+                    raise
         os.chdir(current_dir)
         sys.path.remove(self.tmp_extract)
 
@@ -690,11 +736,14 @@ def main():
             try:
                 package.load_setup()
             except ImportError as err:
-                if 'buildutils' in err.message:
+                if 'buildutils' in str(err):
                     print('This package needs buildutils')
+                    continue
                 else:
-                    raise
-                continue
+                    try:
+                        package.load_pyproject()
+                    except Exception as e:
+                        raise
             except (AttributeError, KeyError) as error:
                 print('Error: Could not install package {pkg}: {error}'.format(
                     pkg=package.real_name, error=error))
