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

Ability to disable provisioning #1921

Closed
hroncok opened this issue Feb 16, 2021 · 8 comments · Fixed by #1922
Closed

Ability to disable provisioning #1921

hroncok opened this issue Feb 16, 2021 · 8 comments · Fixed by #1922
Labels
feature:new something does not exist yet, but should
Milestone

Comments

@hroncok
Copy link
Contributor

hroncok commented Feb 16, 2021

I was looking into redefining how provisioning works via a plugin. I was not successful, it seems that provisioning happens before any plugin code even runs. I've seen the code in tox and realized that changing it in 3.x would be very tedious.

However, I've also realized, that I don't need to redefine the behavior, all I need is to stop it from happening. Apparently, all I needed to do was to set the TOX_PROVISION=1 environment variable to get this exception:

tox/src/tox/config/__init__.py

Lines 1349 to 1351 in d5957b8

if WITHIN_PROVISION and missing_requirements:
msg = "break infinite loop provisioning within {} missing {}"
raise tox.exception.Error(msg.format(sys.executable, missing_requirements))

Before I start using this as a hack:

  • is this even an API?
  • what are the side effects? I see that WITHIN_PROVISION is used at more places.

Would it be possible to have a documented way to error here, without side effects? I was thinking TOX_NO_PROVISION or even TOX_PROVISION=error. Ideally, the error would print the list of missing dependencies in a way that is easily parseable (with literal_eval is fine).

I can work on this, if this would be accepted. I can also go into details about why I'd like to have this if you want.

@gaborbernat
Copy link
Member

Provisioning is meant to pull in the plugins so having a plugin that alters how you pull in plugins seems very meta. There has been no thought put into this behavior and overriding TOX_PROVISION leaves you in undefined land. Please do tell why though 👍🏻

@hroncok
Copy link
Contributor Author

hroncok commented Feb 16, 2021

In Fedora, we use tox to run the upstream tests when we build the RPM packages. Unlike regular tox users, we don't want to install packages from PyPI to a virtual environment, because we need to test integration with other Fedora packages. We have created a plugin for our needs. More details about the use case are in the README. https://github.com/fedora-python/tox-current-env

  1. We use the plugin to generate a list of requirements.
  2. We install those requirements via Fedora RPM packages.
  3. We use the plugin to run the tests in "current" Python environment.

This all works unless tox determines it needs provision. With provisioning, the situation differs depending on internet availability.

When online:

  1. We use the plugin to generate a list of requirements.
    1. tox creates a provision environment
    2. tox fails, because our plugin is not installed into the provision environment

When offline:

  1. We use the plugin to generate a list of requirements.
    1. tox attempts to creates a provision environment, it fails

What I'd like to do instead:

  1. We use the plugin to generate a list of requirements with TOX_NO_PROVISION (or similar) set
    1. tox figures requires are missing, it errors with the list
    2. we parse the list
    3. we install requirements from the list via Fedora RPM packages
  2. (if needed) We use the plugin to generate a list of requirements again.
  3. We install those requirements via Fedora RPM packages.
  4. We use the plugin to run the tests in "current" Python environment.

@gaborbernat
Copy link
Member

I'll get back to you tomorrow on this, need to have a think about what's good approach here.

@hroncok
Copy link
Contributor Author

hroncok commented Feb 16, 2021

Thanks. I'd also be happy to talk about it over chat or video if you'd prefer.

@gaborbernat
Copy link
Member

Can you join discord.gg/tox?

@gaborbernat
Copy link
Member

@hroncok if you can join Discord now 🙇🏻

@gaborbernat
Copy link
Member

Conclusion:

@hroncok will create a PR against v3 to add a --no-provision flag that when set refuses to perform provisioning and instead raises an exception. That flag takes an optional argument to the path. If the provisioning fails, will write a JSON file to that path with:

{
"minversion": "3.2.1",
"requires": ["PEP-440"]
}

@hroncok
Copy link
Contributor Author

hroncok commented Feb 17, 2021

#1922

@hroncok hroncok mentioned this issue Feb 17, 2021
6 tasks
@gaborbernat gaborbernat added this to the 4.0 milestone Feb 27, 2021
hroncok added a commit to hroncok/tox that referenced this issue Mar 2, 2021
tox can now be invoked with a new --no-provision flag that prevents provision,
if requires or minversion are not satisfied, tox will fail;
if a path is specified as an argument to the flag
(e.g. as `tox --no-provision missing.json`) and provision is prevented,
provision metadata are written as JSON to that path.

Fixes tox-dev#1921
hroncok added a commit to hroncok/tox that referenced this issue Mar 2, 2021
tox can now be invoked with a new --no-provision flag that prevents provision,
if requires or minversion are not satisfied, tox will fail;
if a path is specified as an argument to the flag
(e.g. as `tox --no-provision missing.json`) and provision is prevented,
provision metadata are written as JSON to that path.

Fixes tox-dev#1921
hroncok added a commit to hroncok/tox that referenced this issue Mar 2, 2021
tox can now be invoked with a new --no-provision flag that prevents provision,
if requires or minversion are not satisfied, tox will fail;
if a path is specified as an argument to the flag
(e.g. as `tox --no-provision missing.json`) and provision is prevented,
provision metadata are written as JSON to that path.

Fixes tox-dev#1921
hroncok added a commit to hroncok/tox that referenced this issue Mar 2, 2021
tox can now be invoked with a new --no-provision flag that prevents provision,
if requires or minversion are not satisfied, tox will fail;
if a path is specified as an argument to the flag
(e.g. as `tox --no-provision missing.json`) and provision is prevented,
provision metadata are written as JSON to that path.

Fixes tox-dev#1921
gaborbernat pushed a commit that referenced this issue Mar 3, 2021
tox can now be invoked with a new --no-provision flag that prevents provision,
if requires or minversion are not satisfied, tox will fail;
if a path is specified as an argument to the flag
(e.g. as `tox --no-provision missing.json`) and provision is prevented,
provision metadata are written as JSON to that path.

Fixes #1921
ssbarnea pushed a commit to ssbarnea/tox that referenced this issue Apr 19, 2021
tox can now be invoked with a new --no-provision flag that prevents provision,
if requires or minversion are not satisfied, tox will fail;
if a path is specified as an argument to the flag
(e.g. as `tox --no-provision missing.json`) and provision is prevented,
provision metadata are written as JSON to that path.

Fixes tox-dev#1921
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:new something does not exist yet, but should
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants