SFTtech / openage

Free (as in freedom) open source clone of the Age of Empires II engine 🚀
http://openage.dev
Other
12.69k stars 1.12k forks source link

Entering AOE2 install path manually: "No valid existing directory" #778

Closed Birch-san closed 7 years ago

Birch-san commented 7 years ago
INFO [py] Will save to 'b'/Users/birch/git/openage/assets''
  Should we call wine to determine an AOE installation? [Y/n]
> n
Could not find any installation directory automatically.
Please enter an AOE2 install path manually.
> /Users/anon/Documents/age2hd/attempt2 
WARN [py] No valid existing directory: /Users/anon/Documents/age2hd/attempt2

This is actually a valid directory. Look what happens if I add a trailing slash:

Please enter an AOE2 install path manually.
> /Users/anon/Documents/age2hd/attempt2/
converting from '/Users/anon/Documents/age2hd/attempt2'
INFO [py] Game version(s) detected:
INFO [py]  * Age of Empires 2: HD + African Kingdoms (Version 4.7+)
INFO [py]  * Age of Empires 2: The Conquerors, Patch 1.0c
INFO [py]  * Age of Empires 2: Forgotten Empires
INFO [py]  * Age of Empires 2: HD Edition (Version 3.0+)
INFO [py]  * Age of Empires 2: HD + Forgotten Empires (Version 4.0+)
INFO [py] converting metadata
INFO [py] [0] palette
INFO [py] [1] empires.dat
INFO [py] [2] blendomatic.dat
INFO [py] [3] player color palette
INFO [py] [4] terminal color palette
INFO [py] [5] string resources

Here's the part of the code that seems to get confused:

https://github.com/SFTtech/openage/blob/master/openage/convert/main.py#L303

        if Path(sourcedir).is_dir():
            return sourcedir
        else:
            warn("No valid existing directory: {}".format(sourcedir))

I wonder why it doesn't understand that that Path is a directory (unless you add a trailing slash).

TheJJ commented 7 years ago

Did you play around a bit to figure out the problem? On my machine it makes no difference for the call Path("some_folder").is_dir() if some_folder has a trailing slash?

Birch-san commented 7 years ago

I revisited this again today and can no longer reproduce the problem.

I deleted asset_version to attempt a re-conversion of assets, and it went just fine (even though I omitted the trailing slash).

I did a more specific test, and this worked fine too

➜  ~ python3
Python 3.6.1 (default, Mar 23 2017, 16:49:06) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from pathlib import Path
>>> Path("/Users/anon/Documents/age2hd/attempt2").is_dir()
True
>>> Path("/Users/anon/Documents/age2hd/attempt2/").is_dir()
True

Maybe it's a dependency version thing? I think at some point whilst working on openage, I upgraded from Python 3.5 to 3.6 (and also reinstalled dependencies).

Python 3.5 is still on my machine. So I tried there, yet I was unable to reproduce the problem.

Thus the most likely candidate is pathlib. Maybe I once had an old version?

TheJJ commented 7 years ago

Unlikely that pathlib is the problem, it's a standard library module and I didn't ready any bugreports about that lately. But who knows :)