Page MenuHomePhabricator

pwb.py user-config.py search path incorrect
Closed, DuplicatePublic

Description

The search path was:

PYWIKIBOT2_DIR, (pwb directory)

and is now

PYWIKIBOT2_DIR, ., ~/.pywikibot,

(changed in https://github.com/wikimedia/pywikibot-core/commit/3a1ba465c74af95e52e5312f5c5dd5f2c43c3e8b#diff-439f77fba033e329e68235a823736fc3R162)

which is the same if we are in the pwb directory, but not if this is not the case! This is e.g. often the case with jsub commands such as

jsub python /data/project/some/path/pwb.py scriptname

which is expected to use the user-config in /data/project/some/path, not the user-config in /data/project/.pywikibot/

The search order should probably be adapted to PYWIKIBOT2_DIR, ., pwb dir, ~/.pywikibot.


Version: core-(2.0)
Severity: normal
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=72680

Details

Reference
bz72918

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 4:00 AM
bzimport set Reference to bz72918.

It's not about the cwd, but about the directory-pwb.py-is-in!

https://github.com/wikimedia/pywikibot-core/commit/3a1ba465c74af95e52e5312f5c5dd5f2c43c3e8b#diff-f15f62388b2fa48d5a3f9f09dbafceffL146

-if "PYWIKIBOT2_DIR" not in os.environ:

  • os.environ["PYWIKIBOT2_DIR"] = os.path.split(file)[0]

^ that explicitly set PYWIKIBOT2_DIR to the pwb.py dir if it was not set before.

Now the logic is in config2.py.
os.path.split(file)[0] => /home/user/python/core/pywikibot

How it it supposed to know where pwb.py is?
Is it safe enough to assume assume ../pywikibot?

Indeed duplicate.

We can either pass the pwb.py location to config2.py somehow (environment variable, maybe some global variable? not sure), or just use '..', which should be fine in most cases. Maybe we should check whether there actually is a pwb.py in that directory to be sure we're not installed.

  • This bug has been marked as a duplicate of bug 72680 ***