Closed kloczek closed 1 year ago
After add --import-mode=importlib
to pyetst params:
Hmmm looks lik i code are used relaive imports which forces exact location of the modiles.
[tkloczko@pers-jacek greenlet-2.0.2]$ grep -rE "from \.|import \."
src/greenlet/__init__.py:from ._greenlet import _C_API # pylint:disable=no-name-in-module
src/greenlet/__init__.py:from ._greenlet import GreenletExit
src/greenlet/__init__.py:from ._greenlet import error
src/greenlet/__init__.py:from ._greenlet import getcurrent
src/greenlet/__init__.py:from ._greenlet import greenlet
src/greenlet/__init__.py: from ._greenlet import gettrace
src/greenlet/__init__.py: from ._greenlet import settrace
src/greenlet/__init__.py:from ._greenlet import GREENLET_USE_CONTEXT_VARS # pylint:disable=unused-import
src/greenlet/__init__.py:from ._greenlet import GREENLET_USE_GC # pylint:disable=unused-import
src/greenlet/__init__.py:from ._greenlet import GREENLET_USE_TRACING # pylint:disable=unused-import
src/greenlet/__init__.py:from ._greenlet import CLOCKS_PER_SEC # pylint:disable=unused-import
src/greenlet/__init__.py:from ._greenlet import enable_optional_cleanup # pylint:disable=unused-import
src/greenlet/__init__.py:from ._greenlet import get_clocks_used_doing_optional_cleanup # pylint:disable=unused-import
src/greenlet/tests/__init__.py:from . import leakcheck
src/greenlet/tests/test_contextvars.py:from . import TestCase
src/greenlet/tests/test_cpp.py:from . import _test_extension_cpp
src/greenlet/tests/test_cpp.py:from . import TestCase
src/greenlet/tests/test_extension_interface.py:from . import _test_extension
src/greenlet/tests/test_extension_interface.py:from . import TestCase
src/greenlet/tests/test_gc.py:from . import TestCase
src/greenlet/tests/test_gc.py:from .leakcheck import fails_leakcheck
src/greenlet/tests/test_generator.py:from . import TestCase
src/greenlet/tests/test_generator_nested.py:from . import TestCase
src/greenlet/tests/test_generator_nested.py:from .leakcheck import fails_leakcheck
src/greenlet/tests/test_greenlet.py:from . import TestCase
src/greenlet/tests/test_greenlet.py:from .leakcheck import fails_leakcheck
src/greenlet/tests/test_leaks.py:from . import TestCase
src/greenlet/tests/test_leaks.py:from .leakcheck import fails_leakcheck
src/greenlet/tests/test_leaks.py:from .leakcheck import ignores_leakcheck
src/greenlet/tests/test_leaks.py:from .leakcheck import RUNNING_ON_GITHUB_ACTIONS
src/greenlet/tests/test_leaks.py:from .leakcheck import RUNNING_ON_MANYLINUX
src/greenlet/tests/test_stack_saved.py:from . import TestCase
src/greenlet/tests/test_throw.py:from . import TestCase
src/greenlet/tests/test_tracing.py:from . import TestCase
src/greenlet/tests/test_weakref.py:from . import TestCase
build/lib.linux-x86_64-cpython-38/greenlet/__init__.py:from ._greenlet import _C_API # pylint:disable=no-name-in-module
build/lib.linux-x86_64-cpython-38/greenlet/__init__.py:from ._greenlet import GreenletExit
build/lib.linux-x86_64-cpython-38/greenlet/__init__.py:from ._greenlet import error
build/lib.linux-x86_64-cpython-38/greenlet/__init__.py:from ._greenlet import getcurrent
build/lib.linux-x86_64-cpython-38/greenlet/__init__.py:from ._greenlet import greenlet
build/lib.linux-x86_64-cpython-38/greenlet/__init__.py: from ._greenlet import gettrace
build/lib.linux-x86_64-cpython-38/greenlet/__init__.py: from ._greenlet import settrace
build/lib.linux-x86_64-cpython-38/greenlet/__init__.py:from ._greenlet import GREENLET_USE_CONTEXT_VARS # pylint:disable=unused-import
build/lib.linux-x86_64-cpython-38/greenlet/__init__.py:from ._greenlet import GREENLET_USE_GC # pylint:disable=unused-import
build/lib.linux-x86_64-cpython-38/greenlet/__init__.py:from ._greenlet import GREENLET_USE_TRACING # pylint:disable=unused-import
build/lib.linux-x86_64-cpython-38/greenlet/__init__.py:from ._greenlet import CLOCKS_PER_SEC # pylint:disable=unused-import
build/lib.linux-x86_64-cpython-38/greenlet/__init__.py:from ._greenlet import enable_optional_cleanup # pylint:disable=unused-import
build/lib.linux-x86_64-cpython-38/greenlet/__init__.py:from ._greenlet import get_clocks_used_doing_optional_cleanup # pylint:disable=unused-import
build/lib.linux-x86_64-cpython-38/greenlet/tests/__init__.py:from . import leakcheck
build/lib.linux-x86_64-cpython-38/greenlet/tests/test_contextvars.py:from . import TestCase
build/lib.linux-x86_64-cpython-38/greenlet/tests/test_cpp.py:from . import _test_extension_cpp
build/lib.linux-x86_64-cpython-38/greenlet/tests/test_cpp.py:from . import TestCase
build/lib.linux-x86_64-cpython-38/greenlet/tests/test_extension_interface.py:from . import _test_extension
build/lib.linux-x86_64-cpython-38/greenlet/tests/test_extension_interface.py:from . import TestCase
build/lib.linux-x86_64-cpython-38/greenlet/tests/test_gc.py:from . import TestCase
build/lib.linux-x86_64-cpython-38/greenlet/tests/test_gc.py:from .leakcheck import fails_leakcheck
build/lib.linux-x86_64-cpython-38/greenlet/tests/test_generator.py:from . import TestCase
build/lib.linux-x86_64-cpython-38/greenlet/tests/test_generator_nested.py:from . import TestCase
build/lib.linux-x86_64-cpython-38/greenlet/tests/test_generator_nested.py:from .leakcheck import fails_leakcheck
build/lib.linux-x86_64-cpython-38/greenlet/tests/test_greenlet.py:from . import TestCase
build/lib.linux-x86_64-cpython-38/greenlet/tests/test_greenlet.py:from .leakcheck import fails_leakcheck
build/lib.linux-x86_64-cpython-38/greenlet/tests/test_leaks.py:from . import TestCase
build/lib.linux-x86_64-cpython-38/greenlet/tests/test_leaks.py:from .leakcheck import fails_leakcheck
build/lib.linux-x86_64-cpython-38/greenlet/tests/test_leaks.py:from .leakcheck import ignores_leakcheck
build/lib.linux-x86_64-cpython-38/greenlet/tests/test_leaks.py:from .leakcheck import RUNNING_ON_GITHUB_ACTIONS
build/lib.linux-x86_64-cpython-38/greenlet/tests/test_leaks.py:from .leakcheck import RUNNING_ON_MANYLINUX
build/lib.linux-x86_64-cpython-38/greenlet/tests/test_stack_saved.py:from . import TestCase
build/lib.linux-x86_64-cpython-38/greenlet/tests/test_throw.py:from . import TestCase
build/lib.linux-x86_64-cpython-38/greenlet/tests/test_tracing.py:from . import TestCase
build/lib.linux-x86_64-cpython-38/greenlet/tests/test_weakref.py:from . import TestCase
Unisg relative imports is always askig for troubles.
BTW looks like test suite s ot excluded from .whl archive
IMO better would be move greenlet/tests/ to tests/ bacuse that location by defaiult is excluded from to be used to form whl archove content. That needs to be done with remove relative imports. With those two changes compbined it should work as expected.
This project does not use pytest.
This project does not use pytest.
Because now is not possible to use pytest using "test as installed" procedure because those relative imports.
Even unittest
is not working
+ cd greenlet-2.0.2
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-greenlet-2.0.2-2.fc35.x86_64/usr/lib64/python3.8/site-packages
+ /usr/bin/python3 -m unittest discover -v greenlet.tests
Traceback (most recent call last):
File "/usr/lib64/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib64/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/usr/lib64/python3.8/unittest/__main__.py", line 18, in <module>
main(module=None)
File "/usr/lib64/python3.8/unittest/main.py", line 100, in __init__
self.parseArgs(argv)
File "/usr/lib64/python3.8/unittest/main.py", line 124, in parseArgs
self._do_discovery(argv[2:])
File "/usr/lib64/python3.8/unittest/main.py", line 244, in _do_discovery
self.createTests(from_discovery=True, Loader=Loader)
File "/usr/lib64/python3.8/unittest/main.py", line 154, in createTests
self.test = loader.discover(self.start, self.pattern, self.top)
File "/usr/lib64/python3.8/unittest/loader.py", line 346, in discover
raise ImportError('Start directory is not importable: %r' % start_dir)
ImportError: Start directory is not importable: 'greenlet.tests'
Crrecrly implemented unittest
test suite works OOTB with pytest.
Here is exctly the same error messages with unittest
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-greenlet-2.0.2-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-greenlet-2.0.2-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network' --import-mode=importlib
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.8.16, pytest-7.2.1, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/greenlet-2.0.2
collected 2 items / 12 errors
========================================================================================== ERRORS ===========================================================================================
__________________________________________________________________ ERROR collecting src/greenlet/tests/test_contextvars.py __________________________________________________________________
ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/greenlet-2.0.2/src/greenlet/tests/test_contextvars.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
src/greenlet/tests/test_contextvars.py:12: in <module>
from . import TestCase
E ModuleNotFoundError: No module named 'src'
______________________________________________________________________ ERROR collecting src/greenlet/tests/test_cpp.py ______________________________________________________________________
ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/greenlet-2.0.2/src/greenlet/tests/test_cpp.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
src/greenlet/tests/test_cpp.py:8: in <module>
from . import _test_extension_cpp
E ModuleNotFoundError: No module named 'src'
______________________________________________________________ ERROR collecting src/greenlet/tests/test_extension_interface.py ______________________________________________________________
ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/greenlet-2.0.2/src/greenlet/tests/test_extension_interface.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
src/greenlet/tests/test_extension_interface.py:7: in <module>
from . import _test_extension
E ModuleNotFoundError: No module named 'src'
______________________________________________________________________ ERROR collecting src/greenlet/tests/test_gc.py _______________________________________________________________________
ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/greenlet-2.0.2/src/greenlet/tests/test_gc.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
src/greenlet/tests/test_gc.py:8: in <module>
from . import TestCase
E ModuleNotFoundError: No module named 'src'
___________________________________________________________________ ERROR collecting src/greenlet/tests/test_generator.py ___________________________________________________________________
ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/greenlet-2.0.2/src/greenlet/tests/test_generator.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
src/greenlet/tests/test_generator.py:4: in <module>
from . import TestCase
E ModuleNotFoundError: No module named 'src'
_______________________________________________________________ ERROR collecting src/greenlet/tests/test_generator_nested.py ________________________________________________________________
ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/greenlet-2.0.2/src/greenlet/tests/test_generator_nested.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
src/greenlet/tests/test_generator_nested.py:3: in <module>
from . import TestCase
E ModuleNotFoundError: No module named 'src'
___________________________________________________________________ ERROR collecting src/greenlet/tests/test_greenlet.py ____________________________________________________________________
ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/greenlet-2.0.2/src/greenlet/tests/test_greenlet.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
src/greenlet/tests/test_greenlet.py:13: in <module>
from . import TestCase
E ModuleNotFoundError: No module named 'src'
_____________________________________________________________________ ERROR collecting src/greenlet/tests/test_leaks.py _____________________________________________________________________
ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/greenlet-2.0.2/src/greenlet/tests/test_leaks.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
src/greenlet/tests/test_leaks.py:17: in <module>
from . import TestCase
E ImportError: cannot import name 'TestCase' from 'src.greenlet.tests' (unknown location)
__________________________________________________________________ ERROR collecting src/greenlet/tests/test_stack_saved.py __________________________________________________________________
ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/greenlet-2.0.2/src/greenlet/tests/test_stack_saved.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
src/greenlet/tests/test_stack_saved.py:2: in <module>
from . import TestCase
E ImportError: cannot import name 'TestCase' from 'src.greenlet.tests' (unknown location)
_____________________________________________________________________ ERROR collecting src/greenlet/tests/test_throw.py _____________________________________________________________________
ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/greenlet-2.0.2/src/greenlet/tests/test_throw.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
src/greenlet/tests/test_throw.py:5: in <module>
from . import TestCase
E ImportError: cannot import name 'TestCase' from 'src.greenlet.tests' (unknown location)
____________________________________________________________________ ERROR collecting src/greenlet/tests/test_tracing.py ____________________________________________________________________
ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/greenlet-2.0.2/src/greenlet/tests/test_tracing.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
src/greenlet/tests/test_tracing.py:5: in <module>
from . import TestCase
E ImportError: cannot import name 'TestCase' from 'src.greenlet.tests' (unknown location)
____________________________________________________________________ ERROR collecting src/greenlet/tests/test_weakref.py ____________________________________________________________________
ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/greenlet-2.0.2/src/greenlet/tests/test_weakref.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
src/greenlet/tests/test_weakref.py:6: in <module>
from . import TestCase
E ImportError: cannot import name 'TestCase' from 'src.greenlet.tests' (unknown location)
================================================================================== short test summary info ==================================================================================
ERROR src/greenlet/tests/test_contextvars.py
ERROR src/greenlet/tests/test_cpp.py
ERROR src/greenlet/tests/test_extension_interface.py
ERROR src/greenlet/tests/test_gc.py
ERROR src/greenlet/tests/test_generator.py
ERROR src/greenlet/tests/test_generator_nested.py
ERROR src/greenlet/tests/test_greenlet.py
ERROR src/greenlet/tests/test_leaks.py
ERROR src/greenlet/tests/test_stack_saved.py
ERROR src/greenlet/tests/test_throw.py
ERROR src/greenlet/tests/test_tracing.py
ERROR src/greenlet/tests/test_weakref.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 12 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
==================================================================================== 12 errors in 0.22s =====================================================================================
I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.
python3 -sBm build -w --no-isolation
build
with--no-isolation
I'm using during all processes only locally installed modulescut off from access to the public network
(pytest is executed with-m "not network"
)Here is pytest output:
Here is list of installed modules in build env