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

pytest-benchmark: AttributeError: module 'py' has no attribute 'io' #10420

Closed
4 tasks done
ocelotl opened this issue Oct 25, 2022 · 5 comments
Closed
4 tasks done

pytest-benchmark: AttributeError: module 'py' has no attribute 'io' #10420

ocelotl opened this issue Oct 25, 2022 · 5 comments

Comments

@ocelotl
Copy link

ocelotl commented Oct 25, 2022

When I run test cases with 7.2.0 I get this error:

py39-opentelemetry-sdk installed: asgiref==3.5.2,attrs==22.1.0,Deprecated==1.2.13,exceptiongroup==1.0.0rc9,flaky==3.7.0,iniconfig==1.1.1,opentelemetry-api @ file:///home/ocelotl/github/ocelotl/opentelemetry-python/opentelemetry-api,opentelemetry-sdk @ file:///home/ocelotl/github/ocelotl/opentelemetry-python/opentelemetry-sdk,opentelemetry-semantic-conventions @ file:///home/ocelotl/github/ocelotl/opentelemetry-python/opentelemetry-semantic-conventions,opentelemetry-test-utils @ file:///home/ocelotl/github/ocelotl/opentelemetry-python/tests/opentelemetry-test-utils,packaging==21.3,pluggy==1.0.0,py-cpuinfo==8.0.0,pyparsing==3.0.9,pytest==7.2.0,pytest-benchmark==3.4.1,tomli==2.0.1,typing_extensions==4.4.0,wrapt==1.14.1
	py39-opentelemetry-sdk run-test-pre: PYTHONHASHSEED='2761085170'
	py39-opentelemetry-sdk run-test-pre: commands[0] | python -m pip install -U pip setuptools wheel
	Requirement already satisfied: pip in /home/ocelotl/github/ocelotl/opentelemetry-python/.tox/py39-opentelemetry-sdk/lib/python3.9/site-packages (22.3)
	Requirement already satisfied: setuptools in /home/ocelotl/github/ocelotl/opentelemetry-python/.tox/py39-opentelemetry-sdk/lib/python3.9/site-packages (65.5.0)
	Requirement already satisfied: wheel in /home/ocelotl/github/ocelotl/opentelemetry-python/.tox/py39-opentelemetry-sdk/lib/python3.9/site-packages (0.37.1)
	py39-opentelemetry-sdk run-test-pre: commands[1] | pip install /home/ocelotl/github/ocelotl/opentelemetry-python/opentelemetry-api /home/ocelotl/github/ocelotl/opentelemetry-python/opentelemetry-semantic-conventions /home/ocelotl/github/ocelotl/opentelemetry-python/opentelemetry-sdk /home/ocelotl/github/ocelotl/opentelemetry-python/tests/opentelemetry-test-utils
	Processing /home/ocelotl/github/ocelotl/opentelemetry-python/opentelemetry-api
	  Installing build dependencies: started
	  Installing build dependencies: finished with status 'done'
	  Getting requirements to build wheel: started
	  Getting requirements to build wheel: finished with status 'done'
	  Preparing metadata (pyproject.toml): started
	  Preparing metadata (pyproject.toml): finished with status 'done'
	Processing /home/ocelotl/github/ocelotl/opentelemetry-python/opentelemetry-semantic-conventions
	  Installing build dependencies: started
	  Installing build dependencies: finished with status 'done'
	  Getting requirements to build wheel: started
	  Getting requirements to build wheel: finished with status 'done'
	  Preparing metadata (pyproject.toml): started
	  Preparing metadata (pyproject.toml): finished with status 'done'
	Processing /home/ocelotl/github/ocelotl/opentelemetry-python/opentelemetry-sdk
	  Installing build dependencies: started
	  Installing build dependencies: finished with status 'done'
	  Getting requirements to build wheel: started
	  Getting requirements to build wheel: finished with status 'done'
	  Preparing metadata (pyproject.toml): started
	  Preparing metadata (pyproject.toml): finished with status 'done'
	Processing /home/ocelotl/github/ocelotl/opentelemetry-python/tests/opentelemetry-test-utils
	  Installing build dependencies: started
	  Installing build dependencies: finished with status 'done'
	  Getting requirements to build wheel: started
	  Getting requirements to build wheel: finished with status 'done'
	  Preparing metadata (pyproject.toml): started
	  Preparing metadata (pyproject.toml): finished with status 'done'
	Requirement already satisfied: deprecated>=1.2.6 in /home/ocelotl/github/ocelotl/opentelemetry-python/.tox/py39-opentelemetry-sdk/lib/python3.9/site-packages (from opentelemetry-api==1.13.0) (1.2.13)
	Requirement already satisfied: setuptools>=16.0 in /home/ocelotl/github/ocelotl/opentelemetry-python/.tox/py39-opentelemetry-sdk/lib/python3.9/site-packages (from opentelemetry-api==1.13.0) (65.5.0)
	Requirement already satisfied: typing-extensions>=3.7.4 in /home/ocelotl/github/ocelotl/opentelemetry-python/.tox/py39-opentelemetry-sdk/lib/python3.9/site-packages (from opentelemetry-sdk==1.13.0) (4.4.0)
	Requirement already satisfied: asgiref~=3.0 in /home/ocelotl/github/ocelotl/opentelemetry-python/.tox/py39-opentelemetry-sdk/lib/python3.9/site-packages (from opentelemetry-test-utils==0.34b0) (3.5.2)
	Requirement already satisfied: wrapt<2,>=1.10 in /home/ocelotl/github/ocelotl/opentelemetry-python/.tox/py39-opentelemetry-sdk/lib/python3.9/site-packages (from deprecated>=1.2.6->opentelemetry-api==1.13.0) (1.14.1)
	Building wheels for collected packages: opentelemetry-api, opentelemetry-semantic-conventions, opentelemetry-sdk, opentelemetry-test-utils
	  Building wheel for opentelemetry-api (pyproject.toml): started
	  Building wheel for opentelemetry-api (pyproject.toml): finished with status 'done'
	  Created wheel for opentelemetry-api: filename=opentelemetry_api-1.13.0-py3-none-any.whl size=50942 sha256=1901355eef56579ac74db918b4516c56279224c44c0e60e649dc64d9ef7e5c74
	  Stored in directory: /home/ocelotl/.cache/pip/wheels/97/52/38/b1470cb7b99810c0c536deaefbdc2d57a319b66391941669bd
	  Building wheel for opentelemetry-semantic-conventions (pyproject.toml): started
	  Building wheel for opentelemetry-semantic-conventions (pyproject.toml): finished with status 'done'
	  Created wheel for opentelemetry-semantic-conventions: filename=opentelemetry_semantic_conventions-0.34b0-py3-none-any.whl size=26484 sha256=f7173b52a2b82a26871000ad66a7fc4d924bd442bedc7cda7d8000483944437a
	  Stored in directory: /home/ocelotl/.cache/pip/wheels/5e/7b/ea/74985dc81f953e9718c69a2c03d6df36160c9f44c066ce2d36
	  Building wheel for opentelemetry-sdk (pyproject.toml): started
	  Building wheel for opentelemetry-sdk (pyproject.toml): finished with status 'done'
	  Created wheel for opentelemetry-sdk: filename=opentelemetry_sdk-1.13.0-py3-none-any.whl size=91031 sha256=b954e4be9c945ddeb0917d5ef5e1e552c5d456f5ec95b59232dfdb0041c385ea
	  Stored in directory: /home/ocelotl/.cache/pip/wheels/9b/98/37/769fc9cbe6ef9ca97cc67b7b9e050f4c0d4a976fbae98f1764
	  Building wheel for opentelemetry-test-utils (pyproject.toml): started
	  Building wheel for opentelemetry-test-utils (pyproject.toml): finished with status 'done'
	  Created wheel for opentelemetry-test-utils: filename=opentelemetry_test_utils-0.34b0-py3-none-any.whl size=12326 sha256=22a289670a4d4f9ebce121ec0646b0f9e5f0baf7ba5da37d62afa36ed1cb3f20
	  Stored in directory: /home/ocelotl/.cache/pip/wheels/4b/ff/aa/2c99f8acc78fb2eb8b563c2f005c4ec54692fec47266c2ceeb
	Successfully built opentelemetry-api opentelemetry-semantic-conventions opentelemetry-sdk opentelemetry-test-utils
	Installing collected packages: opentelemetry-semantic-conventions, opentelemetry-api, opentelemetry-sdk, opentelemetry-test-utils
	  Attempting uninstall: opentelemetry-semantic-conventions
	    Found existing installation: opentelemetry-semantic-conventions 0.34b0
	    Uninstalling opentelemetry-semantic-conventions-0.34b0:
	      Successfully uninstalled opentelemetry-semantic-conventions-0.34b0
	  Attempting uninstall: opentelemetry-api
	    Found existing installation: opentelemetry-api 1.13.0
	    Uninstalling opentelemetry-api-1.13.0:
	      Successfully uninstalled opentelemetry-api-1.13.0
	  Attempting uninstall: opentelemetry-sdk
	    Found existing installation: opentelemetry-sdk 1.13.0
	    Uninstalling opentelemetry-sdk-1.13.0:
	      Successfully uninstalled opentelemetry-sdk-1.13.0
	  Attempting uninstall: opentelemetry-test-utils
	    Found existing installation: opentelemetry-test-utils 0.34b0
	    Uninstalling opentelemetry-test-utils-0.34b0:
	      Successfully uninstalled opentelemetry-test-utils-0.34b0
	Successfully installed opentelemetry-api-1.13.0 opentelemetry-sdk-1.13.0 opentelemetry-semantic-conventions-0.34b0 opentelemetry-test-utils-0.34b0
	py39-opentelemetry-sdk run-test: commands[0] | pytest metrics
	INTERNALERROR> Traceback (most recent call last):
	INTERNALERROR>   File "/home/ocelotl/github/ocelotl/opentelemetry-python/.tox/py39-opentelemetry-sdk/lib/python3.9/site-packages/_pytest/main.py", line 266, in wrap_session
	INTERNALERROR>     config._do_configure()
	INTERNALERROR>   File "/home/ocelotl/github/ocelotl/opentelemetry-python/.tox/py39-opentelemetry-sdk/lib/python3.9/site-packages/_pytest/config/__init__.py", line 1037, in _do_configure
	INTERNALERROR>     self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
	INTERNALERROR>   File "/home/ocelotl/github/ocelotl/opentelemetry-python/.tox/py39-opentelemetry-sdk/lib/python3.9/site-packages/pluggy/_hooks.py", line 277, in call_historic
	INTERNALERROR>     res = self._hookexec(self.name, self.get_hookimpls(), kwargs, False)
	INTERNALERROR>   File "/home/ocelotl/github/ocelotl/opentelemetry-python/.tox/py39-opentelemetry-sdk/lib/python3.9/site-packages/pluggy/_manager.py", line 80, in _hookexec
	INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
	INTERNALERROR>   File "/home/ocelotl/github/ocelotl/opentelemetry-python/.tox/py39-opentelemetry-sdk/lib/python3.9/site-packages/pluggy/_callers.py", line 60, in _multicall
	INTERNALERROR>     return outcome.get_result()
	INTERNALERROR>   File "/home/ocelotl/github/ocelotl/opentelemetry-python/.tox/py39-opentelemetry-sdk/lib/python3.9/site-packages/pluggy/_result.py", line 60, in get_result
	INTERNALERROR>     raise ex[1].with_traceback(ex[2])
	INTERNALERROR>   File "/home/ocelotl/github/ocelotl/opentelemetry-python/.tox/py39-opentelemetry-sdk/lib/python3.9/site-packages/pluggy/_callers.py", line 39, in _multicall
	INTERNALERROR>     res = hook_impl.function(*args)
	INTERNALERROR>   File "/home/ocelotl/github/ocelotl/opentelemetry-python/.tox/py39-opentelemetry-sdk/lib/python3.9/site-packages/pytest_benchmark/plugin.py", line 440, in pytest_configure
	INTERNALERROR>     bs = config._benchmarksession = BenchmarkSession(config)
	INTERNALERROR>   File "/home/ocelotl/github/ocelotl/opentelemetry-python/.tox/py39-opentelemetry-sdk/lib/python3.9/site-packages/pytest_benchmark/session.py", line 38, in __init__
	INTERNALERROR>     self.logger = Logger(level, config=config)
	INTERNALERROR>   File "/home/ocelotl/github/ocelotl/opentelemetry-python/.tox/py39-opentelemetry-sdk/lib/python3.9/site-packages/pytest_benchmark/logger.py", line 20, in __init__
	INTERNALERROR>     self.term = py.io.TerminalWriter(file=sys.stderr)
	INTERNALERROR> AttributeError: module 'py' has no attribute 'io'
	ERROR: InvocationError for command /home/ocelotl/github/ocelotl/opentelemetry-python/.tox/py39-opentelemetry-sdk/bin/pytest metrics (exited with code 3)
	___________________________________ summary ____________________________________
	ERROR:   py39-opentelemetry-sdk: commands failed

When I do the same thing with pytest 7.1.3 tests pass.

Output of pip list when the error happens:

Package                            Version
---------------------------------- --------
asgiref                            3.5.2
attrs                              22.1.0
Deprecated                         1.2.13
exceptiongroup                     1.0.0rc9
flaky                              3.7.0
iniconfig                          1.1.1
opentelemetry-api                  1.13.0
opentelemetry-sdk                  1.13.0
opentelemetry-semantic-conventions 0.34b0
opentelemetry-test-utils           0.34b0
packaging                          21.3
pip                                22.3
pluggy                             1.0.0
py-cpuinfo                         8.0.0
pyparsing                          3.0.9
pytest                             7.2.0
pytest-benchmark                   3.4.1
setuptools                         65.5.0
tomli                              2.0.1
typing_extensions                  4.4.0
wheel                              0.37.1
wrapt                              1.14.1

Output of `pip list when the error does not happen:

Package                            Version
---------------------------------- -------
asgiref                            3.5.2
attrs                              22.1.0
Deprecated                         1.2.13
flaky                              3.7.0
iniconfig                          1.1.1
opentelemetry-api                  1.13.0
opentelemetry-sdk                  1.13.0
opentelemetry-semantic-conventions 0.34b0
opentelemetry-test-utils           0.34b0
packaging                          21.3
pip                                22.3
pluggy                             1.0.0
py                                 1.11.0
py-cpuinfo                         8.0.0
pyparsing                          3.0.9
pytest                             7.1.3
pytest-benchmark                   3.4.1
setuptools                         65.5.0
tomli                              2.0.1
typing_extensions                  4.4.0
wheel                              0.37.1
wrapt                              1.14.1

Output of lsb_release -a:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:        22.04
Codename:       jammy

Minimal example:

Clone opentelemetry-python, run tox -e py39-opentelemetry-sdk -- opentelemetry-sdk/tests/metrics/

By the way, thanks for all your work, Pytest is a cornerstone of our project!

  • a detailed description of the bug or problem you are having
  • output of pip list from the virtual environment you are using
  • pytest and operating system versions
  • minimal example if possible
@b3n3w
Copy link

b3n3w commented Oct 25, 2022

Experiencing the same issue with the latest version of pytest 7.2.0 on different distributions.

@The-Compiler
Copy link
Member

@ocelotl This is a bug in pytest-benchmark, due to it depending on py without declaring it as a dependency. The shim we introduced in pytest (#10396) intentionally only incudes py.path and py.error.

Looks like this has been fixed in pytest-benchmark already: ionelmc/pytest-benchmark#226 - so once a new release with that is out, it should work again.

@b3n3w Hard to say more without more details, but it's also very unlikely that you're seeing an issue in pytest. Check the traceback and the files involved to see the project responsible.

@The-Compiler The-Compiler closed this as not planned Won't fix, can't repro, duplicate, stale Oct 25, 2022
@The-Compiler The-Compiler changed the title AttributeError: module 'py' has no attribute 'io' pytest-benchmark: AttributeError: module 'py' has no attribute 'io' Oct 25, 2022
@The-Compiler The-Compiler pinned this issue Oct 25, 2022
@The-Compiler
Copy link
Member

Pinning this for a while for visibility, as we had a duplicate opened already...

@asottile
Copy link
Member

note also you can work around by installing py separately

darosior added a commit to darosior/coincurve that referenced this issue Oct 25, 2022
darosior added a commit to darosior/coincurve that referenced this issue Oct 25, 2022
ofek added a commit to ofek/coincurve that referenced this issue Oct 26, 2022
* ci: temporary fixup for pytest-benchmark bug

See pytest-dev/pytest#10420

* ci: upgrade mkdocs to fix jinja2 API break

* Update tox.ini

* fixed

Co-authored-by: Ofek Lev <ofekmeister@gmail.com>
github-actions bot pushed a commit to ofek/coincurve that referenced this issue Oct 26, 2022
* ci: temporary fixup for pytest-benchmark bug

See pytest-dev/pytest#10420

* ci: upgrade mkdocs to fix jinja2 API break

* Update tox.ini

* fixed

Co-authored-by: Ofek Lev <ofekmeister@gmail.com> 8a2c89d
gadomski added a commit to stac-utils/pystac-client that referenced this issue Nov 15, 2022
Required to picked up ionelmc/pytest-benchmark#227 to get pytest 7.2.0 working.
Thanks to pytest-dev/pytest#10420 for pointing the right way.
gadomski added a commit to stac-utils/pystac-client that referenced this issue Nov 15, 2022
)

* build(deps-dev): update pytest requirement from ~=7.1.3 to ~=7.2.0

Updates the requirements on [pytest](https://github.com/pytest-dev/pytest) to permit the latest version.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst)
- [Commits](pytest-dev/pytest@7.1.3...7.2.0)

---
updated-dependencies:
- dependency-name: pytest
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>

* deps, dev: bump pytest-benchmark to 4.0.0

Required to picked up ionelmc/pytest-benchmark#227 to get pytest 7.2.0 working.
Thanks to pytest-dev/pytest#10420 for pointing the right way.

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Pete Gadomski <pete.gadomski@gmail.com>
mblackgeo added a commit to mblackgeo/fast-alphashape that referenced this issue Nov 23, 2022
This is a bug introduced by pytest-benchmark
pytest-dev/pytest#10420
NickCrews added a commit to NickCrews/splink that referenced this issue Jan 24, 2023
Before, I couldn't run `poetry update` because
there would be dependency conflicts, since
pyarrow 7.0.0 requires python >3.7.

In addition, there was a bug
pytest-dev/pytest#10420
in pytest-benchmark <4.0 that was giving me errors when I had python>3.6
so I upgraded that when
we have python >3.7.
But pytest-benchmark 4 isn't compatible with python3.6, so I had
to split the deps into two different cases.

I tweaked the min python version from 3.6 to 3.6.2
because some packages were incompatible with
3.6.0 to 3.6.2, so it was easier to
require just a slightly higher python

Note that although now poetry is happy to
solve dependencies for python 3.6,
python 3.6 still doesn't actually work
due to the `from __future__ import annotations`
in linker.py. But this has a been a problem for months and we
just seem to be ignoring the
[failing 3.6 tests in CI](https://github.com/moj-analytical-services/splink/actions/workflows/pytest_36_compatibility.yml)

Whatever though, at least this unblocks me so now I can actually develop
splink. I think the next step is to actually remove 3.6
support, since 3.6 reached
end of life in Dec 2021. Separate PR for that though.
NickCrews added a commit to NickCrews/splink that referenced this issue Jan 27, 2023
In addition, there was a bug
pytest-dev/pytest#10420
in pytest-benchmark <4.0,
so I also updated that. Now tests pass!
@RonnyPfannschmidt RonnyPfannschmidt unpinned this issue Mar 1, 2023
@RonnyPfannschmidt RonnyPfannschmidt pinned this issue Mar 1, 2023
@nicoddemus nicoddemus unpinned this issue Apr 13, 2023
@Jokendo-collab
Copy link

I solved the issue buy reinstalling vcfstats using pip3.9 install vcfstats by excluding -U

florentLutz added a commit to florentLutz/StdAtm that referenced this issue Jun 2, 2023
Rearranged the package to match the standards for poetry 1.4.2, left `pytest-profiling`, `snakeviz` and `pytest-benchmark` in dev.dependencies. Also had to force the version of pytest to something below 7.2.0 or else `py` is not installed which makes `pytest-benchmark` fail since it is required but not a dependenct (see pytest-dev/pytest#10420)
arwedus added a commit to arwedus/pymarkdown that referenced this issue Jul 13, 2023
- Version constraints relaxed by setting >=
- Separate production package dependencies from development environemnt dependencies in Pipfile
- Add missing dependency on py, introduced by a dependency declaration error in
  a package used by pytest, see:

  pytest-dev/pytest#10420

Issue-Id: jackdewinter#708
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

No branches or pull requests

5 participants