Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/e2e/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import subprocess
import sys
from pathlib import Path

import pytest
Expand Down Expand Up @@ -41,9 +42,8 @@ def crawlee_wheel_path(tmp_path_factory: pytest.TempPathFactory, testrun_uid: st
was_wheel_built_this_test_run_file = tmp_path_factory.getbasetemp() / f'wheel_was_built_in_run_{testrun_uid}'
if not was_wheel_built_this_test_run_file.exists():
subprocess.run(
args='python -m build',
args=[sys.executable, '-m', 'build'],
cwd=_CRAWLEE_ROOT_PATH,
shell=True,
check=True,
capture_output=True,
)
Expand Down
56 changes: 26 additions & 30 deletions tests/e2e/project_template/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import re
import shutil
import subprocess
from pathlib import Path
from typing import Literal

Expand Down Expand Up @@ -68,36 +67,33 @@ def _patch_crawlee_version_in_pyproject_toml_based_project(project_path: Path, w
with dockerfile_path.open() as f:
modified_lines = []
for line in f:
modified_lines.append(line)
if line.startswith('COPY pyproject.toml'):
if 'uv.lock' in line:
package_manager = 'uv'
elif 'poetry.lock' in line:
package_manager = 'poetry'
else:
raise RuntimeError('This does not look like a uv or poetry based project.')
if not line.startswith('COPY pyproject.toml'):
modified_lines.append(line)
continue

# Create lock file that is expected by the docker to exist (even though it will be patched
# in the docker).
subprocess.run(
args=[package_manager, 'lock'],
cwd=str(project_path),
check=True,
capture_output=True,
)
if 'uv.lock' in line:
package_manager = 'uv'
elif 'poetry.lock' in line:
package_manager = 'poetry'
else:
raise RuntimeError('This does not look like a uv or poetry based project.')

# Add command to copy .whl to the docker image and update project with it.
# Patching in docker file due to the poetry not properly supporting relative paths for wheel packages
# and so the absolute path (in the container) is generated when running `add` command in the container.
modified_lines.extend(
[
f'COPY {wheel_path.name} ./\n',
# If no crawlee version bump, poetry might be lazy and take existing pre-installed crawlee
# version, make sure that one is patched as well.
f'RUN pip install ./{wheel_path.name}{crawlee_extras} --force-reinstall\n',
f'RUN {package_manager} add ./{wheel_path.name}{crawlee_extras}\n',
f'RUN {package_manager} lock\n',
]
)
# Copy only `pyproject.toml`. The generated project has no lock file, and the `add` and `lock`
# commands appended below create one in the image anyway.
modified_lines.append('COPY pyproject.toml ./\n')

# Add command to copy .whl to the docker image and update project with it.
# Patching in docker file due to the poetry not properly supporting relative paths for wheel packages
# and so the absolute path (in the container) is generated when running `add` command in the container.
modified_lines.extend(
[
f'COPY {wheel_path.name} ./\n',
# If no crawlee version bump, poetry might be lazy and take existing pre-installed crawlee
# version, make sure that one is patched as well.
f'RUN pip install ./{wheel_path.name}{crawlee_extras} --force-reinstall\n',
f'RUN {package_manager} add ./{wheel_path.name}{crawlee_extras}\n',
f'RUN {package_manager} lock\n',
]
)
with dockerfile_path.open('w') as f:
f.write(''.join(modified_lines))
Loading
Loading