Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Append conda tzdata location instead of overriding #1

Open
isuruf opened this issue Oct 28, 2020 · 8 comments
Open

Append conda tzdata location instead of overriding #1

isuruf opened this issue Oct 28, 2020 · 8 comments

Comments

@isuruf
Copy link
Member

isuruf commented Oct 28, 2020

This matches the behaviour of the zoneinfo module in python 3.9

@mbargull
Copy link
Member

conda-forge::python=3.9 builds only use conda-forge::tzdata:

$ python -c 'import sys, sysconfig; print(sys.version, sysconfig.get_config_var("TZPATH"), sep="\n")'
3.9.0 | packaged by conda-forge | (default, Oct 14 2020, 22:59:50) 
[GCC 7.5.0]
/opt/conda/envs/tmp/share/zoneinfo:/opt/conda/envs/tmp/share/tzinfo

@isuruf
Copy link
Member Author

isuruf commented Oct 28, 2020

That isn't intended.

@isuruf
Copy link
Member Author

isuruf commented Oct 28, 2020

Yep, see conda-forge/python-feedstock#403

@mbargull
Copy link
Member

From what you wrote, I assume you don't want https://github.com/conda-forge/python-feedstock/blob/master/recipe/build_base.sh#L239 but only https://github.com/conda-forge/python-feedstock/blob/master/recipe/build_base.sh#L444 ?
However, what is the advantage to have ours looked last? We probably have more up to date information than the system.

@ocefpaf
Copy link
Member

ocefpaf commented Oct 28, 2020

We probably have more up to date information than the system.

Yep. My ubuntu only offers 2020a, we are shipping 2020d.

@dhirschfeld
Copy link
Member

I think it would be surprising for a user to install the latest tzdata but have Python use an older system version in preference to what the user installed.

I was thinking of refactoring the logic to be:

def reset_tzpath(to=None):
    global TZPATH

    tzpaths = to
    if tzpaths is not None:
        if isinstance(tzpaths, (str, bytes)):
            raise TypeError(
                f"tzpaths must be a list or tuple, "
                + f"not {type(tzpaths)}: {tzpaths!r}"
            )

        if not all(map(os.path.isabs, tzpaths)):
            raise ValueError(_get_invalid_paths_message(tzpaths))
        base_tzpath = tzpaths
    else:
        env_var = os.environ.get("PYTHONTZPATH", None)
        if env_var is not None:
            base_tzpath = _parse_python_tzpath(env_var)
        else:
            base_tzpath = [os.path.join(sys.base_prefix, "share", "zoneinfo")]
            if sys.platform != "win32":
                extra_tzpath = [
                    "/usr/share/zoneinfo",
                    "/usr/lib/zoneinfo",
                    "/usr/share/lib/zoneinfo",
                    "/etc/zoneinfo",
                ]
                extra_tzpath = extra_tzpath.sort(
                    key=lambda x: not os.path.exists(x)
                )
                base_tzpath += extra_tzpath

    TZPATH = tuple(base_tzpath)

    if TZPATH_CALLBACKS:
        for callback in TZPATH_CALLBACKS:
            callback(TZPATH)

Thoughts?

@dhirschfeld
Copy link
Member

...but as @ocefpaf mentioned, since tzdata is a dependency none of the others would then ever be chosen because the first entry would always be present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants