How to check if library is present in vendor folder? I have a form in which I am providing some options to users. But I want the options to appear in the form on the basis of presence of 3rd party libraries in vendor directory. I want something like this:

public function buildForm(array $form, FormStateInterface $form_state) {
    $form['settings']['tools'] = array(
      '#type' =&gt; 'radios',
      '#title' =&gt; $this-&gt;t('tools'),
      '#options' =&gt; array(),
      '#default_value' =&gt; $this-&gt;config('module.settings')-&gt;get('tools'),
    );
if(check_whether_xyz_library_is present_in_vendor_folder) {
  $form['settings']['tools']['#options'] = array('xyz' =&gt; 'xyz');
}

The vendor folder is present in the module directory itself and I am using composer to download third party dependencies. Since I do not want to check this  during installation of module but during form rendering then I suppose hook_requirements is not option. Any ideas on how to do so?
If you are talking about libraries, which are defined in files like *.libraries.yml, then you can use this:

\Drupal::service('library.discovery')-&gt;getLibraryByName('MODULE_NAME', 'LIBRARY_NAME')


You'll receive an array with all data including paths to check that files are exist.