[MacPorts] #67055: Unable to set PYTHONPATH via test.env
MacPorts
noreply at macports.org
Mon Mar 6 15:42:06 UTC 2023
#67055: Unable to set PYTHONPATH via test.env
---------------------+--------------------
Reporter: dgilman | Owner: (none)
Type: defect | Status: new
Priority: Normal | Milestone:
Component: ports | Version:
Keywords: | Port:
---------------------+--------------------
I believe this is a defect in the Python portgroup.
The `PYTHONPATH` variable is not getting propagated from `test.env` down
to the actual running of the tests. This is breaking the case where you
are trying to test against a package that has not yet been installed so
there's no package in the `PYTHONPATH` to import.
Attached is a simple portfile to reproduce the issue. Here is the guts of
the portfile:
{{{
python.test_framework \
pytest
test.run yes
test.target
test.env FOO=bar PYTHONPATH=${worksrcpath}/src
}}}
Truncated test output. Note FOO is set, but PYTHONPATH is empty:
{{{
DEBUG: Executing org.macports.test (py311-pyproject_hooks)
DEBUG: Environment:
CC_PRINT_OPTIONS='YES'
CC_PRINT_OPTIONS_FILE='/opt/local/var/macports/build
/_Users_david_macports-ports-local_python_py-
pyproject_hooks/py311-pyproject_hooks/work/.CC_PRINT_OPTIONS'
CPATH='/opt/local/include'
DEVELOPER_DIR='/Library/Developer/CommandLineTools'
FOO='bar'
LIBRARY_PATH='/opt/local/lib'
MACOSX_DEPLOYMENT_TARGET='10.15'
PYTHONPATH=''
SDKROOT='/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk'
Executing: cd "/opt/local/var/macports/build/_Users_david_macports-ports-
local_python_py-
pyproject_hooks/py311-pyproject_hooks/work/pyproject_hooks-1.0.0" &&
py.test-3.11 -o addopts=''
DEBUG: system: cd "/opt/local/var/macports/build/_Users_david_macports-
ports-local_python_py-
pyproject_hooks/py311-pyproject_hooks/work/pyproject_hooks-1.0.0" &&
py.test-3.11 -o addopts=''
========================================================================
test session starts
=========================================================================
platform darwin -- Python 3.11.2, pytest-7.2.1, pluggy-1.0.0
rootdir: /opt/local/var/macports/build/_Users_david_macports-ports-
local_python_py-
pyproject_hooks/py311-pyproject_hooks/work/pyproject_hooks-1.0.0,
configfile: pytest.ini
collected 0 items / 3 errors
===============================================================================
ERRORS
===============================================================================
_____________________________________________________________ ERROR
collecting tests/test_call_hooks.py
______________________________________________________________
ImportError while importing test module '/opt/local/var/macports/build
/_Users_david_macports-ports-local_python_py-
pyproject_hooks/py311-pyproject_hooks/work/pyproject_hooks-1.0.0/tests/test_call_hooks.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py:126:
in import_module
return _bootstrap._gcd_import(name[level:], package, level)
tests/test_call_hooks.py:13: in <module>
from pyproject_hooks import (
E ModuleNotFoundError: No module named 'pyproject_hooks'
}}}
--
Ticket URL: <https://trac.macports.org/ticket/67055>
MacPorts <https://www.macports.org/>
Ports system for macOS
More information about the macports-tickets
mailing list