Page MenuHomePhabricator

Allow using pywikibot without user-config.py and PYWIKIBOT_NO_USER_CONFIG=1
Closed, ResolvedPublicFeature

Description

Current behavior:

When using pywikibot in an import statement the check for user-config.py is immediately done and throw a runtime error even if pywikibot is never called. It is explained that an Environment variable needs to be set to avoid this behavior.

Set PYWIKIBOT_NO_USER_CONFIG=1 to disable loading user-config.py

Expected behavior:

  • It should be possible to import pywikibot even it no user-config is available.
  • It should be possible to use pywikibot and disable the user-config.py check via API (not via Environment variable!)
  • Reasoning** When deploying a library like https://github.com/WolfgangFahl/py-3rdparty-mediawiki and make it available for the general public that has a choice of using either mwclient or pywikibot as the API channel to MediaWiki it does not make sens to throw an error by pywikibot when people choose mwclient. In fact this makes offering pywikibot as a library impossible in the long run.

Please fix this issue so that py-3rdparty-mediawiki will be able to offer a pywikibot. With the current state of affairs I'd have to remove the pywikibot support for the inconvenience it introduces for users.

Event Timeline

JJMC89 renamed this task from RuntimeError: No user-config.py found to Allow using pywikibot without user-config.py and PYWIKIBOT_NO_USER_CONFIG=1.Dec 18 2020, 7:08 AM
JJMC89 updated the task description. (Show Details)
JJMC89 changed the subtype of this task from "Task" to "Feature Request".

Change 650461 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [IMPR] Allow using pywikibot as site-package without user-config.py

https://gerrit.wikimedia.org/r/650461

New behaviour after this patch:

C:\Users\xqt>python
Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pywikibot
family and mylang are not set.
Defaulting to family='wikipedia' and mylang='test'.
>>> pywikibot.__version__
'5.3.0.dev0'
>>>

looks great. How do i get rid of the "family and mylang ar not set ..." messages?

looks great. How do i get rid of the "family and mylang ar not set ..." messages?

Done in PS2

Curiously the output statement in line 365 does not print the message but the warning in line1131 does if pywikibot is a site-package

Change 650461 merged by jenkins-bot:
[pywikibot/core@master] [IMPR] Allow using pywikibot as site-package without user-config.py

https://gerrit.wikimedia.org/r/650461