-
-
Notifications
You must be signed in to change notification settings - Fork 765
Setting up PyCharm
PyCharm is a Python developer's IDE from Jetbrains available for both Windows, Mac and Linux. It is a commercial product but offer free trials, a scaled-down community edition and also generous licenses for OSS projects like Evennia.
This page was originally tested on Windows (so use Windows-style path examples), but should work the same for all platforms.
First, install Evennia on your local machine with Getting Started. If you're new to PyCharm, loading your project is as easy as selecting the Open option when PyCharm starts, and browsing to your game folder (the one created with evennia --init). We refer to it as mygame here.
If you want to be able to examine evennia's core code or the scripts inside your virtualenv, you'll need to add them to your project too:
- Go to
File > Open... - Select the folder (i.e. the
evenniaroot) - Select "Open in current window" and "Add to currently opened projects"
It's a good idea to do this before attempting anything further. The rest of this page assumes your project is already configured in PyCharm.
- Go to
File > Settings... > Project: \<mygame\> > Project Interpreter - Click the Gear symbol
> Add local - Navigate to your
pyenv/scripts directory, and select Python.exe
Enjoy seeing all your imports checked properly, setting breakpoints, and live variable watching!
- Launch Evennia in your preferred way (usually from a console/terminal)
- Open your project in PyCharm
- In the PyCharm menu, select
Run > Attach to Local Process... - From the list, pick the
twistdprocess with theserver.pyparameter (Example:twistd.exe --nodaemon --logfile=\<mygame\>\server\logs\server.log --python=\<evennia repo\>\evennia\server\server.py)
Of course you can attach to the portal process as well. If you want to debug the Evennia launcher or runner for some reason (or just learn how they work!), see Run Configuration below.
NOTE: Whenever you reload Evennia, the old Server process will die and a new one start. So when you restart you have to detach from the old and then reattach to the new process that was created.
This configuration allows you to launch Evennia from inside PyCharm. Besides convenience, it also allows suspending and debugging the evennia_launcher or evennia_runner at points earlier than you could by running them externally and attaching. In fact by the time the server and/or portal are running the launcher will have exited already.
- Go to
Run > Edit Configutations... - Click the plus-symbol to add a new configuration and choose Python
- Add the script:
\<yourrepo\>\pyenv\Scripts\evennia_launcher.py(substitute your virtualenv if it's not namedpyenv) - Set script parameters to:
start -i(-i enables console logging) - Ensure the chosen interpreter is from your virtualenv
- Set Working directory to your
mygamefolder (not pyenv nor evennia) - You can refer to the PyCharm documentation for general info, but you'll want to set at least a config name (like "MyMUD start" or similar).
Now set up a "stop" configuration by following the same steps as above, but set your Script parameters to: stop (and name the configuration appropriately).
A dropdown box holding your new configurations should appear next to your PyCharm run button. Select MyMUD start and press the debug icon to begin debugging. Depending on how far you let the program run, you may need to run your "MyMUD stop" config to actually stop the server, before you'll be able start it again.