Skip to content

Tox environment is re-created each time one alternates between the black and lint environment if using Tox 4 #9782

@garrison

Description

@garrison

Environment

  • Qiskit Terra version: main
  • Python version: n/a
  • Operating system: Linux

What is happening?

If one uses tox4, the environment is recreated each time one switches from the black to lint environment, or vice versa.

$ tox -eblack
black: recreate env because env type changed from {'name': 'lint', 'type': 'VirtualEnvRunner'} to {'name': 'black', 'type': 'VirtualEnvRunner'}
black: remove tox env folder .tox/lint
black: install_deps> pip install -c/home/garrison/Qiskit/qiskit-terra/constraints.txt -U setuptools_rust -r /home/garrison/Qiskit/qiskit-terra/requirements.txt -r /home/garrison/Qiskit/qiskit-terra/requirements-dev.txt
[...]
$ tox -elint
lint: recreate env because env type changed from {'name': 'black', 'type': 'VirtualEnvRunner'} to {'name': 'lint', 'type': 'VirtualEnvRunner'}
lint: remove tox env folder .tox/lint
lint: install_deps> pip install -c/home/garrison/Qiskit/qiskit-terra/constraints.txt -U setuptools_rust -r /home/garrison/Qiskit/qiskit-terra/requirements.txt -r /home/garrison/Qiskit/qiskit-terra/requirements-dev.txt
[...]

How can we reproduce the issue?

See above

What should happen?

Environment should not be re-created

Any suggestions?

Several options of how to fix this:

  1. Do not set both environments to the same envdir in tox.ini
  2. Work around this using generative section names, in the way I did at Fix {black,lint} environment re-creation on tox4 qiskit-community/quantum-prototype-template#28. (I have not tested this since the issue I flagged in that PR was supposedly fixed in tox4.)
  3. @pedrorrivero has used tox-ignore-env-name-mismatch in recent projects (e.g., pyproject-qiskit, staged-primitives) to deal with this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions