From 371008fe1e145655cc929d25a327e205e6e841c1 Mon Sep 17 00:00:00 2001 From: Stephen Swaney Date: Tue, 11 Apr 2006 19:05:58 +0000 Subject: [PATCH] last release we lost our reassuring msg when no local python install was found. Restore warm fuzzy msg. Text is now Looking for installed Python version XXX followed by either Got it! or 'import site' failed; use -v for traceback No installed Python found. Only built-in modules are available. Some scripts may not run. Continuing happily. And while we are at it, clean up a couple of compiler warnings. --- source/blender/python/BPY_extern.h | 5 +++ source/blender/python/BPY_interface.c | 48 +++++---------------------- source/blender/python/api2_2x/Draw.h | 4 --- 3 files changed, 14 insertions(+), 43 deletions(-) diff --git a/source/blender/python/BPY_extern.h b/source/blender/python/BPY_extern.h index 97e8819c77a..ffb5f258d8d 100644 --- a/source/blender/python/BPY_extern.h +++ b/source/blender/python/BPY_extern.h @@ -30,6 +30,9 @@ * ***** END GPL/BL DUAL LICENSE BLOCK ***** */ +#ifndef BPY_EXTERN_H +#define BPY_EXTERN_H + extern char bprogname[]; /* holds a copy of argv[0], from creator.c */ struct Text; /* defined in DNA_text_types.h */ @@ -93,3 +96,5 @@ extern "C" { #ifdef __cplusplus } /* extern "C" */ #endif + +#endif /* BPY_EXTERN_H */ diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c index 529d428692b..d69a671e7b5 100644 --- a/source/blender/python/BPY_interface.c +++ b/source/blender/python/BPY_interface.c @@ -108,7 +108,7 @@ void init_ourImport( void ); void init_ourReload( void ); PyObject *blender_import( PyObject * self, PyObject * args ); -int BPY_txt_do_python_Text( struct Text *text ); + void BPY_Err_Handle( char *script_name ); PyObject *traceback_getFilename( PyObject * tb ); @@ -143,7 +143,7 @@ void BPY_start_python( int argc, char **argv ) * rest of our init msgs. */ // Py_GetVersion() returns a ptr to astatic string - printf( "Using Python version %.3s\n", Py_GetVersion() ); + printf( "Looking for installed Python version %.3s\n", Py_GetVersion() ); //Initialize the TOP-LEVEL modules PyImport_ExtendInittab(BPy_Inittab_Modules); @@ -230,14 +230,6 @@ void init_syspath( int first_time ) progname = BLI_last_slash( bprogname ); /* looks for the last dir separator */ -#ifdef SETSYSPATH - { - char *c; - c = Py_GetPath( ); /* get python system path */ - PySys_SetPath( c ); /* initialize */ - } -#endif - n = progname - bprogname; if( n > 0 ) { strncpy( execdir, bprogname, n ); @@ -246,42 +238,18 @@ void init_syspath( int first_time ) execdir[n] = '\0'; syspath_append( execdir ); /* append to module search path */ - - /* set Blender.sys.progname */ } else printf( "Warning: could not determine argv[0] path\n" ); -#ifdef SETSYSPATH /* - * bring in the site module so we can add - * site-package dirs to sys.path - */ + attempt to import 'site' module as a check for valid + python install found. + */ mod = PyImport_ImportModule( "site" ); /* new ref */ if( mod ) { - PyObject *item; - int size = 0; - int index; - PyObject *p; - - /* get the value of 'sitedirs' from the module */ - - /* the ref man says GetDict() never fails!!! */ - d = PyModule_GetDict( mod ); /* borrowed ref */ - p = PyDict_GetItemString( d, "sitedirs" ); /* borrowed ref */ - - if( p ) { /* we got our string */ - /* append each item in sitedirs list to path */ - size = PyList_Size( p ); - - for( index = 0; index < size; index++ ) { - item = PySequence_GetItem( p, index ); /* new ref */ - if( item ) - syspath_append( PyString_AsString - ( item ) ); - } - } + printf("Got it!\n"); /* appears after msg Looking for Python... */ Py_DECREF( mod ); } else { /* import 'site' failed */ PyErr_Clear( ); @@ -291,7 +259,7 @@ void init_syspath( int first_time ) printf( "Continuing happily.\n" ); } } -#endif + /* * initialize the sys module @@ -305,6 +273,8 @@ void init_syspath( int first_time ) EXPP_dict_set_item_str( d, "executable", Py_BuildValue( "s", bprogname ) ); Py_DECREF( mod ); + } else{ + printf("import of sys module failed\n"); } } diff --git a/source/blender/python/api2_2x/Draw.h b/source/blender/python/api2_2x/Draw.h index ac3b7b53f3a..ce4d29a850d 100644 --- a/source/blender/python/api2_2x/Draw.h +++ b/source/blender/python/api2_2x/Draw.h @@ -67,10 +67,6 @@ typedef struct _Button { /* * these are declared in ../BPY_extern.h */ -void BPY_spacescript_do_pywin_draw( SpaceScript * sc ); -void BPY_spacescript_do_pywin_event( SpaceScript * sc, - unsigned short event, short val, char ascii ); -void BPY_free_compiled_text( Text * text ); PyObject *M_Draw_Init( void ); PyObject *Draw_Init( void );