Windspar

D - Python virtual environment launcher on linux.

Aug 4th, 2026
80
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.83 KB | Source Code | 0 0
  1. import std.path;
  2. import std.stdio;
  3. import std.process;
  4.  
  5. // Launcher. Python virtual environment programs launcher on linux.
  6. void main(string[] args)
  7. {
  8.     if (args.length > 1)
  9.     {
  10.         string program = args[1];
  11.         auto ext = extension(program);
  12.         if (ext != ".py")
  13.         {
  14.             if (ext.length == 0)
  15.             {
  16.                 program ~= ".py";
  17.             }
  18.             else
  19.             {
  20.                 writeln("Looking for python file extension");
  21.                 return;
  22.             }
  23.         }
  24.  
  25.         auto homedir = environment.get("HOME");
  26.         //writeln(homedir, " -- ", homedir.expandTilde);
  27.         auto pid = spawnProcess([homedir ~ "/env/bin/python", program]);
  28.         auto exitCode = wait(pid);
  29.     }
  30.     else
  31.     {
  32.         writeln("Missing python file name");
  33.     }
  34. }
  35.  
Advertisement
Comments
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment