Skip to content

TST: Hard to install ipython into local test run with tox-uv #17793

Open

Description

@pllim

Description

As posted by @mhvk

Would this still work?

@mhvk Thanks for pointing this out, I honestly had no idea that someone would use tox to create virtualenvs. The answer is a yes but: uv does not include pip itself in virtualenvs it creates (because it makes it redundant), so if you were to run the exact commands you showed in that order, you'd get stopped at

$ pip install ipython
/Users/clm/dev/astropy-project/coordinated/astropy/.tox/test/bin/python: No module named pip

but that's trivially solved by either:

* typing `uv pip` instead of `pip`

* running the awkward (but functional) command `uv pip install pip` between env activation and any further install

is this satisfactory ?

@neutrinoceros - now that this PR is merged, I noticed that my workflow of

tox -e test --develop --notest
source .tox/test/bin/activate
pip install ipython

is indeed broken (as expected). However, your statement that I could just do uv pip install ipython turns out not to be true, since by default uv is not in the path, so I'm stuck with .tox/.tox/bin/uv pip install ipython, which is quite long. There probably is a clever trick to have this work, but I haven't been able to find it. Any suggestions?

Expected behavior

Shouldn't be this hard.

How to Reproduce

See #16963 (comment)

Versions

N/A

Activity

  1. neutrinoceros commented on Feb 19, 2025

    @neutrinoceros
    Contributor

    I initially thought that tox-uv would integrate with a system-level installed uv. It is clear now that it doesn't. I think this is why my initial response was wrong. Let me try and come up with a new solution for this workflow.

  2. neutrinoceros commented on Feb 19, 2025

    @neutrinoceros
    Contributor

    Further context: @mhvk's original comment was #16963 (comment)

  3. mhvk commented on Feb 19, 2025

    @mhvk
    Contributor

    FWIW, I tried tox ... -x uv_seed=True, which seemed logical but didn't seem to do anything.

  4. neutrinoceros commented on Feb 19, 2025

    @neutrinoceros
    Contributor

    this worked for me

    tox -e test --develop --notest
    source .tox/test/bin/activate
    .tox/.tox/bin/uv pip install pip # new
    python -m pip install ipython

    pip install ipython probably works too but I'm always wary that it might not run within the environment currently activated, so I avoided it.

  5. mhvk commented on Feb 19, 2025

    @mhvk
    Contributor

    Hmm, that increases the line count by one! It is probably easier to add .tox/.tox/bin to my path; it will generally not exist anyway...

  6. pllim commented on Feb 19, 2025

    @pllim
    MemberAuthor

    Do we need to update our dev guide for testing about this?

  7. neutrinoceros commented on Feb 19, 2025

    @neutrinoceros
    Contributor

    I would be -0.9 on promoting this workflow which feels a lot like a hack to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions