Skip to content

Commit 735d05a

Browse files
committed
Refactor code structure for improved readability and maintainability
1 parent bb768c2 commit 735d05a

4 files changed

Lines changed: 120 additions & 112 deletions

File tree

docker/Dockerfile.sql_to_arc

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,33 @@ COPY middleware ./middleware
5656
# as pre-built wheels on PyPI.
5757
# 3. Thus, we use 'uv sync' to create a virtual environment (.venv) and resolve all
5858
# complex dependencies exactly as specified in the uv.lock.
59-
RUN HATCH_VCS_PRETEND_VERSION=${APP_VERSION#v} \
60-
SETUPTOOLS_SCM_PRETEND_VERSION=${APP_VERSION#v} \
59+
RUN SETUPTOOLS_SCM_PRETEND_VERSION=${APP_VERSION#v} \
6160
uv sync --no-dev
6261

63-
# 4. Finally, for packages like sql_to_arc that exist both as a workspace dependency
64-
# and as a pre-built wheel, we explicitly 'uv pip install' the wheel. This ensures
65-
# we use our optimized, pre-built package instead of the 'editable' source install.
66-
RUN HATCH_VCS_PRETEND_VERSION=${APP_VERSION#v} \
67-
SETUPTOOLS_SCM_PRETEND_VERSION=${APP_VERSION#v} \
62+
# 4. Install the application wheel.
63+
# This replaces the editable install from 'uv sync' with the optimized wheel.
64+
RUN SETUPTOOLS_SCM_PRETEND_VERSION=${APP_VERSION#v} \
6865
uv pip install /tmp/wheels/*.whl pyinstaller
6966

67+
# 5. FIX: Manually reinstall git dependencies using their INTERNAL names (underscore)
68+
# to ensure proper namespace installation. We do this AFTER installing the wheel
69+
# to ensure the namespace merging happens correctly.
70+
RUN . .venv/bin/activate && \
71+
uv pip install --force-reinstall \
72+
"api_client @ git+https://github.com/fairagro/m4.2_advanced_middleware_api.git@main#subdirectory=middleware/api_client" \
73+
"shared @ git+https://github.com/fairagro/m4.2_advanced_middleware_api.git@main#subdirectory=middleware/shared"
74+
7075
# Build standalone binary using the .venv's context.
76+
# We point PyInstaller to the 'main.py' INSTALLED in site-packages.
77+
# Since we merged everything into site-packages/middleware, we can largely rely on auto-discovery.
78+
# --copy-metadata is still needed because the code checks its own version at runtime.
7179
RUN . .venv/bin/activate && \
72-
python -m PyInstaller --onedir \
80+
.venv/bin/python -m PyInstaller --onedir \
7381
--name sql_to_arc \
74-
/build/middleware/sql_to_arc/src/middleware/sql_to_arc/main.py
82+
--copy-metadata sql_to_arc \
83+
--copy-metadata api_client \
84+
--copy-metadata shared \
85+
.venv/lib/python3.12/site-packages/middleware/sql_to_arc/main.py
7586

7687

7788
# ---- Runtime Stage ----

middleware/sql_to_arc/pyproject.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ dependencies = [
1313
"opentelemetry-api>=1.39.1",
1414
]
1515

16-
[tool.uv.sources]
17-
api_client = { git = "https://github.com/fairagro/m4.2_advanced_middleware_api.git", branch = "main", subdirectory = "middleware/api_client" }
18-
shared = { git = "https://github.com/fairagro/m4.2_advanced_middleware_api.git", branch = "main", subdirectory = "middleware/shared" }
19-
2016
[tool.hatch.version]
2117
source = "vcs"
2218
raw-options = { root = "../.." }

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ dev = [
2626

2727
[tool.uv.sources]
2828
sql_to_arc = { workspace = true }
29+
api_client = { git = "https://github.com/fairagro/m4.2_advanced_middleware_api.git", branch = "main", subdirectory = "middleware/api_client" }
30+
shared = { git = "https://github.com/fairagro/m4.2_advanced_middleware_api.git", branch = "main", subdirectory = "middleware/shared" }
2931

3032
[tool.uv.workspace]
3133
members = [

0 commit comments

Comments
 (0)