Unverified Commit 36837cc6 authored by Ulysses Zhan's avatar Ulysses Zhan
Browse files

renpy: 8.4.1.25072401 -> 8.5.2.26010301-unstable-2026-03-27; add ulysseszhan as maintainer

parent c829ee77
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
diff --git a/launcher/game/distribute.rpy b/launcher/game/distribute.rpy
index bece65c63..831c405f8 100644
--- a/launcher/game/distribute.rpy
+++ b/launcher/game/distribute.rpy
@@ -863,7 +863,7 @@ fix_dlc("renios", "renios")
                             )
 
             for fn in os.listdir(directory):
-                walk(fn, os.path.join(directory, fn))
+                walk(fn, os.path.join(directory, "renpy-dist" if fn == "renpy" else fn))
 
         def merge_file_lists(self):
             """
+31 −0
Original line number Diff line number Diff line
diff --git a/renpy/script.py b/renpy/script.py
index 62e424415..7c3ae5922 100644
--- a/renpy/script.py
+++ b/renpy/script.py
@@ -969,6 +969,13 @@ class Script(object):
                 f.seek(-hashlib.md5().digest_size, 2)
                 digest = f.read(hashlib.md5().digest_size)
 
+        elif dir.startswith("@systemRenpy@"):
+            data, stmts = self.load_file(dir, fn + compiled)
+            lastfn = dir + "/" + fn + compiled
+            with open(lastfn, "rb") as f:
+                f.seek(-hashlib.md5().digest_size, 2)
+                digest = f.read(hashlib.md5().digest_size)
+
         else:
             # Otherwise, we're loading from disk. So we need to decide if
             # we want to load the rpy or the rpyc file.
diff --git a/launcher/game/distribute.rpy b/launcher/game/distribute.rpy
index bece65c63..c2590bcf7 100644
--- a/launcher/game/distribute.rpy
+++ b/launcher/game/distribute.rpy
@@ -606,7 +606,7 @@ fix_dlc("renios", "renios")
                 self.log.close()
                 return
 
-            if project.data['force_recompile']:
+            if project.data['force_recompile'] and False:
                 import compileall
 
                 compileall.compile_dir(
+30 −0
Original line number Diff line number Diff line
diff --git a/launcher/game/gui7/code.py b/launcher/game/gui7/code.py
index 5c1b89f23c..c8ad04b6dd 100644
--- a/launcher/game/gui7/code.py
+++ b/launcher/game/gui7/code.py
@@ -243,9 +243,7 @@ def quote(s):
 
         self.update_defines(replacements)
 
-    def write_target(self, filename):
-
-        target = os.path.join(self.p.prefix, filename)
+    def write_target(self, target):
 
         if os.path.exists(target):
 
@@ -421,7 +419,7 @@ def generate_gui(self, fn, defines=False):
             self.translate_comments()
             self.add_code(fn)
 
-        self.write_target(fn)
+        self.write_target(os.path.join(self.p.prefix, fn))
 
     def generate_code(self, fn):
 
@@ -439,4 +437,4 @@ def generate_code(self, fn):
 
         self.add_code(fn)
 
-        self.write_target(fn)
+        self.write_target(target)
+0 −16
Original line number Diff line number Diff line
diff --git a/renpy/common/00steam.rpy b/renpy/common/00steam.rpy
index 9a5f9c405..68c8c26e0 100644
--- a/renpy/common/00steam.rpy
+++ b/renpy/common/00steam.rpy
@@ -1029,11 +1029,6 @@ init -1499 python in achievement:
             steam = None
             steamapi = None
 
-    if renpy.windows or renpy.macintosh or renpy.linux:
-        steam_preinit()
-        steam_init()
-
-
 init 1500 python in achievement:
 
     # Steam position.
+221 −62
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  assimp,
  copyDesktopItems,
  desktopToDarwinBundle,
  fetchFromGitHub,
  fetchurl,
  fetchzip,
  ffmpeg,
  freetype,
  fribidi,
  glew,
  harfbuzz,
  lib,
  libGL,
  libGLU,
  libjpeg,
  libpng,
  makeWrapper,
  makeBinaryWrapper,
  makeDesktopItem,
  openssl,
  pkg-config,
  python312,
  SDL2,
  stdenv,
  SDL2_image,
  versionCheckHook,
  withoutSteam ? true,
  zenity,
  zlib,

  # the minimal package contains only compiled python and cython files, and the example projects and the launcher are removed
  # one should use the minimal package in favor of the full package when packaging games, in which case only the game runtime is needed
  minimal ? false,
  # with this, you can click "Documentation" in the launcher to open local doc (otherwise it opens web doc)
  withDoc ? !minimal,
  # set this to true if you want to use this package to distribute games
  # (to windows, linux, and macos, outside of nix; android, ios, and web are not supported)
  withDistributedLibs ? !minimal,
  # set this to true if you additionally want to distribute games for aarch64-linux
  # this implies withDistributedLibs = true because it also includes the libraries for other platforms
  withAarch64LinuxDistributedLibs ?
    withDistributedLibs && stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isLinux,
}:

# technically we can support cross-compilation by first compiling a renpy for the build platform besides a renpy for the host platform
# and we can use the former to compile the rpy{,m} files but install the latter to $out
# but let's not bother
assert lib.assertMsg (stdenv.buildPlatform.canExecute stdenv.hostPlatform)
  "Ren'Py cannot be cross-compiled because it needs to run itself during the build phase.";

assert lib.assertMsg (!minimal || !withDistributedLibs && !withAarch64LinuxDistributedLibs)
  "The distributed libraries are only useful when used with the Ren'Py launcher, which is not installed for the minimal Ren'Py package.";

let
  python = python312;
  pythonBuildTime = python312.withPackages (
    ps:
    with ps;
    [
      cython
      setuptools
      pkgconfig

      # the runtime dependencies are also added to compile bundled rpy{,m} files in renpy source tree
      future
      pefile
      requests
      rsa
      six
    ]
    ++ lib.optionals withDoc [
      sphinx
      sphinx-rtd-theme
      sphinx-rtd-dark-mode
    ]
  );
  pythonRunTime = python312.withPackages (
    ps: with ps; [
      future
      pefile
      requests
      rsa
      six
    ]
  );

in
stdenv.mkDerivation (finalAttrs: {
  pname = "renpy";
  version = "8.4.1.25072401";
  # unstable version drops dependency on insecure package ecdsa
  version = "8.5.2.26010301-unstable-2026-03-27";

  src = fetchFromGitHub {
    owner = "renpy";
    repo = "renpy";
    tag = finalAttrs.version;
    hash = "sha256-wJnMqUrRGWcsuZWdqbiUI/BD2sSRjJKEzsCOzSngoZM=";
    rev = "09eb6986ea9e5dbe64c9096ed48a638e593ea0ef";
    hash = "sha256-w7tQbZCH7F0Npu8rD2UADxe/KzsTUdtIhJY6GH4YFAs=";
  };

  __structuredAttrs = true;
  strictDeps = true;

  nativeBuildInputs = [
    makeWrapper
    makeBinaryWrapper
    pkg-config
    python.pkgs.cython
    python.pkgs.setuptools
  ];
    pythonBuildTime
  ]
  ++ lib.optional (!minimal) copyDesktopItems
  ++ lib.optional (stdenv.hostPlatform.isDarwin && !minimal) desktopToDarwinBundle;

  buildInputs = [
    assimp
@@ -50,86 +115,170 @@ stdenv.mkDerivation (finalAttrs: {
    harfbuzz
    libGL
    libGLU
    libpng
    libjpeg
    openssl
    SDL2
    zlib
  ]
  ++ (with python.pkgs; [
    ecdsa
    future
    pefile
    pygame-sdl2
    python
    requests
    six
    tkinter
  ]);

  env = {
    NIX_CFLAGS_COMPILE = "-I${python.pkgs.pygame-sdl2}/include";

    RENPY_DEPS_INSTALL = lib.concatStringsSep "::" (
      [
        ffmpeg.lib
        freetype
        fribidi
        glew.dev
        harfbuzz.dev
        libpng
        SDL2
        (lib.getDev SDL2)
        zlib
      ]
      ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
        libGL
        libGLU
      ]
    );
  };
    SDL2_image
    pythonRunTime
  ];

  enableParallelBuilding = true;

  patches = [
    ./shutup-erofs-errors.patch
  ]
  ++ lib.optional withoutSteam ./noSteam.patch;
    # do not try to compile renpy files installed in nix store because we already compiled them at build phase
    ./dont-compile-system.patch

    # catch error instead of crashing when trying to write steam_appid.txt to nix store
    # https://github.com/renpy/renpy/pull/6976
    ./steam-preinit-catch.patch

    # fix write_target looking for wrong file locations when launcher creates new project
    # https://github.com/renpy/renpy/pull/6978
    ./new-project-prefix.patch

    # the distributed libs are not compatible with renpy built from source,
    # so patch the launcher to look for renpy files in renpy-dist (where bin distribution from upstream is copied to) instead of renpy
    ./distribute.patch
  ];

  postPatch = ''
    # use nix out path instead of `renpy.config.renpy_base` because otherwise we cannot compile them in the build phase
    substituteInPlace renpy/script.py --replace-fail "@systemRenpy@" "$out/share/renpy"

    patchShebangs --build setup.py

    # https://github.com/renpy/renpy/blob/8.5.2.26010301/tutorial/game/01director_support.rpy
    cp tutorial/game/tutorial_director.rpy{m,}

    cat > renpy/vc_version.py << EOF
    version = '${finalAttrs.version}'
    branch = 'master'
    version = '${finalAttrs.passthru.appver}'
    official = False
    nightly = False
    # Look at https://renpy.org/latest.html for what to put.
    version_name = "Tomorrowland"
    version_name = "In Good Health"
    EOF
  '';

  env.PYTHONDONTWRITEBYTECODE = "1";

  buildPhase = ''
    runHook preBuild
    ${python.pythonOnBuildForHost.interpreter} setup.py build --parallel=$NIX_BUILD_CORES

    ./setup.py build_ext --inplace -j $NIX_BUILD_CORES

    # so that these files won't need to be compiled on the host platform
    python -m compileall renpy -q -d renpy -f${lib.optionalString minimal " -b"};

    ${lib.optionalString (!minimal) ''
      # compile bundled rpy{,m} files so that they don't have to be compiled when used on the host platform
      python renpy.py gui compile
      python renpy.py tutorial compile
      python renpy.py the_question compile
    ''}

    # there is no single command to compile all rpym files, so apply a temporary patch for doing that
    patch -p1 -i ${./temp-compile-modules.patch}
    python renpy.py . compile
    patch -p1 -R -i ${./temp-compile-modules.patch}

    ${lib.optionalString (!minimal) "rm -r {tutorial,the_question}/game/saves"}

    ${lib.optionalString withDoc ''
      # https://github.com/renpy/renpy/blob/8.5.2.26010301/sphinx/build.sh
      pushd sphinx
      mkdir -p source/inc
      python ../renpy.py .
      RENPY_NO_FIGURES=1 sphinx-build -E -a source ../doc
      popd
    ''}

    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    ${python.pythonOnBuildForHost.interpreter} setup.py install_lib -d $out/${python.sitePackages}
    mkdir -p $out/share/renpy
    cp -vr sdk-fonts gui launcher renpy the_question tutorial renpy.py $out/share/renpy
    ./setup.py install_lib -d $out/share/renpy
    cp -ar renpy renpy.py $out/share/renpy

    makeWrapper ${lib.getExe pythonRunTime} $out/bin/renpy --add-flags "$out/share/renpy/renpy.py" ${
      # add zenity for file dialogs (https://github.com/renpy/renpy/blob/8.5.2.26010301/src/tinyfiledialogs/tinyfiledialogs.c#L188)
      lib.optionalString (!minimal) "--prefix PATH : ${lib.makeBinPath [ zenity ]}"
    }

    ${lib.optionalString minimal ''
      # delete files not necessary at runtime
      find $out/share/renpy/renpy -type f -regextype posix-egrep -regex '.*\.(py|pyx|pyd|pxd|pyi|pxi|rpy|rpym)$' -delete
    ''}

    ${lib.optionalString (!minimal) ''
      cp -ar sdk-fonts gui launcher the_question tutorial $out/share/renpy

      # most commands (such as `distribute`) are commands of the launcher but not renpy itself
      makeWrapper $out/bin/renpy $out/bin/renpy-launcher --add-flags "$out/share/renpy/launcher"

    makeWrapper ${python.interpreter} $out/bin/renpy \
      --set PYTHONPATH "$PYTHONPATH:$out/${python.sitePackages}" \
      --add-flags "$out/share/renpy/renpy.py"
      mkdir -p $out/share/icons/hicolor/{256x256,32x32}/apps
      ln -s $out/share/renpy/launcher/game/images/window-icon.png $out/share/icons/hicolor/256x256/apps/renpy.png
      ln -s $out/share/renpy/launcher/game/images/logo32.png $out/share/icons/hicolor/32x32/apps/renpy.png
    ''}

    ${lib.optionalString withDoc "cp -ar doc $out/share/renpy"}

    ${lib.optionalString (finalAttrs.passthru.distributedRenpy != null) ''
      # have to use cp instead of symlinkJoin because renpy resolves symlinks to find its base dir
      cp -ar ${finalAttrs.passthru.distributedRenpy}/{update,lib,renpy.sh} $out/share/renpy
      # renpy packaged from source in this nix package is not compatible with the distributed libs
      cp -ar ${finalAttrs.passthru.distributedRenpy}/renpy $out/share/renpy/renpy-dist
    ''}

    runHook postInstall
  '';

  desktopItems = lib.optional (!minimal) (makeDesktopItem {
    name = "renpy";
    desktopName = "Ren'Py";
    comment = finalAttrs.meta.description;
    exec = "renpy-launcher %U";
    icon = "renpy";
    categories = [ "Development" ];
  });

  # keep the files in $out/share/renpy/{renpy-dist,lib,renpy.sh} redistributable
  dontStrip = true;
  dontPatchShebangs = true;
  dontPatchELF = true;
  postFixup = lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
    patchELF $out/share/renpy/renpy
  '';

  nativeInstallCheckInputs = [ versionCheckHook ];
  doInstallCheck = true;
  doInstallCheck = false; # set to true when the version is not unstable

  passthru.updateScript = ./update.sh;
  passthru = {
    appver = lib.head (builtins.match "([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+).*" finalAttrs.version);
    semver = lib.head (builtins.match "([0-9]+\\.[0-9]+\\.[0-9]+).*" finalAttrs.version);

    binSrc = fetchzip {
      url = "https://www.renpy.org/dl/${finalAttrs.passthru.semver}/renpy-${finalAttrs.passthru.semver}-sdk.tar.bz2";
      hash = "sha256-wF6Z/lA8CyaCEZg1IqpZ4mG8CF8JgNHBf5KjKIOoKVI=";
    };

    binSrcArm = fetchzip {
      url = "https://www.renpy.org/dl/${finalAttrs.passthru.semver}/renpy-${finalAttrs.passthru.semver}-sdkarm.tar.bz2";
      hash = "sha256-DKXghs1XIRrtAGTifMx+7XAbxiqH7qYQiaKhBaO7PBA=";
    };

    distributedRenpy =
      if withAarch64LinuxDistributedLibs then
        finalAttrs.passthru.binSrcArm
      else if withDistributedLibs then
        finalAttrs.passthru.binSrc
      else
        null;

    updateScript = ./update.sh;
  };

  meta = {
    description = "Visual Novel Engine";
@@ -138,6 +287,16 @@ stdenv.mkDerivation (finalAttrs: {
    changelog = "https://renpy.org/doc/html/changelog.html";
    license = lib.licenses.mit;
    platforms = lib.platforms.unix;
    maintainers = with lib.maintainers; [ shadowrz ];
    maintainers = with lib.maintainers; [
      shadowrz
      ulysseszhan
    ];
    sourceProvenance =
      with lib.sourceTypes;
      [ fromSource ]
      ++ lib.optionals (finalAttrs.passthru.distributedRenpy != null) [
        binaryNativeCode # bundled python for windows, linux, and macos in the bin distribution from upstream
        binaryBytecode # __pycache__ in the bin distribution from upstream
      ];
  };
})
Loading