Skip to content

Commit d9ae6d3

Browse files
committed
Trying to fix mysql-connector-python issue
1 parent b338bab commit d9ae6d3

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

codeserver/ubi9-python-3.12/Dockerfile.cpu

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,8 @@ COPY --chown=1001:0 ${CODESERVER_SOURCE_CODE}/run-code-server.sh ${CODESERVER_SO
472472

473473
ENV SHELL=/bin/bash
474474

475-
ENV PYTHONPATH=/opt/app-root/bin/python3
475+
# Directory where uv pip install puts packages; PYTHONPATH must be a directory, not the python binary.
476+
ENV PYTHONPATH=/opt/app-root/lib/python3.12/site-packages
476477

477478
# Copy requirements files (pylock.toml for metadata; requirements.txt used for installation)
478479
COPY ${CODESERVER_SOURCE_CODE}/uv.lock.d/pylock.${PYLOCK_FLAVOR}.toml ./pylock.toml

tests/containers/workbenches/jupyterlab/jupyterlab_datascience_test.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ def test_sklearn_smoke(self, jupyterlab_datascience_image: conftest.Image) -> No
8282

8383
@allure.description("Check that mysql client functionality is working with SASL plain auth.")
8484
def test_mysql_connection(self, tf: TestFrame, datascience_image: Image, subtests):
85+
name_label = datascience_image.labels.get("name", "")
86+
if "-rstudio-" in name_label:
87+
pytest.skip(
88+
f"Image {datascience_image.name} does have -rstudio- in {datascience_image.labels['name']=}'"
89+
)
90+
8591
MYSQL_CONNECTOR_PYTHON_VERSION = "9.5.0"
8692

8793
network = testcontainers.core.network.Network()
@@ -159,22 +165,26 @@ def test_mysql_connection(self, tf: TestFrame, datascience_image: Image, subtest
159165
try:
160166
container.start(wait_for_readiness=False)
161167

168+
# Use same interpreter for pip and -c so runtime-installed package is visible (PYTHONPATH).
169+
# Code-server image uses /opt/app-root/bin/python3; others use default python.
170+
python_exe = (
171+
"/opt/app-root/bin/python3"
172+
if "-code-server-" in name_label
173+
else "python"
174+
)
175+
print(f"Using python executable: {python_exe}")
176+
162177
# RHOAIENG-140: code-server image users are expected to install their own db clients
163-
if "-code-server-" in datascience_image.labels["name"]:
178+
if "-code-server-" in name_label:
164179
exit_code, output = container.exec(
165-
["python", "-m", "pip", "install", f"mysql-connector-python=={MYSQL_CONNECTOR_PYTHON_VERSION}"]
180+
[python_exe, "-m", "pip", "install", f"mysql-connector-python=={MYSQL_CONNECTOR_PYTHON_VERSION}"]
166181
)
167182
output_str = output.decode()
168183
print(output_str)
169-
170184
assert exit_code == 0, f"Failed to install mysql-connector-python: {output_str}"
171-
elif "-rstudio-" in datascience_image.labels["name"]:
172-
pytest.skip(
173-
f"Image {datascience_image.name} does have -rstudio- in {datascience_image.labels['name']=}'"
174-
)
175185

176186
with subtests.test("Setting the user..."):
177-
exit_code, output = container.exec(["python", "-c", setup_mysql_user])
187+
exit_code, output = container.exec([python_exe, "-c", setup_mysql_user])
178188
output_str = output.decode()
179189

180190
print(output_str)
@@ -183,7 +193,7 @@ def test_mysql_connection(self, tf: TestFrame, datascience_image: Image, subtest
183193
assert exit_code == 0
184194

185195
with subtests.test("Checking the output of the clearpassuser script..."):
186-
exit_code, output = container.exec(["python", "-c", clearpassuser])
196+
exit_code, output = container.exec([python_exe, "-c", clearpassuser])
187197
output_str = output.decode()
188198

189199
print(output_str)

0 commit comments

Comments
 (0)