Skip to content

wine: pure python generator - #16203

Open
aderumier wants to merge 1 commit into
batocera-linux:masterfrom
aderumier:winegenerator
Open

wine: pure python generator#16203
aderumier wants to merge 1 commit into
batocera-linux:masterfrom
aderumier:winegenerator

Conversation

@aderumier

@aderumier aderumier commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

utils/wine.py holds what every wine system needs: runners and prefixes, building and importing into a prefix, autorun.cmd, saves, and stopping whatever runs in a prefix.

  • the wine generator runs the windows and windows_installers systems itself, building the command and the environment for every rom extension (.wine, .pc, .exe, .wsquashfs, .wtgz) and for the installers (.exe, .msi, .iso).

  • batocera-wine keeps what is a tool rather than a launch: tricks, createprefix, wine2squashfs, wine2winetgz, autorun/-list/-count and stop.

some related PR:

squashfs umount fix (currently it's not waiting that all wine process are closed, so squashfs is not correctly umounted:
#16093

mugen generator (pure python without batocera-wine):
#16094

@aderumier

Copy link
Copy Markdown
Contributor Author

@bryanforbes @crcerror please review :)

@crcerror

crcerror commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

There are some things missing

  • Pipewire hard export
  • Wine detection of games so the autorun.cmd is built per automatic after install
  • Installs to an unique dir because ISO often call the setup file just setup.exe
  • Logging of the file system
  • removed the build of a win32prefix if the runner carries win32 as prefix itself.

I did not check everything but if you want to implent the Python call then go the full mile like I have done here #13542 and check every line and every call twice. This PR was hard work and done without any AI and there was no critical mistake madein the refactor.

It was worth it ... Before it was hard to maintain, after this it was readable, all variables are exposed and gives you now the possibility to reimplement in python

What I see in your PR that you concentrate on archive - files. That is the way to go after you are sure the game works. But from some missing parts In have wrote in the list I assume you did not test yet or you still want to use the batocera-wine as tool subset within the python call?

In the end you will see that python isn't magic and I fear you just change complexity with redundancy.

@aderumier
aderumier force-pushed the winegenerator branch 2 times, most recently from 5003831 to 3941c33 Compare August 8, 2026 23:24
@aderumier

Copy link
Copy Markdown
Contributor Author

are some things missing

  • Pipewire hard export

it's was only with launching the game, but not in installer or other prefix launch. I had fixed it, it's now in every wine execution environment

  • Wine detection of games so the autorun.cmd is built per automatic after install

This one is already working. (tested with .msi, .iso, .exe).

it's done in "def __installed" in winegenerator.py, which is called in "def running", after that the wine process of installer is finished.

(I just pushed a small improvement for .iso installation, with autorun.inf reading to auto exec the setup)

  • Installs to an unique dir because ISO often call the setup file just setup.exe

This one is already implemented too, in

def _installed_name
    return f'{datetime.now():%y%m%d-%H%M%S}_{rom.stem}.wine'

called in

    def __install(self, config: SystemConfig, rom: Path, playersControllers, /) -> Command.Command:
        # the installer builds the game, as a prefix in the roms of the windows system
        runner = self.__prepare(config, rom, prefix=ROMS / _WINDOWS / _installed_name(rom))
  • Logging of the file system

his one was missing. I have added it. (reading /proc/mounts instead calling df , to avoid possible hang of df with nfs/smb mount)

  • removed the build of a win32prefix if the runner carries win32 as prefix itself.

this one is already implemented.

win32 prefix is detected with reading userdef.reg in "def current_prefix_arch".

the old setprefixarch() code is mostly done in wine.py def post_init

I did not check everything but if you want to implent the Python call then go the full mile like I have done here #13542 and check every line and every call twice. This PR was hard work and done without any AI and there was no critical mistake madein the refactor.

It was worth it ... Before it was hard to maintain, after this it was readable, all variables are exposed and gives you now the possibility to reimplement in python

yes, I have see that, nice work !

What I see in your PR that you concentrate on archive - files. That is the way to go after you are sure the game works. But from some missing parts In have wrote in the list I assume you did not test yet or you still want to use the batocera-wine as tool subset within the python call?

I had tested on my side all commands for new batocera-wine python && the generator game start && installer for differents extensions. From python generator, I don't want (and don't do) any call to batocera-wine.
but I have keeped batocera-wine command that user can launch through ssh or through the actions in filemanager (tricks, autorun* auto create, wine2squashfs,...) and stop (in case of hotkey is not working, or user could have overrided .keys with batocera-wine stop)

@aderumier
aderumier force-pushed the winegenerator branch 4 times, most recently from 929dd88 to d02e7d1 Compare August 9, 2026 02:18
@crcerror

crcerror commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

No if the runner is named win32-wine-tkg then it builds the 32 bit prefix reading it from the reg is useless. The prefix HAS to be built BEFORE afterwards it can't be altered.

Please add the default exe-array and the ability to add additional excludes from a file. It looks into 2 places... for autorun-regex.txt reading expressions. Without this every exe is a hit..look also in the shell script there was an array with default otherwise it will detect notepad and internet explorer


1.    /userdata/system/roms/windows_installers/ (primary)
2.    /userdata/saves/windows_installers/ (secondary)

I know this are all things AI isn't available to recognise. So go the full mile and check every call.

I also miss or maybe did overwatch it but what about the installs of reg.keys exe and MSI and fonts per default in the directory?

See that are all things I changed added and so an but also @nadenislamarre should add his comments here. He started the script and everything I did not know why it handles it that way I left unchanged 1:1

@aderumier
aderumier force-pushed the winegenerator branch 3 times, most recently from b493d14 to aa69b8f Compare August 10, 2026 18:16
- utils/wine.py holds what every wine system needs: runners and prefixes,
  building and importing into a prefix, autorun.cmd, saves, the filesystem a
  prefix sits on, and stopping whatever runs in a prefix.

- the wine generator runs the games of any system itself, windows and
  windows_installers as much as mugen, each keeping its prefixes under
  wine-bottles/<system>/<runner>/. It builds the command and the environment
  for every rom extension (.wine, .pc, .exe, .wsquashfs, .wtgz) and for the
  installers (.exe, .msi, .iso). An installation image is run through the
  installer its autorun.inf names, and only opens its drive in the file
  manager when it names none.

- batocera-wine keeps what is a tool rather than a launch: tricks,
  createprefix, wine2squashfs, wine2winetgz, autorun/-list/-count and stop.
@aderumier

aderumier commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

No if the runner is named win32-wine-tkg then it builds the 32 bit prefix reading it from the reg is useless. The prefix HAS to be built BEFORE afterwards it can't be altered.

Well, it's already currently handled

it's creating a 32bit prefix when runner is named win32-xxx or enable_win32 option is enable when prefix don't exist,
or read the .reg to find the current arch.

I have rewritten a little bit the code with more logs to match old batocera-wine, and move the check in Runner class postinit.

Please add the default exe-array and the ability to add additional excludes from a file. It looks into 2 places... for autorun-regex.txt reading expressions


1.    /userdata/system/roms/windows_installers/ (primary)
2.    /userdata/saves/windows_installers/ (secondary)

I know this are all things AI isn't available to recognise. So go the full mile and check every call.

t's already handled too, in utils/wine.py

_AUTORUN_REGEX_FILES: Final = (
    ROMS / 'windows_installers' / 'autorun-regex.txt',
    SAVES / 'windows_installers' / 'autorun-regex.txt',
)

. Without this every exe is a hit..look also in the shell script there was an array with default otherwise it will detect notepad and internet explorer

same, in utils/wine.py

_NOT_THE_GAME: Final = (
    re.compile(r'/Windows Media Player/'),
    re.compile(r'/Windows NT/'),
    re.compile(r'/Internet Explorer/'),
    re.compile(r'/drive_c/windows/'),
    re.compile(r'/unins[a-z0-9]{0,6}\.exe$', re.IGNORECASE),
    re.compile(r'/install(..)?\.exe$', re.IGNORECASE),
    re.compile(r'/setup\.exe$', re.IGNORECASE),
    re.compile(r'/unwise(..)?\.exe$', re.IGNORECASE),
)

I also miss or maybe did overwatch it but what about the installs of reg.keys exe and MSI and fonts per default in the directory?

yes, like in old batocera-wine in play_* o install_*

    def __setup_prefix(self, config: SystemConfig, runner: wine.Runner, /) -> None:
        """What a prefix is given before the game runs, whether it is new or not."""
        runner.install_redists()
        runner.install_msis()
        runner.install_rawinput() 
        runner.install_regs()
        runner.install_fonts()
        runner.sandbox_prefix()

See that are all things I changed added and so an but also @nadenislamarre should add his comments here. He started the script and everything I did not know why it handles it that way I left unchanged 1:1

I have tested all the features manually for now, but I'm currently writting unit tests to be sure that no case is forgotten.

@crcerror

Copy link
Copy Markdown
Contributor

Hope it will work. Let others review now.

One critics: use more destinct comments that nails the case.

It is better readable and maintainable now? I have doubts but if everything is tested and works then proceed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants