My Project
Loading...
Searching...
No Matches
Functions
python_module.cc File Reference
#include "kernel/mod2.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <sys/stat.h>
#include "Singular/tok.h"
#include "kernel/structs.h"
#include "Singular/mod_lib.h"
#include "Singular/ipid.h"
#include "Singular/locals.h"
#include "omalloc/omalloc.h"
#include <time.h>
#include <boost/python.hpp>
#include <Python.h>
#include "wrapper.h"

Go to the source code of this file.

Functions

static BOOLEAN mod_python (leftv __res, leftv __h)
 
int SI_MOD_INIT() python_module (SModulFunctions *psModulFunctions)
 

Function Documentation

◆ mod_python()

static BOOLEAN mod_python ( leftv  __res,
leftv  __h 
)
static

Definition at line 25 of file python_module.cc.

26{
28 int __tok = NONE, __index = 0;
30 char * a;
31 if(__v==NULL) goto mod_python_error;
32 __tok = __v->Typ();
35 __v_save = __v->next;
36 __v->next = NULL;
39 __v = __v_save;
40 a = (char *)__za->Data();
41 if(__v!=NULL) { __tok = __v->Typ(); goto mod_python_error; }
42
44 __res->data = NULL;
45 __res->rtyp = END_RING;
46 return FALSE;
47
49 Werror("python(`%s`) is not supported", Tok2Cmdname(__tok));
50 Werror("expected python('string')");
51 return TRUE;
52}
#define TRUE
Definition auxiliary.h:100
#define FALSE
Definition auxiliary.h:96
Class used for (list of) interpreter objects.
Definition subexpr.h:83
int iiTestConvert(int inputType, int outputType)
Definition gentable.cc:301
const char * Tok2Cmdname(int tok)
Definition gentable.cc:140
@ END_RING
Definition grammar.cc:310
BOOLEAN iiConvert(int inputType, int outputType, int index, leftv input, leftv output, const struct sConvertTypes *dConvertTypes)
Definition ipconv.cc:435
#define NULL
Definition omList.c:12
void Werror(const char *fmt,...)
Definition reporter.cc:189
@ STRING_CMD
Definition tok.h:185
#define NONE
Definition tok.h:221

◆ python_module()

int SI_MOD_INIT() python_module ( SModulFunctions psModulFunctions)

Definition at line 57 of file python_module.cc.

58{
59 VAR char *py=getenv("PYTHONPATH");
60 VAR char buf[1024];
61 if (py!=NULL)
62 {
63 strcpy(buf,py);
64 strcat(buf,":");
66 }
67 else
69 Print("setting PYTHONAPTH to %s\n",buf);
70 setenv("PYTHONPATH",buf,1);
71
73 PyRun_SimpleString("from sys import path\n\
74path.insert(0,'.')\n");
77
78 psModulFunctions->iiAddCproc(currPack->libname,"python",FALSE, mod_python);
79 return MAX_TOK;
80}
#define Print
Definition emacs.cc:80
static char * feResource(feResourceConfig config, int warn)
char * getenv()
#define VAR
Definition globaldefs.h:5
VAR package currPack
Definition ipid.cc:57
static BOOLEAN mod_python(leftv __res, leftv __h)
int status int void * buf
Definition si_signals.h:59
@ MAX_TOK
Definition tok.h:218