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

py-pytest-html: Add version 3.2.0 #38989

Merged
merged 5 commits into from Jul 30, 2023

Conversation

Jordan474
Copy link
Contributor

@Jordan474 Jordan474 commented Jul 19, 2023

Add py-pytest-html 3.2.0.

Add conflict with py-pytest@7.2:, due to conflicting py python modules (see PR comments). A reliable fix should come with py-pytest-html 4 (not released yet).

For the record, here is the errors you'd get with a conflicting py python module:

$ python3 -m pytest --version
[...]
  File "/.../spack/linux-ubuntu22.04-skylake/gcc-11.3.0/py-pytest-html-3.1.1-hhlwraizrwicneboermmg6ft7p37544k/lib/python3.10/site-packages/pytest_html/plugin.py", line 22, in <module>
    from py.xml import html
ModuleNotFoundError: No module named 'py.xml'; 'py' is not a package

Or

$ python3 -m pytest --version
[...]
  File "/.../spack/linux-ubuntu22.04-skylake/gcc-12.1.0/py-pytest-html-3.2.0-gujzhqzf4cjuahf4chqz5dtitohihzn2/lib/python3.10/site-packages/pytest_html/html_report.py", line 11, in <module>
    from py.xml import html
ModuleNotFoundError: No module named 'py.xml'; 'py' is not a package

@Jordan474
Copy link
Contributor Author

EDIT: The conflicts directive did not fix all version combinations, the addition of the py-py dependency seems to work better.

@Jordan474 Jordan474 marked this pull request as ready for review July 19, 2023 12:49
Copy link
Contributor

@tldahlgren tldahlgren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed the version sha256.

@tldahlgren tldahlgren self-assigned this Jul 19, 2023
@adamjstewart adamjstewart self-assigned this Jul 20, 2023
@Jordan474
Copy link
Contributor Author

Jordan474 commented Jul 21, 2023

I think there is something shady going on with dependency ordering.

First, there is a python module name collision between import py as py.py in py-pytest and, import py.xml as py/{xml.py,__init__.py} in py-py. Not great, but if py-py is in PYTHONPATH before pytest, this seems ok.

But then, I don't understand Spack's dependency ordering:

  • sometimes depending on if you add or remove the when in depends_on("py-py@1.8.2:", when="^py-pytest@7.2.0:", type=("build", "run")), you get different PYTHONPATH order, consistently
  • sometimes the order changes between spack install --fresh py-pytest-html and spack install --fresh py-pytest-html ^py-pytest@7.3.2 maybe inconsistently

So I still get the ModuleNotFoundError: No module named 'py.xml'; 'py' is not a package error from time to time, but I cannot find what causes the bad order, or how to control it.

ADDENDUM: I confirm sometimes the install-time test would pass, but then spack load py-pytest-html; pytest -VV would fail again due to py-pytest being load before py-py.

@Jordan474
Copy link
Contributor Author

Jordan474 commented Jul 21, 2023

I didn't expect this fix to go down a rabbit hole...

If there is no way to control PYTHONPATH order, I'm beginning to think it is safer to constrain to pytest@:7.1 pending pytest-html@4.0.0.

Maybe add 4.0.0rc4 as non-preferred ? (4.0.0rc4 not released on pypi yet)

EDIT: 4.0.0rc4 is not released on pypi.

@adamjstewart
Copy link
Member

Oh, that's fun. I think the reason that no one else has complained is that the py.py file that comes with pytest 7.2+ will normally get overridden by the py/__init__.py file that comes with py, assuming that they're installed in the same directory. Since Spack installs them to different directories, we're completely dependent on the order of PYTHONPATH to control which gets used.

I don't think there's going to be a reliable way to control the order of this, especially if you have a root package that depends on all 3 of these packages. So I agree with the decision to pin to pytest 7.1 and older until the pytest-html 4.0 release.

@Jordan474
Copy link
Contributor Author

I added the conflict. I wasn't sure about it until I found the install-test would pass but then spack load would set the faulty PYTHONPATH order:

$ spack install --fresh --test root py-pytest-html ^py-pytest@7.3.2
[... install ok ... test ok ...]

$ ( spack load py-pytest-html/...; pytest -VV )
[...]
ModuleNotFoundError: No module named 'py.xml'; 'py' is not a package

I'll edit the PR description.

@adamjstewart adamjstewart merged commit 048cc71 into spack:develop Jul 30, 2023
13 checks passed
mpokorny pushed a commit to mpokorny/spack that referenced this pull request Sep 18, 2023
* py-pytest-html: add 3.2.0

* py-pytest-html: Add py-py version requirement

See https://github.com/pytest-dev/pytest-html/blob/v3.2.0/setup.py#L16

* py-pytest-html: Add dependencies from setup.py and pyproject.toml

* py-pytest-html: Add git url

* py-pytest-html: Add conflict with py-pytest@7.2: pending py-pytest-html@4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants