RenPy game with Python Debugger Attached

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Regis
Newbie
Posts: 16
Joined: Tue Jan 10, 2017 6:31 pm
Contact:

RenPy game with Python Debugger Attached

#1 Post by Regis » Sun Feb 26, 2017 3:17 pm

Is the a "right way" to launch RenPy game with attached Python level debugger (like pdb or, better, PyCharm from JetBrains)?

How to launch RenPy-based game as Python script if I'm on Windows?
Any attempt to launch *.py file from game root results in
"""
Could not import pygame_sdl2. Please ensure that this program has been built
and unpacked properly. Also, make sure that the directories containing
this program do not contain : or ; in their names.

You may be using a system install of python. Please run GameName.sh,
GameName.exe, or GameName.app instead
"""

User avatar
PyTom
Ren'Py Creator
Posts: 15445
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: RenPy game with Python Debugger Attached

#2 Post by PyTom » Sun Feb 26, 2017 3:25 pm

In general, no. You'd have to somehow integrate the python debugger with the Ren'Py event loop. I don't know anyone who has done this.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

Regis
Newbie
Posts: 16
Joined: Tue Jan 10, 2017 6:31 pm
Contact:

Re: RenPy game with Python Debugger Attached

#3 Post by Regis » Sun Feb 26, 2017 3:34 pm

I assumed that RenPy itself mainly work on Python. Am I wrong?

Could you please point to a place in RenPy sources where the Python execution starts?

Regis
Newbie
Posts: 16
Joined: Tue Jan 10, 2017 6:31 pm
Contact:

Re: RenPy game with Python Debugger Attached

#4 Post by Regis » Sun Feb 26, 2017 3:37 pm

Is the any docs that describe RenPy internal structure?

User avatar
PyTom
Ren'Py Creator
Posts: 15445
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: RenPy game with Python Debugger Attached

#5 Post by PyTom » Mon Feb 27, 2017 3:01 am

Ren'Py is written in a mix of Python, Cython, and C. Execution starts at the start of renpy.py. There isn't any documentation that describes Ren'Py's internal structures. The various files themselves are pretty well documented (at least for code touched in the past 5 years or so), but there isn't really a high-level overview document at this time. I don't get paid to work on Ren'Py, so documenting the internals is hard to get time for.

BTW, note that there is a Ren'Py console that you can get at by hitting shift+O. In the latest prerelease, it can be run when an exception occurs. That might get you some of the way to what you want.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

Apa
Regular
Posts: 103
Joined: Fri Dec 23, 2016 2:26 am
Location: NYC
Contact:

Re: RenPy game with Python Debugger Attached

#6 Post by Apa » Mon Feb 27, 2017 3:29 pm

PyTom wrote:In the latest prerelease, it can be run when an exception occurs. That might get you some of the way to what you want.
Cool! Almost like JIT debugger! 8)

User avatar
ISAWHIM
Veteran
Posts: 284
Joined: Sun Nov 06, 2016 5:34 pm
Contact:

Re: RenPy game with Python Debugger Attached

#7 Post by ISAWHIM » Tue Feb 28, 2017 12:47 am

PyTom wrote:I don't get paid to work on Ren'Py, so documenting the internals is hard to get time for.
Time for you to get a Patreon page and start getting paid. This program qualifies for acceptance there. Take advantage of this "burst wave" of money influx and ride the coat-tails of Patreon, until the next new thing comes around.

You not only help by making this possible, but also by directly assisting those of us in great need.

Just wanted to add, for those hitting this thread, the link to the dev-tools help page.
https://www.renpy.org/doc/html/developer_tools.html

I think that should be the first thing everyone can see on any code-help page, as well as the error-page that RenPy displays, when the game crashes. :P

Regis
Newbie
Posts: 16
Joined: Tue Jan 10, 2017 6:31 pm
Contact:

Re: RenPy game with Python Debugger Attached

#8 Post by Regis » Tue Feb 28, 2017 4:39 pm

PyTom, how to actually import "pygame_sdl2" from Python code?
Note: I want to import version that is distributed with the game and/or RenPy SDK. Naive approach when I just use embedded Python doesn't work :(

User avatar
PyTom
Ren'Py Creator
Posts: 15445
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: RenPy game with Python Debugger Attached

#9 Post by PyTom » Tue Feb 28, 2017 5:28 pm

Code: Select all

init python:
    import pygame_sdl2
Will work.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
gas
Miko-Class Veteran
Posts: 530
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: RenPy game with Python Debugger Attached

#10 Post by gas » Tue Feb 28, 2017 6:19 pm

ISAWHIM wrote:
PyTom wrote:I don't get paid to work on Ren'Py, so documenting the internals is hard to get time for.
Time for you to get a Patreon page and start getting paid. This program qualifies for acceptance there. Take advantage of this "burst wave" of money influx and ride the coat-tails of Patreon, until the next new thing comes around.
Patreon put a number of issues.
One, the project is not entirely a PyTom thing and a number of people contributed from the start (a LARGE number). If PyTom get money, translators, interface designers and other contributors want their slice of the cake.
Two, you really want to work with an engine that could cease to exist or being updated if someone else stop to pledge it?
Third, documenting things is not forbidden for the community. Is a large and boring task, but you can do it at will. I think that PyTom can't and couldn't exchange his regular work hours with "who knows" pledges to do a secondary thing (99.9% of people are not even going over the quick start guide, that's all they need to do a visual novel).
so if someone want, is the welcome and the community will be grateful.

To get money, I think is far better to do low level core changes for companies that ACTUALLY can pay real money for ("Take this 2000 dollars and code a way to avoid rpa extractor work on the scripts.."). Or selling accessories, like the Interactive Director.
10 ? "RENPY"
20 GOTO 10

RUN

User avatar
PyTom
Ren'Py Creator
Posts: 15445
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: RenPy game with Python Debugger Attached

#11 Post by PyTom » Wed Mar 01, 2017 2:05 am

I'm considering running a Patreon at some point. While Ren'Py has quite a few contributors, it will remain open source. I suspect each contributor would be able to run their own patreon, although there are some issues with the Ren'Py trademark that I own. (I'd be fine if a regular contributor ran a patreon to contribute more, but not someone random trying to trade on the name.) Ren'Py would continue existing regardless, but it would be nice to work on it more, and afford some tools I'd like, such as a visual studio subscription.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

Regis
Newbie
Posts: 16
Joined: Tue Jan 10, 2017 6:31 pm
Contact:

Re: RenPy game with Python Debugger Attached

#12 Post by Regis » Thu Mar 02, 2017 4:04 pm

PyTom wrote:

Code: Select all

init python:
    import pygame_sdl2
Will work.
Doesn't work when I try to run
```
import pygame_sdl2
```
directly from Python executable that is distributed with game. Do I need to specify additional search path? Do I need to manually load sdl2.dll somehow?

User avatar
PyTom
Ren'Py Creator
Posts: 15445
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: RenPy game with Python Debugger Attached

#13 Post by PyTom » Thu Mar 02, 2017 4:40 pm

Run python with the -O option.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
Enerccio
Miko-Class Veteran
Posts: 616
Joined: Thu Oct 26, 2006 4:23 pm
Projects: My Teacher; Songs of Araiah; Something new; Possible Cross Bomber?
Location: Slovakia, Kosice
Contact:

Re: RenPy game with Python Debugger Attached

#14 Post by Enerccio » Tue Aug 22, 2017 4:45 am

Any info on better debugging? If you have lots of normal python code, sometimes it is better to debug it outside the renpy which makes no sense...
Image
http://www.bishojo.tk is technically ONLINE!
Songs of Araiah promo: http://www.youtube.com/watch?v=CalchucuoDU

Post Reply

Who is online

Users browsing this forum: Ayael