victorious-dress-47449
11/26/2025, 10:41 PMA under the directory company_name/lib/A that depends on a third party package called B and B depends on a package also called A (but not the same as my package under company_name/lib/A). In testing company_name/lib/A, when B tries to import from A, it resolves to my own package. Why would this happen if my package is nested under company_name/lib? I'm using a docker environment. My source root is just '/'. I'd expect `import company_name.lib.A`to resolve to my package and import A to resolve to the third party package.victorious-dress-47449
11/26/2025, 10:45 PMcompany_name.lib ? Shouldn't we keep the directory structure to prevent this situation?kind-dusk-88649
11/27/2025, 12:48 AMimport company_name.lib import A to work it might be that your pants.toml is incorrect. The root patterns decide what is threaten as as a first party. It might be that you have lib as a root pattern.victorious-dress-47449
11/27/2025, 12:51 AMroot_patterns = ['/', '/idl'] so company_name is at the root of the repokind-dusk-88649
11/27/2025, 2:13 AMvictorious-dress-47449
11/27/2025, 4:06 PMpython_sources()
python_tests(
name="tests",
environment="python"
)happy-kitchen-89482
11/27/2025, 4:39 PMpants roots show?happy-kitchen-89482
11/27/2025, 4:39 PMvictorious-dress-47449
11/27/2025, 4:39 PMpants roots
.
idlhappy-kitchen-89482
11/27/2025, 4:41 PM--keep-sandboxes=always, which will print out the paths to all the sandboxes, find the one for the relevant process (pytest?), and look at the directory structure inside it, and at the command line in __run.shhappy-kitchen-89482
11/27/2025, 4:43 PMcompany_name/lib/A in there and unless company_name/lib is on the sys.path, there should be no way for B to import A and get that code instead of what was intendedvictorious-dress-47449
11/27/2025, 4:46 PMtree -L 3
.
āāā __run.sh
āāā extra-output
āāā idl
ā āāā jazmo
ā āāā contracts
āāā jazmo
ā āāā lib
ā āāā postgrest
āāā jazmo.lib.postgrest.postgrest_test.py.tests.xml
āāā local_dists.pex
ā āāā PEX-INFO
ā āāā __main__.py
ā āāā __pex__
ā ā āāā __init__.py
ā āāā pex -> __main__.py
āāā pytest.pex
ā āāā PEX-INFO
ā āāā __main__.py
ā āāā __pex__
ā ā āāā __init__.py
ā āāā pex -> __main__.py
āāā pytest_runner.pex
ā āāā PEX-INFO
ā āāā __main__.py
ā āāā __pex__
ā ā āāā __init__.py
ā āāā pex -> __main__.py
āāā pytest_runner.pex_bin_python_shim.sh
āāā pytest_runner.pex_pex_shim.sh
āāā requirements.pex
āāā PEX-INFO
āāā __main__.py
āāā __pex__
ā āāā __init__.py
āāā pex -> __main__.pyvictorious-dress-47449
11/27/2025, 4:47 PM#!/usr/bin/env bash
# This script replicates the Docker-based process execution performed by Pants.
# It starts a container and executes the process within it.
set -euo pipefail
# Ensure required Docker volume exists
if ! docker volume inspect pants-named-caches-baa3e18b7d02 >/dev/null 2>&1; then
echo "Creating Docker volume: pants-named-caches-baa3e18b7d02"
docker volume create pants-named-caches-baa3e18b7d02
fi
# Start the container if it's not already running
CONTAINER_ID=$(docker run -d \
--init \
--tty \
-v /private/var/folders/lf/tr4gz0k514lf165m8gcg73yw0000gn/T:/pants-sandbox \
-v pants-named-caches-baa3e18b7d02:/pants-named-caches \
-v /private/var/folders/lf/tr4gz0k514lf165m8gcg73yw0000gn/T/immutable_inputsQA8s2Z:/pants-immutable-inputs \
$'sha256:8186c9704e598774b42228bd4257330ff02f26b88c068238ab9367f977bb2b80' \
/bin/sh)
echo "Started container: $CONTAINER_ID"
# Ensure container cleanup on script exit
cleanup() {
echo "Stopping and removing container: $CONTAINER_ID"
docker stop "$CONTAINER_ID" >/dev/null 2>&1 || true
docker rm "$CONTAINER_ID" >/dev/null 2>&1 || true
}
trap cleanup EXIT
# Execute the command in the container
echo "Executing command in container..."
docker exec \
-w /pants-sandbox/pants-sandbox-u0CCTc \
-e PEX_EXTRA_SYS_PATH=$'.:idl' \
"$CONTAINER_ID" \
./pytest_runner.pex_pex_shim.sh $'--color=yes' $'--junit-xml=jazmo.lib.postgrest.postgrest_test.py.tests.xml' -o $'junit_family=xunit2' jazmo/lib/postgrest/postgrest_test.pyvictorious-dress-47449
11/27/2025, 4:51 PMsupabase package
==================================== ERRORS ====================================
____________ ERROR collecting jazmo/lib/postgrest/postgrest_test.py ____________
ImportError while importing test module 'jazmo/lib/postgrest/postgrest_test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/local/lib/python3.13/importlib/__init__.py:88: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
jazmo/lib/postgrest/postgrest_test.py:17: in <module>
from supabase import AuthRetryableError, Client, create_client
/pants-named-caches/pex_root/venvs/1/s/89ebac87/venv/lib/python3.13/site-packages/supabase/__init__.py:1: in <module>
from postgrest import APIError as PostgrestAPIError
E ImportError: cannot import name 'APIError' from 'postgrest' (jazmo/lib/postgrest/__init__.py)
As you can see, site-packages/supabase/__init__.py is importing postgrest , which is being directed to jazmo/lib/postgresthappy-kitchen-89482
11/28/2025, 8:36 PMvictorious-dress-47449
11/28/2025, 8:37 PMvictorious-dress-47449
11/29/2025, 5:39 PMvictorious-dress-47449
11/29/2025, 5:44 PMcompany/lib is indeed first in the search path. But why should it even be there if it's not a source root?brief-scientist-13682
11/29/2025, 7:42 PMvictorious-dress-47449
11/29/2025, 7:45 PMbrief-scientist-13682
11/29/2025, 7:46 PMvictorious-dress-47449
11/29/2025, 7:53 PMhappy-kitchen-89482
11/29/2025, 11:18 PMcompany/__init__.py and company/lib/__init__.py, as pytest uses the presence of those to infer the package root.happy-kitchen-89482
11/29/2025, 11:20 PM...
ā company/lib/postgrest/main_test.py:tests failed in 1.57s.
$ touch company/lib/__init__.py
$ touch company/__init__.py
$ pants test company/lib/postgrest/main_test.py
15:19:58.90 [INFO] Completed: Scheduling: Run Pytest for company/lib/postgrest/main_test.py:tests
15:19:58.90 [INFO] Completed: Run Pytest - company/lib/postgrest/main_test.py:tests - succeeded.
ā company/lib/postgrest/main_test.py:tests succeeded in 2.99s.
waldorf:[/tmp/pants-debug][main]$victorious-dress-47449
11/29/2025, 11:32 PM__init__.py files around the place nor have the path be different from the pants source rootshappy-kitchen-89482
11/29/2025, 11:37 PM__init__.py the sys.path would not be different, right?happy-kitchen-89482
11/29/2025, 11:37 PMhappy-kitchen-89482
11/29/2025, 11:38 PMhappy-kitchen-89482
11/29/2025, 11:38 PM--import-mode that works for you, you can set that in your pants.toml