Skip to content

py-pytest-html: Add version 3.2.0 - #38989

Merged
adamjstewart merged 5 commits into
spack:developfrom
Jordan474:fix-py-pytest-html
Jul 30, 2023
Merged

adamjstewart merged 5 commits into
spack:developfrom
Jordan474:fix-py-pytest-html

Conversation

@Jordan474

@Jordan474 Jordan474 commented Jul 19, 2023 •

Copy link
Copy Markdown
Contributor

Add py-pytest-html 3.2.0.

Add conflict with [email protected]:, 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
Copy Markdown
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
@Jordan474
Jordan474 force-pushed the fix-py-pytest-html branch from 0a91191 to 7ef4082 Compare July 19, 2023 12:54

@tldahlgren tldahlgren left a comment

Copy link
Copy Markdown
Contributor

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

Jordan474 commented Jul 21, 2023 •

Copy link
Copy Markdown
Contributor Author

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("[email protected]:", when="^[email protected]:", 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 ^[email protected] 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
Jordan474 force-pushed the fix-py-pytest-html branch from 92f55cb to eb67905 Compare July 21, 2023 09:01
@Jordan474
Jordan474 force-pushed the fix-py-pytest-html branch from eb67905 to 9e1effe Compare July 21, 2023 09:02
@Jordan474

Jordan474 commented Jul 21, 2023 •

Copy link
Copy Markdown
Contributor Author

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 [email protected].

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
Copy Markdown
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
Copy Markdown
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 ^[email protected]
[... 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
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 [email protected]: 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.

3 participants