HammerAddons icon indicating copy to clipboard operation
HammerAddons copied to clipboard

Add better support for Wine on Linux

Open some-username-here1 opened this issue 2 years ago • 11 comments

Currently when trying to launch postcompiler.exe through wine, I get a Uncaught Exception error shown through the console.

[E] logger.except_handler(): Uncaught Exception:
Traceback (most recent call last):
  File "srctools\scripts\postcompiler.py", line 25, in <module>
  File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
  File "srctools\compiler\propcombine.py", line 24, in <module>
ModuleNotFoundError: No module named 'srctools._math'
[1012] Failed to execute script 'postcompiler' due to unhandled exception!
03f8:fixme:kernelbase:AppPolicyGetProcessTerminationMethod FFFFFFFA, 0021FEAC

I'm asking for better support since I've been working on a map of mine under Linux, using both Crowbar and Hammer++ through Wine as well. Unless all I would need to do is install python runtime as well. Here is a link to Wine's homepage.

EDIT: This was with the 32-bit version of postcompiler, almost forgot to mention. It works just fine if I were to run the 64-bit version instead.

some-username-here1 avatar Feb 09 '22 19:02 some-username-here1

The postcompiler itself should work fine natively on Linux, I just haven't built an executable - not entirely sure how best to do that sort of thing. What you can do is just install Python 3.9+, pip3 install srctools, then run get Hammer to run python -m srctools.scripts.postcompiler. The only issue is going to be the code that runs studiomdl and Crowbar for models - those probably need to run through WINE. I could add a config / detection there to do that though.

TeamSpen210 avatar Feb 09 '22 22:02 TeamSpen210

Really? there should be separate instructions for Linux then, since I never seen any mention of it in the wiki.

some-username-here1 avatar Feb 09 '22 22:02 some-username-here1

I ran with python, didn't work, but it did work when using python3 instead:

$ python -m srctools.scripts.postcompiler
/usr/bin/python: No module named srctools.scripts
$ python3 -m srctools.scripts.postcompiler
usage: postcompiler.py [-h] [-game GAME_FOLDER] [--nopack] [--propcombine] [--showgroups] [--dumpgroups] map
postcompiler.py: error: the following arguments are required: map

some-username-here1 avatar Feb 09 '22 22:02 some-username-here1

Then you'd want to run it with Hammer, instead of the exe.

TeamSpen210 avatar Feb 09 '22 23:02 TeamSpen210

~~Yeah I know, but I want it working properly outside of hammer (and within wine) first so I can know it's not a hammer issue, but I keep getting errors when trying to run it~~

~~$ WINEPREFIX="/mnt/games_linux/wine_hammer" wine python "-m srctools.scripts.postcompiler"~~ ~~C:\Python27\python.exe: No module named srctools.scripts~~ ~~031c:fixme:msvcrt:__clean_type_info_names_internal (1E2719D0) stub~~

~~$ WINEPREFIX="/mnt/games_linux/wine_hammer" wine python.exe -m "P:/steam/steamapps/common/Team Fortress 2/bin/postcompilersrctools.scripts.postcompiler"~~ ~~C:\Python27\python.exe: Import by filename is not supported.~~ ~~034c:fixme:msvcrt:__clean_type_info_names_internal (1E2719D0) stub~~

~~Even hammer complained about the first error as well, meaning that.~~

~~After installing python 3 manually, I still got an error. This time being C:\Python3\python.exe: Error while finding module specification for 'srctools.scripts.postcompiler' (ModuleNotFoundError: No module named 'srctools.scripts')~~

Turns out, after installing python 3 within the wine prefix, I had to just do pip3 install srctools. Going to test how the postcompiler works now, though

some-username-here1 avatar Feb 10 '22 00:02 some-username-here1

You shouldn't need to install it within wine, just run it natively and get Hammer to do so.

TeamSpen210 avatar Feb 10 '22 00:02 TeamSpen210

I'm not sure how to do that exactly, since I never heard of a program within wine able to run another program outside of wine, unless that's possible?

some-username-here1 avatar Feb 10 '22 00:02 some-username-here1

Looks like you can do it this way.

TeamSpen210 avatar Feb 10 '22 00:02 TeamSpen210

Tried that way, it stopped the compilation right after reaching to the postcompile stage

When running with C:\Python3\python.exe -m srctools.scripts.postcompiler under Commands and -game $gamedir --propcombine $path\$file under Parameters instead, it complained about a "Path not found" error, pointing to C:\\Python3\\Lib\\site-packages\\srctools\\scripts\\transforms

[INFO] postcompiler.main(): HammerAddons postcompiler, srctools=v2.2.5, addons=v(unknown)
[INFO] postcompiler.main(): Map path is n:\source engine\new\maps\mine\bk\trade_treasure_trove_cove_b1.bsp
[INFO] config.parse(): Config path: "n:\source engine\new\maps\mine\bk\srctools.vdf"
[INFO] config.parse(): Game folder: P:\steam\steamapps\common\Team Fortress 2\tf
[DEBUG] config.parse(): Builtin plugin path is C:\Python3\Lib\site-packages\srctools\scripts\transforms
[INFO] postcompiler.main(): Loading plugins...
[ERROR] logger.except_handler(): Uncaught Exception:
Traceback (most recent call last):
  File "C:\Python3\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Python3\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Python3\lib\site-packages\srctools\scripts\postcompiler.py", line 281, in <module>
    main(sys.argv[1:])
  File "C:\Python3\lib\site-packages\srctools\scripts\postcompiler.py", line 97, in main
    plugin.load_all()
  File "C:\Python3\lib\site-packages\srctools\scripts\plugin.py", line 133, in load_all
    for path in paths:
  File "C:\Python3\lib\site-packages\srctools\scripts\plugin.py", line 59, in _iter_folder
    for path in folders.popleft().iterdir():
  File "C:\Python3\lib\pathlib.py", line 1015, in iterdir
    for name in self._accessor.listdir(self):
FileNotFoundError: [WinError 3] Path not found: 'C:\\Python3\\Lib\\site-packages\\srctools\\scripts\\transforms'

some-username-here1 avatar Feb 10 '22 00:02 some-username-here1

Should the folder exist? I didn't find it under my python3 install within my home folder either.

some-username-here1 avatar Feb 10 '22 00:02 some-username-here1

After manually creating the transforms folder, it started working properly up until the postcompiler.propcombiner() section:

[INFO] postcompiler.main(): HammerAddons postcompiler, srctools=v2.2.5, addons=v(unknown)
[INFO] postcompiler.main(): Map path is n:\source engine\new\maps\mine\bk\trade_treasure_trove_cove_b1.bsp
[INFO] config.parse(): Config path: "n:\source engine\new\maps\mine\bk\srctools.vdf"
[INFO] config.parse(): Game folder: P:\steam\steamapps\common\Team Fortress 2\tf
[DEBUG] config.parse(): Builtin plugin path is C:\Python3\Lib\site-packages\srctools\scripts\transforms
[INFO] postcompiler.main(): Loading plugins...
[INFO] postcompiler.main(): Gameinfo: P:\steam\steamapps\common\Team Fortress 2\tf
[INFO] postcompiler.main(): Search paths: 
 | P:\steam\steamapps\common\Team Fortress 2\tf\tf2_textures_dir.vpk
 | P:\steam\steamapps\common\Team Fortress 2\tf\tf2_sound_vo_english_dir.vpk
 | P:\steam\steamapps\common\Team Fortress 2\tf\tf2_sound_misc_dir.vpk
 | P:\steam\steamapps\common\Team Fortress 2\tf\tf2_misc_dir.vpk
 | P:\steam\steamapps\common\Team Fortress 2\hl2\hl2_textures_dir.vpk
 | P:\steam\steamapps\common\Team Fortress 2\hl2\hl2_sound_vo_english_dir.vpk
 | P:\steam\steamapps\common\Team Fortress 2\hl2\hl2_sound_misc_dir.vpk
 | P:\steam\steamapps\common\Team Fortress 2\hl2\hl2_misc_dir.vpk
 | P:\steam\steamapps\common\Team Fortress 2\platform\platform_misc_dir.vpk
 | P:\steam\steamapps\common\Team Fortress 2\tf\custom\compiled
 | P:\steam\steamapps\common\Team Fortress 2\tf\custom\decal_tool
 | P:\steam\steamapps\common\Team Fortress 2\tf\custom\disabled
 | P:\steam\steamapps\common\Team Fortress 2\tf\custom\drastically-improved-tf_english
 | P:\steam\steamapps\common\Team Fortress 2\tf\custom\fixed_engineer_ubercharge
 | P:\steam\steamapps\common\Team Fortress 2\tf\custom\kazotsky-rouxls
 | P:\steam\steamapps\common\Team Fortress 2\tf\custom\map-trade_artisans
 | P:\steam\steamapps\common\Team Fortress 2\tf\custom\map-trade_spiral_mountain
 | P:\steam\steamapps\common\Team Fortress 2\tf\custom\map-trade_treasure_trove_cove
 | P:\steam\steamapps\common\Team Fortress 2\tf\custom\old_backgrounds
 | P:\steam\steamapps\common\Team Fortress 2\tf\custom\old_backgrounds-alt
 | P:\steam\steamapps\common\Team Fortress 2\tf\custom\source_text_refont
 | P:\steam\steamapps\common\Team Fortress 2\tf\custom\tf2_anotherccproject
 | P:\steam\steamapps\common\Team Fortress 2\tf\custom\workshop
 | P:\steam\steamapps\common\Team Fortress 2\tf
 | P:\steam\steamapps\common\Team Fortress 2\tf
 | P:\steam\steamapps\common\Team Fortress 2\tf\bin
 | P:\steam\steamapps\common\Team Fortress 2\hl2
 | P:\steam\steamapps\common\Team Fortress 2\platform
 | P:\steam\steamapps\common\Team Fortress 2\tf\download
 | P:\steam\steamapps\common\Team Fortress 2\hammer
 | P:\steam\steamapps\common\Team Fortress 2\platform
 |___

[INFO] postcompiler.main(): Loading soundscripts...
[INFO] postcompiler.main(): Done! (8374 sounds)
[INFO] postcompiler.main(): Loading particles...
[INFO] postcompiler.main(): Done! (5689 particles)
[DEBUG] postcompiler.main(): Known particles: 
 | particles/error.pcf: preload
 | particles/rockettrail.pcf: preload
 | particles/smoke_blackbillow.pcf: include
 | particles/teleport_status.pcf: preload
 | particles/explosion.pcf: preload
 | particles/player_recent_teleport.pcf: preload
 | particles/rocketjumptrail.pcf: preload
 | particles/rocketbackblast.pcf: preload
 | particles/flamethrower.pcf: preload
 | particles/flamethrower_mvm.pcf: preload
 | particles/burningplayer.pcf: preload
 | particles/blood_impact.pcf: preload
 | particles/blood_trail.pcf: preload
 | particles/muzzle_flash.pcf: preload
 | particles/teleported_fx.pcf: preload
 | particles/cig_smoke.pcf: preload
 | particles/crit.pcf: preload
 | particles/medicgun_beam.pcf: preload
 | particles/bigboom.pcf: preload
 | particles/water.pcf: preload
 | particles/stickybomb.pcf: preload
 | particles/buildingdamage.pcf: preload
 | particles/nailtrails.pcf: preload
 | particles/speechbubbles.pcf: preload
 | particles/bullet_tracers.pcf: preload
 | particles/nemesis.pcf: preload
 | particles/disguise.pcf: preload
 | particles/sparks.pcf: preload
 | particles/flag_particles.pcf: preload
 | particles/shellejection.pcf: preload
 | particles/medicgun_attrib.pcf: preload
 | particles/item_fx.pcf: preload
 | particles/cinefx.pcf: preload
 | particles/impact_fx.pcf: preload
 | particles/conc_stars.pcf: preload
 | particles/class_fx.pcf: preload
 | particles/dirty_explode.pcf: preload
 | particles/smoke_blackbillow_hoodoo.pcf: preload
 | particles/scary_ghost.pcf: preload
 | particles/soldierbuff.pcf: preload
 | particles/level_fx.pcf: include
 | particles/training.pcf: preload
 | particles/stormfront.pcf: preload
 | particles/coin_spin.pcf: preload
 | particles/stamp_spin.pcf: preload
 | particles/rain_custom.pcf: preload
 | particles/npc_fx.pcf: preload
 | particles/drg_cowmangler.pcf: preload
 | particles/drg_bison.pcf: preload
 | particles/dxhr_fx.pcf: preload
 | particles/eyeboss.pcf: preload
 | particles/bombinomicon.pcf: preload
 | particles/harbor_fx.pcf: preload
 | particles/drg_engineer.pcf: preload
 | particles/drg_pyro.pcf: preload
 | particles/xms.pcf: preload
 | particles/mvm.pcf: preload
 | particles/doomsday_fx.pcf: preload
 | particles/halloween.pcf: preload
 | particles/items_demo.pcf: preload
 | particles/items_engineer.pcf: preload
 | particles/bl_killtaunt.pcf: preload
 | particles/urban_fx.pcf: preload
 | particles/killstreak.pcf: preload
 | particles/taunt_fx.pcf: preload
 | particles/rps.pcf: preload
 | particles/firstperson_weapon_fx.pcf: preload
 | particles/powerups.pcf: preload
 | particles/weapon_unusual_isotope.pcf: preload
 | particles/weapon_unusual_hot.pcf: preload
 | particles/weapon_unusual_cool.pcf: preload
 | particles/weapon_unusual_energyorb.pcf: preload
 | particles/passtime.pcf: preload
 | particles/passtime_beam.pcf: preload
 | particles/passtime_tv_projection.pcf: preload
 | particles/vgui_menu_particles.pcf: preload
 | particles/invasion_ray_gun_fx.pcf: preload
 | particles/invasion_unusuals.pcf: preload
 | particles/halloween2015_unusuals.pcf: preload
 | particles/rankup.pcf: preload
 | particles/halloween2016_unusuals.pcf: preload
 | particles/rocketpack.pcf: preload
 | particles/smoke_island_volcano.pcf: preload
 | particles/halloween2018_unusuals.pcf: preload
 | particles/halloween2019_unusuals.pcf: preload
 | particles/smissmas2019_unusuals.pcf: preload
 | particles/summer2020_unusuals.pcf: preload
 | particles/halloween2020_unusuals.pcf: preload
 | particles/smissmas2020_unusuals.pcf: preload
 | particles/summer2021_unusuals.pcf: preload
 | particles/halloween2021_unusuals.pcf: preload
 | particles/smissmas2021_unusuals.pcf: preload
 |___

[INFO] postcompiler.main(): Reading BSP...
[INFO] postcompiler.main(): Reading entities...
[INFO] postcompiler.main(): Done!
[INFO] postcompiler.main(): Mounting BSP packfile...
[INFO] postcompiler.main(): Running transforms...
[INFO] bsp_trans.run_transformations(): Running "Attachment Points"...
[DEBUG] bsp_trans.run_transformations(): Config: Property('Attachment Points', [])
[INFO] bsp_trans.run_transformations(): Running "VScript Init Code"...
[DEBUG] bsp_trans.run_transformations(): Config: Property('VScript Init Code', [])
[INFO] bsp_trans.run_transformations(): Running "VScript RunScript Inputs"...
[DEBUG] bsp_trans.run_transformations(): Config: Property('VScript RunScript Inputs', [])
[INFO] bsp_trans.run_transformations(): Running "func_instance_io_proxy"...
[DEBUG] bsp_trans.run_transformations(): Config: Property('func_instance_io_proxy', [])
[INFO] bsp_trans.run_transformations(): Running "trigger_brush Input Filters"...
[DEBUG] bsp_trans.run_transformations(): Config: Property('trigger_brush Input Filters', [])
[INFO] bsp_trans.run_transformations(): Running "Fix alternate classnames"...
[DEBUG] bsp_trans.run_transformations(): Config: Property('Fix alternate classnames', [])
[INFO] bsp_trans.run_transformations(): Running "Branch Listener UniqueState"...
[DEBUG] bsp_trans.run_transformations(): Config: Property('Branch Listener UniqueState', [])
[INFO] bsp_trans.run_transformations(): Running "Optimise logic_auto"...
[DEBUG] bsp_trans.run_transformations(): Config: Property('Optimise logic_auto', [])
[INFO] bsp_trans.run_transformations(): Running "Strip Entities"...
[DEBUG] bsp_trans.run_transformations(): Config: Property('Strip Entities', [])
[INFO] bsp_trans.run_transformations(): Running "comp_precache_model"...
[DEBUG] bsp_trans.run_transformations(): Config: Property('comp_precache_model', [])
[INFO] bsp_trans.run_transformations(): Running "comp_precache_sound"...
[DEBUG] bsp_trans.run_transformations(): Config: Property('comp_precache_sound', [])
[INFO] bsp_trans.run_transformations(): Running "comp_pack_replace_soundscript"...
[DEBUG] bsp_trans.run_transformations(): Config: Property('comp_pack_replace_soundscript', [])
[INFO] bsp_trans.run_transformations(): Running "comp_pack"...
[DEBUG] bsp_trans.run_transformations(): Config: Property('comp_pack', [])
[INFO] bsp_trans.run_transformations(): Running "comp_pack_rename"...
[DEBUG] bsp_trans.run_transformations(): Config: Property('comp_pack_rename', [])
[INFO] postcompiler.main(): Combining props...
[INFO] propcombine.combine(): Parsing QC files. Paths: 
 | P:\steam\steamapps\common\Team Fortress 2\..\content
 |___

[INFO] propcombine.combine(): Done! 0 prop QCs found.
[INFO] propcombine.combine(): No propcombine groups provided.
[INFO] postcompiler.main(): Done!
[INFO] postcompiler.main(): Analysing packable resources...
[WARNING] packlist.pack_breakable_chunk(): Unknown gib chunks type "WoodChunks"!
[WARNING] packlist.pack_breakable_chunk(): Unknown gib chunks type "WoodChunks"!
[WARNING] packlist.pack_breakable_chunk(): Unknown gib chunks type "WoodChunks"!
[WARNING] packlist.pack_breakable_chunk(): Unknown gib chunks type "GlassChunks"!
[WARNING] packlist.pack_breakable_chunk(): Unknown gib chunks type "WoodChunks"!
[ERROR] logger.except_handler(): Uncaught Exception:
Traceback (most recent call last):
  File "C:\Python3\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Python3\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Python3\lib\site-packages\srctools\scripts\postcompiler.py", line 281, in <module>
    main(sys.argv[1:])
  File "C:\Python3\lib\site-packages\srctools\scripts\postcompiler.py", line 227, in main
    packlist.pack_from_bsp(bsp_file)
  File "C:\Python3\lib\site-packages\srctools\packlist.py", line 760, in pack_from_bsp
    for prop in bsp.props:
  File "C:\Python3\lib\site-packages\srctools\bsp.py", line 1003, in __get__
    result = list(result)  # type: ignore
  File "C:\Python3\lib\site-packages\srctools\bsp.py", line 2334, in _lmp_read_props
    model_name = model_dict[model_ind]
IndexError: list index out of range

some-username-here1 avatar Feb 10 '22 01:02 some-username-here1