Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sphinx-pre-install: detect an existing virtualenv

Detect if the script runs after creating the virtualenv,
printing the command line commands to enable the virtualenv.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
5be33182 24071ac1

+17 -9
+17 -9
scripts/sphinx-pre-install
··· 13 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 # GNU General Public License for more details. 15 15 16 + my $virtenv_dir = "sphinx_1.4"; 17 + 16 18 # 17 19 # Static vars 18 20 # ··· 456 454 which("sphinx-build-3"); 457 455 } 458 456 if ($need_sphinx) { 459 - my $virtualenv = findprog("virtualenv-3"); 460 - $virtualenv = findprog("virtualenv") if (!$virtualenv); 461 - $virtualenv = "virtualenv" if (!$virtualenv); 457 + my $activate = "$virtenv_dir/bin/activate"; 458 + if (-e "$ENV{'PWD'}/$activate") { 459 + printf "\nNeed to activate virtualenv with:\n"; 460 + printf "\t. $activate\n"; 461 + } else { 462 + my $virtualenv = findprog("virtualenv-3"); 463 + $virtualenv = findprog("virtualenv") if (!$virtualenv); 464 + $virtualenv = "virtualenv" if (!$virtualenv); 462 465 463 - printf "\t$virtualenv sphinx_1.4\n"; 464 - printf "\t. sphinx_1.4/bin/activate\n"; 465 - printf "\tpip install 'docutils==0.12'\n"; 466 - printf "\tpip install 'Sphinx==1.4.9'\n"; 467 - printf "\tpip install sphinx_rtd_theme\n"; 468 - $need++; 466 + printf "\t$virtualenv $virtenv_dir\n"; 467 + printf "\t. $activate\n"; 468 + printf "\tpip install 'docutils==0.12'\n"; 469 + printf "\tpip install 'Sphinx==1.4.9'\n"; 470 + printf "\tpip install sphinx_rtd_theme\n"; 471 + $need++; 472 + } 469 473 } 470 474 printf "\n"; 471 475