Determine this is the right repository
Summary of the issue
Context
I am trying to use google-cloud-alloydb and alloydb-python-connector in the same Python environment.
Expected Behavior:
I expected to be able to import from google.cloud.alloydb.connector after installing both packages.
Actual Behavior:
I get a ModuleNotFoundError when trying to import google.cloud.alloydb.connector, because the google-cloud-alloydb package installs a concrete __init__.py file in google/cloud/alloydb/, which breaks namespace package resolution (PEP 420)
API client name and version
google-cloud-alloydb-connector 1.8.0, google-cloud-alloydb 0.4.5
Reproduction steps: code
file: test.py
from google.cloud.alloydb.connector import Connector
print("Connector loaded successfully")
Reproduction steps: supporting files
Here is a self-contained repro shell script that shows the issue with namespace packages:
file: repro.sh
#!/bin/bash
set -euo pipefail
WORKDIR=$(mktemp -d)
echo "Working directory: $WORKDIR"
# Create two isolated package install dirs
PKG_CONNECTOR="$WORKDIR/pkg_alloydb_connector"
PKG_CLOUD="$WORKDIR/pkg_cloud_alloydb"
mkdir -p "$PKG_CONNECTOR" "$PKG_CLOUD"
python3 -m venv "$WORKDIR/venv"
source "$WORKDIR/venv/bin/activate"
pip3 install --upgrade pip setuptools wheel
# Install each package into a separate directory
pip3 install --target="$PKG_CONNECTOR" google-cloud-alloydb-connector[pg8000]
pip3 install --target="$PKG_CLOUD" google-cloud-alloydb
# Show resulting google.cloud tree
echo
echo "Installed paths:"
find "$WORKDIR" -path '*/google/cloud/*' -type d
echo
echo "Attempting import..."
PYTHONPATH="$PKG_CLOUD:$PKG_CONNECTOR" python3 -c "from google.cloud.alloydb.connector import Connector" || {
echo
echo "❌ Import failed as expected due to concrete __init__.py blocking namespace package resolution"
exit 1
}
Note that if you reverse the order of the $PYTHONPATH entries, the import does work.
Reproduction steps: actual results
Traceback (most recent call last):
File "/tmp/pex-repro/test.py", line 1, in <module>
from google.cloud.alloydb.connector import Connector
ModuleNotFoundError: No module named 'google.cloud.alloydb.connector'
Reproduction steps: expected results
Connector loaded successfully
OS & version + platform
Ubuntu 22.04 on x86_64
Python environment
Python 3.11.8
Python dependencies
No response
Additional context
This issue only manifests in isolated environments like PEX or when manually simulating PEX-style import resolution. The problem arises because google/cloud/alloydb/__init__.py is a concrete file (i.e., not empty or omitted), which causes Python to treat google.cloud.alloydb as a non-namespace package.
As a result, google.cloud.alloydb.connector, becomes invisible to the import system.
Why this matters
This breaks compatibility for any downstream environment or tool that expects namespace packages to behave per PEP 420. In particular, PEX environments fail to import google.cloud.alloydb.connector, even when it's installed.
Suggested Fix
Please remove the google/cloud/alloydb/__init__.py file entirely from the google-cloud-alloydb distribution. This will allow Python to treat the directory as a namespace package, making it compatible with alloydb-python-connector.
Determine this is the right repository
Summary of the issue
Context
I am trying to use
google-cloud-alloydbandalloydb-python-connectorin the same Python environment.Expected Behavior:
I expected to be able to import from
google.cloud.alloydb.connectorafter installing both packages.Actual Behavior:
I get a
ModuleNotFoundErrorwhen trying to importgoogle.cloud.alloydb.connector, because thegoogle-cloud-alloydbpackage installs a concrete__init__.pyfile ingoogle/cloud/alloydb/, which breaks namespace package resolution (PEP 420)API client name and version
google-cloud-alloydb-connector 1.8.0, google-cloud-alloydb 0.4.5
Reproduction steps: code
file: test.py
Reproduction steps: supporting files
Here is a self-contained repro shell script that shows the issue with namespace packages:
file: repro.sh
Note that if you reverse the order of the $PYTHONPATH entries, the import does work.
Reproduction steps: actual results
Reproduction steps: expected results
OS & version + platform
Ubuntu 22.04 on x86_64
Python environment
Python 3.11.8
Python dependencies
No response
Additional context
This issue only manifests in isolated environments like PEX or when manually simulating PEX-style import resolution. The problem arises because
google/cloud/alloydb/__init__.pyis a concrete file (i.e., not empty or omitted), which causes Python to treatgoogle.cloud.alloydbas a non-namespace package.As a result,
google.cloud.alloydb.connector, becomes invisible to the import system.Why this matters
This breaks compatibility for any downstream environment or tool that expects namespace packages to behave per PEP 420. In particular, PEX environments fail to import
google.cloud.alloydb.connector, even when it's installed.Suggested Fix
Please remove the
google/cloud/alloydb/__init__.pyfile entirely from thegoogle-cloud-alloydbdistribution. This will allow Python to treat the directory as a namespace package, making it compatible withalloydb-python-connector.