-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyb.c
51 lines (45 loc) · 1.19 KB
/
pyb.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(int argc, char *argv[]) {
const char* ENV_VAR_NAME = "PYBUILDJ";
#ifdef _WIN32
char command[1024] = "python ";
char* path = getenv(ENV_VAR_NAME);
char* exec_command;
if(path == NULL) {
printf("Environment Variable %s not set", ENV_VAR_NAME);
return 1;
}
path = strcat(path, "\\main.py");
exec_command = strcat(command, path);
exec_command = strcat(exec_command, " ");
for(int i = 1; i < argc; i++) {
strcat(exec_command, argv[i]);
strcat(exec_command, " ");
}
#endif
/* char command[1024] = "python ./main.py"; */
/* for(int i = 1; i < argc; i++) { */
/* strcat(command, argv[i]); */
/* strcat(command, " "); */
/* } */
#ifdef __linux__
char command[1024] = "python3 ";
char* path = getenv(ENV_VAR_NAME);
char* exec_command;
if(path == NULL) {
printf("Environment Variable %s not set", ENV_VAR_NAME);
return 1;
}
path = strcat(path, "/main.py");
exec_command = strcat(command, path);
exec_command = strcat(exec_command, " ");
for(int i = 1; i < argc; i++) {
strcat(exec_command, argv[i]);
strcat(exec_command, " ");
}
#endif
system(exec_command);
return 0;
}