• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Vortez

Embedded Python 3.3 problem...

2 posts in this topic

Hey, i just ran into a little snag with an app i've made that use python 3.3. The thing is, it work perfectly on a machine with python installed on it, but when i tried it on another machine, at first, it complained about Python33.dll. So, i found the file in the system32 folder and copied it in the app directory, but now, it crash, giving me the error 0x40000015. From what i could dig up, i though it was some missing msvc runtime dlls, so i tryed installing vs2012 redist, to no avail (i have vs2010 installed on my machine, so no need for those). I even tryed copying all files starting with msvcxxxx.dll i could find, didn't fixed it either. Im a bit lost. Do they really expect us to install python on every machine we want our app to run?

 

How the hell can i know what file is missing... I tryed dependency walker on the dev machine, didn't even detect any python dll... It seem i just can't find the problem. To be honest, it seem that previous python version where better(no @#$@ unicode everywhere, delphi/cpp builder did that too and i hate that), but i haven't tryed them.

 

What the heck with forcing us to use unicode everywhere??? It's really fun to convert from UnicodeString, AnsiString, string and C-String in a c++ builder app, really fun........

Most old python code in c++ don't work either because of that too, and it's really pissing me off. For example, today i typed the 'é' char in a save file dialog box, only to see it transformed to an '@'....... angry.pngangry.pngangry.png

Edited by Vortez
0

Share this post


Link to post
Share on other sites

 

Do they really expect us to install python on every machine we want our app to run?

 

No, one of the goal of embedding python is that you don't need to ask your user to install it on their system. Your executable is linked against the python library so you must distribute the python dll (and the microsoft c runtimes). That being said I've only worked with python 2.7 and do not know what dll you are missing in your specific case. You can always use the Windows Dependency Walker to find out the missing dlls.

 

 

Edit: What compiler did you use to build your game executable? It must be the same one as the one used to build python, wich is Visual Studio 2010 (if you downloaded the official python release)

Edited by ColinDuquesnoy
0

Share this post


Link to post
Share on other sites

I know this post is really old now, but i just wanted to add the solution i just found in case that could help someone in a similar situation. The problem was that python use the registry to know where to find it's library (you don't just need the dll you also need the python files), and for a machine with no python installed it search in directories relative to the application directory, so that's why it crashed/failed ect.

 

The solution i've found is to call PySys_SetPath() with the 3 required directory: "<python dir>/DLLs" "<python dir>/Lib" and "<python dir>/Lib/lib-tk"

 

<python dir> can be a directory or even a .zip file.

 

For example, if your program is in "C:\MyApp", the value to pass to PySys_SetPath() should be

 

"C:\MyApp\Python27\DLLs;C:\MyApp\Python27\Lib;C:\MyApp\Python27\Lib\lib-tk"

or

"C:\MyApp\Python27.zip\DLLs;C:\MyApp\Python27.zip\Lib;C:\MyApp\Python27.zip\Lib\lib-tk"

 

So, using the poorly written but working code, all works

char* ExtractFilePath(char *fullpath)
{
	static char Path[MAX_PATH];
	ZeroMemory(Path, MAX_PATH);

	int Pos = -1;
	int Size = strlen(fullpath);

	for(int i = Size-1; i >= 0; i--){
		if(fullpath[i] == '\\'){
			Pos = i;
			break;
		}
	}

	if(Pos > 0)
		memcpy(Path, fullpath, Pos); 

	return Path;
}

// Set paths to directories
/*void SetPythonPaths(char *AppDir)
{
	LPCSTR DllsDir = "\\Python27\\DLLs";
	LPCSTR LibDir = "\\Python27\\Lib";
	LPCSTR libtkDir = "\\Python27\\Lib\\lib-tk";

	int PathBufSize = (strlen(AppDir) * 3) + strlen(DllsDir) + strlen(LibDir) + strlen(libtkDir) + 3;
		
	char *PythonPaths = new char[PathBufSize];
	ZeroMemory(PythonPaths, PathBufSize);
	sprintf(PythonPaths, "%s%s;%s%s;%s%s", AppDir, DllsDir, AppDir, LibDir, AppDir, libtkDir);
	PySys_SetPath(PythonPaths);
	delete [] PythonPaths;
}*/

// Set paths to .zip file
void SetPythonPaths(char *AppDir)
{
	LPCSTR DllsDir = "/DLLs";
	LPCSTR LibDir = "/Lib";
	LPCSTR libtkDir = "/Lib/lib-tk";
	
	LPCSTR ZipName = "\\Python27.zip";

	int PathBufSize = (strlen(AppDir) * 3) + (strlen(ZipName) * 3) + strlen(DllsDir) + strlen(LibDir) + strlen(libtkDir) + 3;
		
	char *PythonPaths = new char[PathBufSize];
	ZeroMemory(PythonPaths, PathBufSize);
	sprintf(PythonPaths, "%s%s%s;%s%s%s;%s%s%s", AppDir, ZipName, DllsDir, AppDir, ZipName, LibDir, AppDir, ZipName, libtkDir);
	PySys_SetPath(PythonPaths);
	delete [] PythonPaths;
}

void CPythonScript::InitPython()
{
	if(!Initialized){

		Py_NoSiteFlag=1;
		Py_Initialize();
		module = PyImport_AddModule("__main__");
		dictionary = PyModule_GetDict(module);

		SetPythonPaths(ExtractFilePath(Py_GetProgramFullPath()));

		Initialized = true;
	}
}

Also, i had to add Py_NoSiteFlag=1; to the init function for some reason.

Edited by Vortez
2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0