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.
This commit is contained in:
Stephen Swaney 2006-04-11 19:05:58 +00:00
parent 18a8479931
commit 371008fe1e
3 changed files with 14 additions and 43 deletions

@ -30,6 +30,9 @@
* ***** END GPL/BL DUAL LICENSE BLOCK ***** * ***** 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 */ extern char bprogname[]; /* holds a copy of argv[0], from creator.c */
struct Text; /* defined in DNA_text_types.h */ struct Text; /* defined in DNA_text_types.h */
@ -93,3 +96,5 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */
#endif #endif
#endif /* BPY_EXTERN_H */

@ -108,7 +108,7 @@ void init_ourImport( void );
void init_ourReload( void ); void init_ourReload( void );
PyObject *blender_import( PyObject * self, PyObject * args ); PyObject *blender_import( PyObject * self, PyObject * args );
int BPY_txt_do_python_Text( struct Text *text );
void BPY_Err_Handle( char *script_name ); void BPY_Err_Handle( char *script_name );
PyObject *traceback_getFilename( PyObject * tb ); PyObject *traceback_getFilename( PyObject * tb );
@ -143,7 +143,7 @@ void BPY_start_python( int argc, char **argv )
* rest of our init msgs. * rest of our init msgs.
*/ */
// Py_GetVersion() returns a ptr to astatic string // 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 //Initialize the TOP-LEVEL modules
PyImport_ExtendInittab(BPy_Inittab_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 */ 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; n = progname - bprogname;
if( n > 0 ) { if( n > 0 ) {
strncpy( execdir, bprogname, n ); strncpy( execdir, bprogname, n );
@ -246,42 +238,18 @@ void init_syspath( int first_time )
execdir[n] = '\0'; execdir[n] = '\0';
syspath_append( execdir ); /* append to module search path */ syspath_append( execdir ); /* append to module search path */
/* set Blender.sys.progname */
} else } else
printf( "Warning: could not determine argv[0] path\n" ); printf( "Warning: could not determine argv[0] path\n" );
#ifdef SETSYSPATH
/* /*
* bring in the site module so we can add attempt to import 'site' module as a check for valid
* site-package dirs to sys.path python install found.
*/ */
mod = PyImport_ImportModule( "site" ); /* new ref */ mod = PyImport_ImportModule( "site" ); /* new ref */
if( mod ) { if( mod ) {
PyObject *item; printf("Got it!\n"); /* appears after msg Looking for Python... */
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 ) );
}
}
Py_DECREF( mod ); Py_DECREF( mod );
} else { /* import 'site' failed */ } else { /* import 'site' failed */
PyErr_Clear( ); PyErr_Clear( );
@ -291,7 +259,7 @@ void init_syspath( int first_time )
printf( "Continuing happily.\n" ); printf( "Continuing happily.\n" );
} }
} }
#endif
/* /*
* initialize the sys module * initialize the sys module
@ -305,6 +273,8 @@ void init_syspath( int first_time )
EXPP_dict_set_item_str( d, "executable", EXPP_dict_set_item_str( d, "executable",
Py_BuildValue( "s", bprogname ) ); Py_BuildValue( "s", bprogname ) );
Py_DECREF( mod ); Py_DECREF( mod );
} else{
printf("import of sys module failed\n");
} }
} }

@ -67,10 +67,6 @@ typedef struct _Button {
/* /*
* these are declared in ../BPY_extern.h * 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 *M_Draw_Init( void );
PyObject *Draw_Init( void ); PyObject *Draw_Init( void );