Skip to content

Commit

Permalink
Support empty PYTHRANRC
Browse files Browse the repository at this point in the history
This should help reproducible builds.

Related to #2170
  • Loading branch information
serge-sans-paille committed Jan 17, 2024
1 parent 14777c7 commit eb40f87
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions pythran/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,30 +56,37 @@ def get_paths_cfg(
"pythran-default.cfg")

user_config_path = os.environ.get('PYTHRANRC', None)
if not user_config_path:
if user_config_path:
user_config_paths = "user", user_config_path
elif user_config_path is None:
user_config_dir = os.environ.get('XDG_CONFIG_HOME', None)
if not user_config_dir:
user_config_dir = os.environ.get('HOME', None)
if not user_config_dir:
user_config_dir = '~'
user_config_path = os.path.expanduser(
user_config_paths = "user", os.path.expanduser(
os.path.join(user_config_dir, user_file))
return {"sys": sys_config_path,
"platform": platform_config_path,
"user": user_config_path}
else:
user_config_paths = ()

paths = {"sys": sys_config_path,
"platform": platform_config_path}.
paths.update(user_config_paths)


def init_cfg(sys_file, platform_file, user_file, config_args=None):
paths = get_paths_cfg(sys_file, platform_file, user_file)

sys_config_path = paths["sys"]
platform_config_path = paths["platform"]
user_config_path = paths["user"]
user_config_path = paths.get("user")

cfgp = ConfigParser()
for required in (sys_config_path, platform_config_path):
cfgp.read([required])
cfgp.read([user_config_path])

if user_config_path:
cfgp.read([user_config_path])

if config_args is not None:
update_cfg(cfgp, config_args)
Expand Down

0 comments on commit eb40f87

Please sign in to comment.