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

Add Python version support #1239

Merged
merged 2 commits into from
Feb 4, 2024
Merged

Add Python version support #1239

merged 2 commits into from
Feb 4, 2024

Conversation

charliermarsh
Copy link
Member

Closes #1221.

@charliermarsh charliermarsh added the documentation Improvements or additions to documentation label Feb 2, 2024
@charliermarsh charliermarsh enabled auto-merge (squash) February 4, 2024 21:54
@charliermarsh charliermarsh merged commit 0e35041 into main Feb 4, 2024
22 checks passed
@charliermarsh charliermarsh deleted the charlie/py branch February 4, 2024 21:56
jherland added a commit to tweag/FawltyDeps that referenced this pull request May 7, 2024
Upgrade Nox to (at least) 2024.03.02 (which is the first version with
support for managing virtualenvs with uv.

Add uv as an indirect dependency by depending on "nox[uv]" instead of
"nox" (exception: inside the "lint" dependency group, we only depend on
"nox" in order for Mypy to access Nox' type annotations, uv is not
needed here).

Also we cannot use/depend on uv when using Python 3.7, since uv requires
Python >=v3.8. I'm not actually sure _why_ uv requires >=v3.8, as it is
apparently able to create venvs for Python v3.7 (see e.g.
https://github.com/astral-sh/uv?tab=readme-ov-file#python-discovery),
still astral-sh/uv#1239 prevents uv from being
installed on <=v3.7).

Finally, in noxfile.py, use uv as our default venv_backend instead of
the default (pip), but only when it is in fact available.

A final complication on Nix(OS) happens when we install requirements for
the current session; we do this in two steps, and then we make sure that
whatever we installed was patched appropriately:

    session.install("-r", str(requirments_txt))
    if include_self:
        session.install("-e", ".")

    if not session.virtualenv._reused:  # noqa: SLF001
        patch_binaries_if_needed(session, session.virtualenv.location)

However, with uv in the mix, we have to consider that session.install()
itself _runs_ uv at the same time as the first session.install() may
also _install_ uv itself into the virtualenv. The second
session.install() can then end up _running_ a uv that was _installed_
by the first session.install(), and this will break on Nix(OS) unless
the uv binary has been patched in the meantime.

We therefore need to insert a call to patch_binaries_if_needed()
_between_ the two session.install() calls. Since the second
session.install() only installs FawltyDeps itself (which does not
introduce any binaries to be patched), we can get away with simply
reordering the second session.install() and the call to
patch_binaries_if_needed():

    session.install("-r", str(requirments_txt))

    if not session.virtualenv._reused:  # noqa: SLF001
        patch_binaries_if_needed(session, session.virtualenv.location)

    if include_self:
        session.install("-e", ".")
jherland added a commit to tweag/FawltyDeps that referenced this pull request May 22, 2024
Upgrade Nox to (at least) 2024.03.02 (which is the first version with
support for managing virtualenvs with uv.

Add uv as an indirect dependency by depending on "nox[uv]" instead of
"nox" (exception: inside the "lint" dependency group, we only depend on
"nox" in order for Mypy to access Nox' type annotations, uv is not
needed here).

Also we cannot use/depend on uv when using Python 3.7, since uv requires
Python >=v3.8. I'm not actually sure _why_ uv requires >=v3.8, as it is
apparently able to create venvs for Python v3.7 (see e.g.
https://github.com/astral-sh/uv?tab=readme-ov-file#python-discovery),
still astral-sh/uv#1239 prevents uv from being
installed on <=v3.7).

Finally, in noxfile.py, use uv as our default venv_backend instead of
the default (pip), but only when it is in fact available.

A final complication on Nix(OS) happens when we install requirements for
the current session; we do this in two steps, and then we make sure that
whatever we installed was patched appropriately:

    session.install("-r", str(requirments_txt))
    if include_self:
        session.install("-e", ".")

    if not session.virtualenv._reused:  # noqa: SLF001
        patch_binaries_if_needed(session, session.virtualenv.location)

However, with uv in the mix, we have to consider that session.install()
itself _runs_ uv at the same time as the first session.install() may
also _install_ uv itself into the virtualenv. The second
session.install() can then end up _running_ a uv that was _installed_
by the first session.install(), and this will break on Nix(OS) unless
the uv binary has been patched in the meantime.

We therefore need to insert a call to patch_binaries_if_needed()
_between_ the two session.install() calls. Since the second
session.install() only installs FawltyDeps itself (which does not
introduce any binaries to be patched), we can get away with simply
reordering the second session.install() and the call to
patch_binaries_if_needed():

    session.install("-r", str(requirments_txt))

    if not session.virtualenv._reused:  # noqa: SLF001
        patch_binaries_if_needed(session, session.virtualenv.location)

    if include_self:
        session.install("-e", ".")
jherland added a commit to tweag/FawltyDeps that referenced this pull request Jun 12, 2024
Upgrade Nox to (at least) 2024.03.02 (which is the first version with
support for managing virtualenvs with uv.

Add uv as an indirect dependency by depending on "nox[uv]" instead of
"nox" (exception: inside the "lint" dependency group, we only depend on
"nox" in order for Mypy to access Nox' type annotations, uv is not
needed here).

Also we cannot use/depend on uv when using Python 3.7, since uv requires
Python >=v3.8. I'm not actually sure _why_ uv requires >=v3.8, as it is
apparently able to create venvs for Python v3.7 (see e.g.
https://github.com/astral-sh/uv?tab=readme-ov-file#python-discovery),
still astral-sh/uv#1239 prevents uv from being
installed on <=v3.7).

Finally, in noxfile.py, use uv as our default venv_backend instead of
the default (pip), but only when it is in fact available.

A final complication on Nix(OS) happens when we install requirements for
the current session; we do this in two steps, and then we make sure that
whatever we installed was patched appropriately:

    session.install("-r", str(requirments_txt))
    if include_self:
        session.install("-e", ".")

    if not session.virtualenv._reused:  # noqa: SLF001
        patch_binaries_if_needed(session, session.virtualenv.location)

However, with uv in the mix, we have to consider that session.install()
itself _runs_ uv at the same time as the first session.install() may
also _install_ uv itself into the virtualenv. The second
session.install() can then end up _running_ a uv that was _installed_
by the first session.install(), and this will break on Nix(OS) unless
the uv binary has been patched in the meantime.

We therefore need to insert a call to patch_binaries_if_needed()
_between_ the two session.install() calls. Since the second
session.install() only installs FawltyDeps itself (which does not
introduce any binaries to be patched), we can get away with simply
reordering the second session.install() and the call to
patch_binaries_if_needed():

    session.install("-r", str(requirments_txt))

    if not session.virtualenv._reused:  # noqa: SLF001
        patch_binaries_if_needed(session, session.virtualenv.location)

    if include_self:
        session.install("-e", ".")
jherland added a commit to tweag/FawltyDeps that referenced this pull request Jul 9, 2024
Upgrade Nox to (at least) 2024.03.02 (which is the first version with
support for managing virtualenvs with uv.

Add uv as an indirect dependency by depending on "nox[uv]" instead of
"nox" (exception: inside the "lint" dependency group, we only depend on
"nox" in order for Mypy to access Nox' type annotations, uv is not
needed here).

Also we cannot use/depend on uv when using Python 3.7, since uv requires
Python >=v3.8. I'm not actually sure _why_ uv requires >=v3.8, as it is
apparently able to create venvs for Python v3.7 (see e.g.
https://github.com/astral-sh/uv?tab=readme-ov-file#python-discovery),
still astral-sh/uv#1239 prevents uv from being
installed on <=v3.7).

Finally, in noxfile.py, use uv as our default venv_backend instead of
the default (pip), but only when it is in fact available.

A final complication on Nix(OS) happens when we install requirements for
the current session; we do this in two steps, and then we make sure that
whatever we installed was patched appropriately:

    session.install("-r", str(requirments_txt))
    if include_self:
        session.install("-e", ".")

    if not session.virtualenv._reused:  # noqa: SLF001
        patch_binaries_if_needed(session, session.virtualenv.location)

However, with uv in the mix, we have to consider that session.install()
itself _runs_ uv at the same time as the first session.install() may
also _install_ uv itself into the virtualenv. The second
session.install() can then end up _running_ a uv that was _installed_
by the first session.install(), and this will break on Nix(OS) unless
the uv binary has been patched in the meantime.

We therefore need to insert a call to patch_binaries_if_needed()
_between_ the two session.install() calls. Since the second
session.install() only installs FawltyDeps itself (which does not
introduce any binaries to be patched), we can get away with simply
reordering the second session.install() and the call to
patch_binaries_if_needed():

    session.install("-r", str(requirments_txt))

    if not session.virtualenv._reused:  # noqa: SLF001
        patch_binaries_if_needed(session, session.virtualenv.location)

    if include_self:
        session.install("-e", ".")
jherland added a commit to tweag/FawltyDeps that referenced this pull request Jul 23, 2024
Upgrade Nox to (at least) 2024.03.02 (which is the first version with
support for managing virtualenvs with uv.

Add uv as an indirect dependency by depending on "nox[uv]" instead of
"nox" (exception: inside the "lint" dependency group, we only depend on
"nox" in order for Mypy to access Nox' type annotations, uv is not
needed here).

Also we cannot use/depend on uv when using Python 3.7, since uv requires
Python >=v3.8. I'm not actually sure _why_ uv requires >=v3.8, as it is
apparently able to create venvs for Python v3.7 (see e.g.
https://github.com/astral-sh/uv?tab=readme-ov-file#python-discovery),
still astral-sh/uv#1239 prevents uv from being
installed on <=v3.7).

Finally, in noxfile.py, use uv as our default venv_backend instead of
the default (pip), but only when it is in fact available.

A final complication on Nix(OS) happens when we install requirements for
the current session; we do this in two steps, and then we make sure that
whatever we installed was patched appropriately:

    session.install("-r", str(requirments_txt))
    if include_self:
        session.install("-e", ".")

    if not session.virtualenv._reused:  # noqa: SLF001
        patch_binaries_if_needed(session, session.virtualenv.location)

However, with uv in the mix, we have to consider that session.install()
itself _runs_ uv at the same time as the first session.install() may
also _install_ uv itself into the virtualenv. The second
session.install() can then end up _running_ a uv that was _installed_
by the first session.install(), and this will break on Nix(OS) unless
the uv binary has been patched in the meantime.

We therefore need to insert a call to patch_binaries_if_needed()
_between_ the two session.install() calls. Since the second
session.install() only installs FawltyDeps itself (which does not
introduce any binaries to be patched), we can get away with simply
reordering the second session.install() and the call to
patch_binaries_if_needed():

    session.install("-r", str(requirments_txt))

    if not session.virtualenv._reused:  # noqa: SLF001
        patch_binaries_if_needed(session, session.virtualenv.location)

    if include_self:
        session.install("-e", ".")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document minimum supported python version
2 participants