diff --git a/CHANGES.rst b/CHANGES.rst
index 607054e..f794d66 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,7 +4,7 @@ Changelog
 4.1 (unreleased)
 ----------------
 
-- Nothing changed yet.
+- Fix generated ``runzeo`` and ``zeoctl`` scripts to run with ZEO 5.
 
 
 4.0 (2017-02-28)
diff --git a/src/zope/mkzeoinstance/__init__.py b/src/zope/mkzeoinstance/__init__.py
index 9b6fe44..8053e92 100644
--- a/src/zope/mkzeoinstance/__init__.py
+++ b/src/zope/mkzeoinstance/__init__.py
@@ -116,9 +116,7 @@ CONFIG_FILE="%(instance_home)s/etc/%(package)s.conf"
 PYTHONPATH="$ZODB3_HOME"
 export PYTHONPATH INSTANCE_HOME
 
-ZEOCTL="$ZODB3_HOME/ZEO/zeoctl.py"
-
-exec "$PYTHON" "$ZEOCTL" -C "$CONFIG_FILE" ${1+"$@"}
+exec "$PYTHON" -m ZEO.zeoctl -C "$CONFIG_FILE" ${1+"$@"}
 """
 
 
@@ -135,9 +133,7 @@ CONFIG_FILE="%(instance_home)s/etc/%(package)s.conf"
 PYTHONPATH="$ZODB3_HOME"
 export PYTHONPATH INSTANCE_HOME
 
-RUNZEO="$ZODB3_HOME/ZEO/runzeo.py"
-
-exec "$PYTHON" "$RUNZEO" -C "$CONFIG_FILE" ${1+"$@"}
+exec "$PYTHON" -m ZEO.runzeo -C "$CONFIG_FILE" ${1+"$@"}
 """
 
 
@@ -197,7 +193,7 @@ class ZEOInstanceBuilder:
             if k in ('-h', '--help'):
                 usage(rc=2)
 
-        if len(args) < 1 or len(args) > 2:  
+        if len(args) < 1 or len(args) > 2:
             usage(rc=1)
 
         instance_home = os.path.abspath(args[0])

Broken with ZEO 5.1.1: runzeo and zeoctl fails.
While investigating zopefoundation/ZEO#87 I figured out, that the scripts running zeoctl and runzeo are no longer working due to usage of relative imports in ZEO.runzeo and ZEO.zeoctl.

It looks like the clean way is to not call the files as scripts, but execute them as modules. 
diff --git a/src/zope/mkzeoinstance/tests/test_unix.py b/src/zope/mkzeoinstance/tests/test_unix.py
index 68c4a2a..89c5c07 100644
--- a/src/zope/mkzeoinstance/tests/test_unix.py
+++ b/src/zope/mkzeoinstance/tests/test_unix.py
@@ -271,9 +271,7 @@ class ZEOInstanceBuilderTests(_WithTempdir, unittest.TestCase):
             'PYTHONPATH="$ZODB3_HOME"',
             'export PYTHONPATH INSTANCE_HOME',
             '',
-            'ZEOCTL="$ZODB3_HOME/ZEO/zeoctl.py"',
-            '',
-            'exec "$PYTHON" "$ZEOCTL" -C "$CONFIG_FILE" ${1+"$@"}',
+            'exec "$PYTHON" -m ZEO.zeoctl -C "$CONFIG_FILE" ${1+"$@"}',
             '',
             ]) % params
 

pip install -e .[test]
parse_log_pytest
requirements.txt
pytest coverage
apt-get update apt-get install -y gcc
3.9
requirements/base.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
BTrees==6.1
cffi==1.17.1
coverage==7.8.0
exceptiongroup==1.2.2
iniconfig==2.1.0
packaging==24.2
persistent==6.1.1
pluggy==1.5.0
pycparser==2.22
pytest==8.3.5
tomli==2.2.1
transaction==5.0
zc.lockfile==3.0.post1
ZConfig==4.2
zdaemon==5.1
ZEO==6.0.0
ZODB==6.0
zodbpickle==4.2
zope.deferredimport==5.0
zope.interface==7.2
-e git+https://github.com/zopefoundation/zope.mkzeoinstance.git@7ed33bb183929e5645a71950f5032018acbbda51#egg=zope.mkzeoinstance
zope.proxy==6.1

name: zope.mkzeoinstance
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - btrees==6.1
      - cffi==1.17.1
      - coverage==7.8.0
      - exceptiongroup==1.2.2
      - iniconfig==2.1.0
      - packaging==24.2
      - persistent==6.1.1
      - pluggy==1.5.0
      - pycparser==2.22
      - pytest==8.3.5
      - tomli==2.2.1
      - transaction==5.0
      - zc-lockfile==3.0.post1
      - zconfig==4.2
      - zdaemon==5.1
      - zeo==6.0.0
      - zodb==6.0
      - zodbpickle==4.2
      - zope-deferredimport==5.0
      - zope-interface==7.2
      - zope-proxy==6.1
prefix: /opt/conda/envs/zope.mkzeoinstance

src/zope/mkzeoinstance/tests/test_unix.py::ZEOInstanceBuilderTests::test_zeoctl_content
src/zope/mkzeoinstance/tests/test_unix.py::Test_print_::test_print__no_args_no_kw src/zope/mkzeoinstance/tests/test_unix.py::Test_print_::test_print__w_args src/zope/mkzeoinstance/tests/test_unix.py::Test_print_::test_print__w_kw src/zope/mkzeoinstance/tests/test_unix.py::Test_usage::test_defaults src/zope/mkzeoinstance/tests/test_unix.py::Test_usage::test_explicit src/zope/mkzeoinstance/tests/test_unix.py::Test_usage::test_w_non_str_message src/zope/mkzeoinstance/tests/test_unix.py::ZEOInstanceBuilderTests::test_create_folders_and_files src/zope/mkzeoinstance/tests/test_unix.py::ZEOInstanceBuilderTests::test_get_params src/zope/mkzeoinstance/tests/test_unix.py::ZEOInstanceBuilderTests::test_run_w_help src/zope/mkzeoinstance/tests/test_unix.py::ZEOInstanceBuilderTests::test_run_w_invalid_opt src/zope/mkzeoinstance/tests/test_unix.py::ZEOInstanceBuilderTests::test_run_w_too_many_arguments src/zope/mkzeoinstance/tests/test_unix.py::ZEOInstanceBuilderTests::test_run_wo_arguments src/zope/mkzeoinstance/tests/test_unix.py::ZEOInstanceBuilderTests::test_run_wo_single_arg_non_absolute src/zope/mkzeoinstance/tests/test_unix.py::ZEOInstanceBuilderTests::test_run_wo_two_args_no_host src/zope/mkzeoinstance/tests/test_unix.py::ZEOInstanceBuilderTests::test_run_wo_two_args_w_host src/zope/mkzeoinstance/tests/test_unix.py::ZEOInstanceBuilderTests::test_zeo_conf_content src/zope/mkzeoinstance/tests/test_unix.py::UtilityFunctionsTest::test_makedir src/zope/mkzeoinstance/tests/test_unix.py::UtilityFunctionsTest::test_makefile src/zope/mkzeoinstance/tests/test_unix.py::UtilityFunctionsTest::test_makefile_existing_different_content src/zope/mkzeoinstance/tests/test_unix.py::UtilityFunctionsTest::test_makefile_existing_same_content src/zope/mkzeoinstance/tests/test_unix.py::UtilityFunctionsTest::test_makexfile src/zope/mkzeoinstance/tests/test_unix.py::UtilityFunctionsTest::test_mkdirs src/zope/mkzeoinstance/tests/test_unix.py::UtilityFunctionsTest::test_mkdirs_nested
src/zope/mkzeoinstance/__init__.py CHANGES.rst
src/zope/mkzeoinstance/__init__.py CHANGES.rst