Drupal Finder provides a class to locate a Drupal installation in a given path.
$drupalFinder = new \DrupalFinder\DrupalFinder();
if ($drupalFinder->locateRoot(getcwd())) {
$drupalRoot = $drupalFinder->getDrupalRoot();
$composerRoot = $drupalFinder->getComposerRoot();
...
}
Copy the file d7-no-composer.composer.json to the root of your project.
Rename it composer.json.
In Terminal, run $ composer install
GPL-2.0+