Merge pull request #3718 from 0xDEADFED5/main

remove twistd.bat creation and usage
This commit is contained in:
Griatch 2025-02-02 19:46:56 +01:00 committed by GitHub
commit a80d794668
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 67 deletions

View file

@ -85,5 +85,4 @@ If `localhost` doesn't work when trying to connect to your local game, try `127.
- If your MUD client cannot connect to `localhost:4000`, try the equivalent `127.0.0.1:4000` instead. Some MUD clients on Windows does not appear to understand the alias `localhost`.
- Some Windows users get an error installing the Twisted 'wheel'. A wheel is a pre-compiled binary package for Python. A common reason for this error is that you are using a 32-bit version of Python, but Twisted has not yet uploaded the latest 32-bit wheel. Easiest way to fix this is to install a slightly older Twisted version. So if, say, version `22.1` failed, install `22.0` manually with `pip install twisted==22.0`. Alternatively you could check that you are using the 64-bit version of Python and uninstall any 32bit one. If so, you must then `deactivate` the virtualenv, delete the `evenv` folder and recreate it anew with your new Python.
- If you've done a git installation, and your server won't start with an error message like `AttributeError: module 'evennia' has no attribute '_init'`, it may be a python path issue. In a terminal, cd to `(your python directory)\site-packages` and run the command `echo "C:\absolute\path\to\evennia" > local-vendors.pth`. Open the created file in your favorite IDE and make sure it is saved with *UTF-8* encoding and not *UTF-8 with BOM*.
- If your server won't start, with no error messages (and no log files at all when starting from scratch), try to start with `evennia ipstart` instead. If you then see an error about `system cannot find the path specified`, it may be that the file `evennia\evennia\server\twistd.bat` has the wrong path to the `twistd` executable. This file is auto-generated, so try to delete it and then run `evennia start` to rebuild it and see if it works. If it still doesn't work you need to open it in a text editor like Notepad. It's just one line containing the path to the `twistd.exe` executable as determined by Evennia. If you installed Twisted in a non-standard location this might be wrong and you should update the line to the real location.
- Some users have reported issues with Windows WSL and anti-virus software during Evennia development. Timeout errors and the inability to run `evennia connections` may be due to your anti-virus software interfering. Try disabling or changing your anti-virus software settings.

View file

@ -258,29 +258,6 @@ ERROR_DATABASE = """
to initialize/update the database according to your settings.
"""
ERROR_WINDOWS_WIN32API = """
ERROR: Unable to import win32api, which Twisted requires to run.
You may download it with pip in your Python environment:
pip install --upgrade pywin32
"""
INFO_WINDOWS_BATFILE = """
INFO: Since you are running Windows, a file 'twistd.bat' was
created for you. This is a simple batch file that tries to call
the twisted executable. Evennia determined this to be:
{twistd_path}
If you run into errors at startup you might need to edit
twistd.bat to point to the actual location of the Twisted
executable (usually called twistd.py) on your machine.
This procedure is only done once. Run `evennia` again when you
are ready to start the server.
"""
CMDLINE_HELP = """Starts, initializes, manages and operates the Evennia MU* server.
Most standard django management commands are also accepted."""
@ -1870,50 +1847,10 @@ def init_game_directory(path, check_db=True, need_gamedir=True):
sys.exit()
if _is_windows():
# We need to handle Windows twisted separately. We create a
# batchfile in game/server, linking to the actual binary
global TWISTED_BINARY
# Windows requires us to use the absolute path for the bat file.
server_path = os.path.dirname(os.path.abspath(__file__))
TWISTED_BINARY = os.path.join(server_path, "twistd.bat")
# add path so system can find the batfile
sys.path.insert(1, os.path.join(GAMEDIR, SERVERDIR))
try:
importlib.import_module("win32api")
except ImportError:
print(ERROR_WINDOWS_WIN32API)
sys.exit()
batpath = os.path.join(EVENNIA_SERVER, TWISTED_BINARY)
if not os.path.exists(batpath):
# Test for executable twisted batch file. This calls the
# twistd.py executable that is usually not found on the
# path in Windows. It's not enough to locate
# scripts.twistd, what we want is the executable script
# C:\PythonXX/Scripts/twistd.py. Alas we cannot hardcode
# this location since we don't know if user has Python in
# a non-standard location. So we try to figure it out.
twistd = importlib.import_module("twisted.scripts.twistd")
twistd_dir = os.path.dirname(twistd.__file__)
# note that we hope the twistd package won't change here, since we
# try to get to the executable by relative path.
# Update: In 2016, it seems Twisted 16 has changed the name of
# of its executable from 'twistd.py' to 'twistd.exe'.
twistd_path = os.path.abspath(
os.path.join(
twistd_dir, os.pardir, os.pardir, os.pardir, os.pardir, "scripts", "twistd.exe"
)
)
with open(batpath, "w") as bat_file:
# build a custom bat file for windows
bat_file.write('@"%s" %%*' % twistd_path)
print(INFO_WINDOWS_BATFILE.format(twistd_path=twistd_path))
TWISTED_BINARY = os.path.join(os.path.dirname(sys.executable), "twistd.exe")
if not os.path.exists(TWISTED_BINARY): # venv isn't being used
TWISTED_BINARY = os.path.join(os.path.dirname(sys.executable), "Scripts\\twistd.exe")
def run_dummyrunner(number_of_dummies):