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

Update noxutil.py #359

Merged
merged 1 commit into from
Sep 26, 2022
Merged

Update noxutil.py #359

merged 1 commit into from
Sep 26, 2022

Conversation

mforbes
Copy link
Contributor

@mforbes mforbes commented Sep 4, 2022

Add python parameter to get_version() allowing one to limit versions based on the python version.

This allows one to parse multiple requirements like

Sphinx = [
  {version = ">=3.4.2,<6.0.0", python = "<3.9"},
  {version = ">=3.4.2,!=3.5.*,!=4.0.*,!=4.1.*,<6.0.0", python = ">=3.10"}
]

Add `python` parameter to `get_version()` allowing one to limit versions based on the python version.
@CLAassistant
Copy link

CLAassistant commented Sep 4, 2022

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot commented Sep 15, 2022

Codecov Report

Merging #359 (d2b4ce8) into master (fa69083) will decrease coverage by 0.02%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #359      +/-   ##
==========================================
- Coverage   77.48%   77.46%   -0.03%     
==========================================
  Files          92       92              
  Lines       14633    14633              
  Branches     3274     3274              
==========================================
- Hits        11338    11335       -3     
- Misses       2853     2854       +1     
- Partials      442      444       +2     
Flag Coverage Δ
3.10 77.45% <ø> (-0.02%) ⬇️
3.11.0-alpha 46.92% <ø> (-30.13%) ⬇️
3.7 45.75% <ø> (-30.84%) ⬇️
3.8 46.91% <ø> (-30.08%) ⬇️
3.9 46.91% <ø> (ø)
Linux 77.02% <ø> (ø)
Windows 46.90% <ø> (-30.11%) ⬇️
macOS 77.43% <ø> (ø)
pypy-3.9 77.02% <ø> (ø)
regression-3.10 75.87% <ø> (-0.02%) ⬇️
regression-3.11 ?
regression-3.7 ?
regression-3.8 ?
regression-pypy3 75.42% <ø> (ø)
unit-3.10 46.91% <ø> (ø)
unit-3.11 46.92% <ø> (ø)
unit-3.7 45.75% <ø> (ø)
unit-3.8 46.91% <ø> (ø)
unit-3.9 46.91% <ø> (ø)
unit-pypy3 46.93% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/rinoh/style.py 84.95% <0.00%> (-0.27%) ⬇️
src/rinoh/table.py 93.30% <0.00%> (-0.24%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@brechtm
Copy link
Owner

brechtm commented Sep 15, 2022

Thanks @mforbes!

It's not obvious to me how this can be used. Do you happen to have an example noxfile.py where this is used? I suspect I may be able to use it here:

@nox_poetry.session(python='3.9') # Sphinx >3.5 fail on 3.10

@brechtm
Copy link
Owner

brechtm commented Sep 15, 2022

My first test: get_versions('sphinx', 'minor', python='x.y') always returns the same list of Sphinx versions, regardless of x and y.

EDIT: Ah, now I see that the python version corresponds to the python version specified for the dependency in my pyproject.toml.

@mforbes
Copy link
Contributor Author

mforbes commented Sep 15, 2022

Sorry, yes, an example noxfile.py would probably have been useful. I am doing something like this, since there does not seem to be a better way of determining the python version at the time that the decorator is called. It is a bit ugly:

sys.path.append(".")
from noxutils import get_versions

python_versions = ["3.6", "3.7", "3.8", "3.9", "3.10"]
@session(reuse_venv=True)
@nox.parametrize("python,sphinx",
                 sum([[(python, sphinx)
                       for sphinx in get_versions("sphinx", "minor", python=python)]
                      for python in python_versions],
                     []),
                 )
def test(session, sphinx):
    # nox_poetry uses the info in poetry.lock but you need to specify the test
    # dependencies here:
    session.install("sphinx-testing", "pytest-cov", ".")
    # Override sphinx, but using get_versions() makes sure this is consistent
    session.run("pip", "install", f"sphinx=={sphinx}")
    session.run("pytest")

I am a bit confused: your example get_versions('sphinx', 'minor', python='x.y') should work. What was going wrong?

@brechtm
Copy link
Owner

brechtm commented Sep 26, 2022

Thanks! I was able to get closer to get it working once I realized that I needed to set python-version dependent Sphinx requirements in my pyproject.toml (as you suggested in your original comment). I needed to upgrade Poetry because I ran into an issue with it generating an invalid version constraint (I forgot the details, unfortunately), but now I'm running into python-poetry/poetry-plugin-export#118, so I'll first need to fix that before I can start using this.

@brechtm brechtm merged commit cc77265 into brechtm:master Sep 26, 2022
@brechtm
Copy link
Owner

brechtm commented Sep 26, 2022

Merged. Many thanks for taking the time to make this PR!

brechtm added a commit that referenced this pull request Aug 25, 2023
Only use Python 3.9 if the Sphinx version requires it.

This requires setting the Python version requirement for Sphinx in
our pyproject.toml (see #359).
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

Successfully merging this pull request may close these issues.

3 participants