Skip to content

Commit 1a347f5

Browse files
Copilotsaurabh500
andcommitted
DOC: Update dev container and Copilot instructions for mssql-py-core NuGet setup
Co-authored-by: saurabh500 <1623701+saurabh500@users.noreply.github.com>
1 parent 197a923 commit 1a347f5

4 files changed

Lines changed: 162 additions & 20 deletions

File tree

.devcontainer/post-create.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,18 @@ else
4848
exit 1
4949
fi
5050

51+
# Install mssql_py_core from NuGet (required for bulkcopy functionality)
52+
echo ""
53+
echo "📦 Installing mssql_py_core from NuGet (required for bulkcopy)..."
54+
PYCORE_INSTALLED=false
55+
if bash eng/scripts/install-mssql-py-core.sh; then
56+
echo "✅ mssql_py_core installed successfully"
57+
PYCORE_INSTALLED=true
58+
else
59+
echo "⚠️ mssql_py_core installation failed - bulkcopy functionality will not be available"
60+
echo " You can retry manually: bash eng/scripts/install-mssql-py-core.sh"
61+
fi
62+
5163
# Generate random password for SQL Server
5264
echo ""
5365
echo "Generating SQL Server password..."
@@ -103,6 +115,11 @@ echo "=============================================="
103115
echo ""
104116
echo "📦 What's ready:"
105117
echo " ✅ C++ extension built"
118+
if [ "$PYCORE_INSTALLED" = "true" ]; then
119+
echo " ✅ mssql_py_core installed (bulkcopy support)"
120+
else
121+
echo " ⚠️ mssql_py_core not installed (bulkcopy unavailable - retry: bash eng/scripts/install-mssql-py-core.sh)"
122+
fi
106123
echo " ✅ SQL Server running (localhost:1433)"
107124
echo " ✅ DB_CONNECTION_STRING set in environment"
108125
echo ""

.github/prompts/build-ddbc.prompt.md

Lines changed: 73 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,49 @@ cd mssql_python\pybind && build.bat && cd ..\..
113113

114114
---
115115

116-
## STEP 2: Verify the Build
116+
## STEP 2: Install mssql_py_core from NuGet (Required for Bulkcopy)
117+
118+
The `bulkcopy` method requires the `mssql_py_core` native module, which is distributed as a NuGet package and must be installed separately.
119+
120+
### 2.1 Run the Install Script
121+
122+
**macOS / Linux:**
123+
124+
```bash
125+
# From repository root - downloads and extracts the matching wheel from NuGet
126+
bash eng/scripts/install-mssql-py-core.sh
127+
```
128+
129+
**Windows (PowerShell):**
130+
131+
```powershell
132+
# From repository root
133+
.\eng\scripts\install-mssql-py-core.ps1
134+
```
135+
136+
### 2.2 What the Script Does
137+
138+
1. **Reads** the required version from `eng/versions/mssql-py-core.version`
139+
2. **Downloads** the `mssql-py-core-wheels` NuGet package from the public Azure Artifacts feed
140+
3. **Extracts** the platform-matching wheel (e.g., `mssql_py_core-*-cp313-cp313-linux_x86_64.whl`)
141+
4. **Installs** the `mssql_py_core/` directory at the repository root
142+
143+
### 2.3 Verify Installation
144+
145+
```bash
146+
# From repository root
147+
python -c "import mssql_py_core; print('✅ mssql_py_core loaded:', dir(mssql_py_core))"
148+
```
149+
150+
> ⚠️ **Note:** On Linux build containers with glibc older than 2.34, the import verification is skipped automatically (the `.so` requires glibc 2.34+). The file is still installed correctly.
151+
152+
---
153+
154+
## STEP 3: Verify the Build
117155

118156
**These commands assume you're at the repository root** (which you should be after Step 1).
119157

120-
### 2.1 Check Output File Exists
158+
### 3.1 Check Output File Exists
121159

122160
```bash
123161
# macOS/Linux
@@ -127,15 +165,15 @@ ls -la mssql_python/ddbc_bindings.*.so
127165
dir mssql_python\ddbc_bindings.*.pyd
128166
```
129167

130-
### 2.2 Verify Import Works
168+
### 3.2 Verify Import Works
131169

132170
```bash
133171
python -c "from mssql_python import connect; print('✅ Import successful')"
134172
```
135173

136174
---
137175

138-
## STEP 3: Clean Build (If Needed)
176+
## STEP 4: Clean Build (If Needed)
139177

140178
If you need a completely fresh build:
141179

@@ -280,15 +318,43 @@ rm -rf build/
280318
./build.sh
281319
```
282320

321+
### ❌ "No module named 'mssql_py_core'" when using bulkcopy
322+
323+
**Cause:** The `mssql_py_core` NuGet package has not been installed yet.
324+
325+
**Fix:**
326+
```bash
327+
# macOS/Linux - from repository root
328+
bash eng/scripts/install-mssql-py-core.sh
329+
330+
# Windows (PowerShell) - from repository root
331+
.\eng\scripts\install-mssql-py-core.ps1
332+
```
333+
334+
### ❌ "ERROR: No wheel found matching: ..." when running install-mssql-py-core.sh
335+
336+
**Cause:** The NuGet package doesn't contain a wheel for your Python version or platform.
337+
338+
**Fix:**
339+
```bash
340+
# Check the version file
341+
cat eng/versions/mssql-py-core.version
342+
343+
# Check your Python version and platform
344+
python -c "import sys, platform; v=sys.version_info; print(f'cp{v.major}{v.minor}', platform.system(), platform.machine())"
345+
346+
# Contact the team if the combination is unsupported
347+
```
348+
283349
---
284350

285351
## Quick Reference
286352

287353
### One-Liner Build Commands
288354

289355
```bash
290-
# macOS/Linux - Full rebuild from repo root
291-
cd mssql_python/pybind && rm -rf build && ./build.sh && cd ../.. && python -c "from mssql_python import connect; print('✅ Build successful')"
356+
# macOS/Linux - Full rebuild from repo root (includes mssql_py_core)
357+
cd mssql_python/pybind && rm -rf build && ./build.sh && cd ../.. && bash eng/scripts/install-mssql-py-core.sh && python -c "from mssql_python import connect; print('✅ Build successful')"
292358
```
293359

294360
### Build Output Naming Convention
@@ -305,7 +371,7 @@ cd mssql_python/pybind && rm -rf build && ./build.sh && cd ../.. && python -c "f
305371

306372
## After Building
307373

308-
Once the build succeeds:
374+
Once the build succeeds (Steps 1 and 2 above):
309375

310376
1. **Run tests** → Use `#run-tests`
311377
2. **Test manually** with a connection to SQL Server

.github/prompts/run-tests.prompt.md

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -247,17 +247,23 @@ tests/test_004_cursor.py:25: DatabaseError
247247

248248
### Test Files and What They Cover
249249

250-
| File | Purpose | Requires DB? |
251-
|------|---------|--------------|
252-
| `test_000_dependencies.py` | Dependency checks | No |
253-
| `test_001_globals.py` | Global state | No |
254-
| `test_002_types.py` | Type conversions | No |
255-
| `test_003_connection.py` | Connection lifecycle | **Yes** |
256-
| `test_004_cursor.py` | Cursor operations | **Yes** |
257-
| `test_005_connection_cursor_lifecycle.py` | Lifecycle management | **Yes** |
258-
| `test_006_exceptions.py` | Error handling | Mixed |
259-
| `test_007_logging.py` | Logging functionality | No |
260-
| `test_008_auth.py` | Authentication | **Yes** |
250+
| File | Purpose | Requires DB? | Requires mssql_py_core? |
251+
|------|---------|--------------|--------------------------|
252+
| `test_000_dependencies.py` | Dependency checks | No | No |
253+
| `test_001_globals.py` | Global state | No | No |
254+
| `test_002_types.py` | Type conversions | No | No |
255+
| `test_003_connection.py` | Connection lifecycle | **Yes** | No |
256+
| `test_004_cursor.py` | Cursor operations | **Yes** | No |
257+
| `test_005_connection_cursor_lifecycle.py` | Lifecycle management | **Yes** | No |
258+
| `test_006_exceptions.py` | Error handling | Mixed | No |
259+
| `test_007_logging.py` | Logging functionality | No | No |
260+
| `test_008_auth.py` | Authentication | **Yes** | No |
261+
| `test_019_bulkcopy.py` | Bulk copy operations | **Yes** | **Yes** |
262+
263+
> ⚠️ **Bulkcopy tests** require `mssql_py_core` to be installed. If not installed, the module is automatically skipped. To install it:
264+
> ```bash
265+
> bash eng/scripts/install-mssql-py-core.sh
266+
> ```
261267
262268
---
263269
@@ -339,6 +345,22 @@ cd mssql_python/pybind && ./build.sh && cd ../..
339345
python -c "from mssql_python import connect; print('OK')"
340346
```
341347

348+
### ❌ Bulkcopy tests are skipped ("module not available")
349+
350+
**Cause:** `mssql_py_core` is not installed — the bulkcopy tests skip automatically when it can't be imported.
351+
352+
**Fix:**
353+
```bash
354+
# macOS/Linux - from repository root
355+
bash eng/scripts/install-mssql-py-core.sh
356+
357+
# Windows (PowerShell) - from repository root
358+
.\eng\scripts\install-mssql-py-core.ps1
359+
360+
# Verify
361+
python -c "import mssql_py_core; print('✅ mssql_py_core loaded')"
362+
```
363+
342364
### ❌ Tests pass locally but fail in CI
343365

344366
**Cause:** Environment differences (connection string, Python version, OS)

.github/prompts/setup-dev-env.prompt.md

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,34 @@ pip install black flake8 autopep8
134134
pip install -e .
135135
```
136136

137-
### 3.5 Verify Python Dependencies
137+
### 3.5 Install mssql_py_core from NuGet (Required for Bulkcopy)
138+
139+
The `bulkcopy` feature requires `mssql_py_core`, a Rust-based native module distributed as a NuGet package. It must be installed separately from pip packages.
140+
141+
**macOS / Linux:**
142+
143+
```bash
144+
# From repository root - downloads and extracts the wheel matching your Python/platform
145+
bash eng/scripts/install-mssql-py-core.sh
146+
```
147+
148+
**Windows (PowerShell):**
149+
150+
```powershell
151+
# From repository root
152+
.\eng\scripts\install-mssql-py-core.ps1
153+
```
154+
155+
> ℹ️ The script reads the version from `eng/versions/mssql-py-core.version`, downloads the NuGet package from the public Azure Artifacts feed, and extracts the `mssql_py_core/` directory to the repository root.
156+
157+
### 3.6 Verify Python Dependencies
138158

139159
```bash
140160
# Check critical packages
141161
python -c "import pybind11; print('✅ pybind11:', pybind11.get_include())"
142162
python -c "import pytest; print('✅ pytest:', pytest.__version__)"
143163
python -c "import mssql_python; print('✅ mssql_python installed')"
164+
python -c "import mssql_py_core; print('✅ mssql_py_core installed (bulkcopy support)')" 2>/dev/null || echo "⚠️ mssql_py_core not installed (bulkcopy unavailable)"
144165
```
145166

146167
---
@@ -585,6 +606,7 @@ echo "3. Key Packages:" && \
585606
python -c "import pybind11; print(' ✅ pybind11:', pybind11.__version__)" 2>/dev/null || echo " ❌ pybind11 not installed" && \
586607
python -c "import pytest; print(' ✅ pytest:', pytest.__version__)" 2>/dev/null || echo " ❌ pytest not installed" && \
587608
python -c "import mssql_python; print(' ✅ mssql_python installed')" 2>/dev/null || echo " ❌ mssql_python not installed" && \
609+
python -c "import mssql_py_core; print(' ✅ mssql_py_core installed (bulkcopy support)')" 2>/dev/null || echo " ⚠️ mssql_py_core not installed (bulkcopy unavailable - run: bash eng/scripts/install-mssql-py-core.sh)" && \
588610
echo "" && \
589611
echo "4. Build Tools:" && \
590612
cmake --version 2>/dev/null | head -1 | sed 's/^/ ✅ /' || echo " ❌ cmake not found" && \
@@ -714,6 +736,19 @@ pip install -r requirements.txt -v
714736
pip install <package-name>
715737
```
716738

739+
### ❌ "No module named 'mssql_py_core'" when using bulkcopy
740+
741+
**Cause:** The `mssql_py_core` NuGet package has not been installed yet.
742+
743+
**Fix:**
744+
```bash
745+
# macOS/Linux - from repository root
746+
bash eng/scripts/install-mssql-py-core.sh
747+
748+
# Windows (PowerShell) - from repository root
749+
.\eng\scripts\install-mssql-py-core.ps1
750+
```
751+
717752
### ❌ PowerShell: "Activate.ps1 cannot be loaded because running scripts is disabled"
718753

719754
**Cause:** PowerShell execution policy
@@ -741,6 +776,7 @@ pip install --upgrade pip && \
741776
pip install -r requirements.txt && \
742777
pip install pybind11 pytest pytest-cov && \
743778
pip install -e . && \
779+
bash eng/scripts/install-mssql-py-core.sh && \
744780
echo "✅ Setup complete!"
745781
```
746782

@@ -752,14 +788,15 @@ echo "✅ Setup complete!"
752788
| `pytest` | Testing | Running tests |
753789
| `pytest-cov` | Coverage | Coverage reports |
754790
| `azure-identity` | Azure auth | Runtime (in requirements.txt) |
791+
| `mssql_py_core` | Rust/TDS bulkcopy core | Bulkcopy feature (via NuGet script) |
755792

756793
---
757794

758795
## After Setup
759796

760797
Once setup is complete, you can:
761798

762-
1. **Build DDBC extensions** → Use `#build-ddbc`
799+
1. **Build DDBC extensions** → Use `#build-ddbc` (also installs `mssql_py_core` for bulkcopy)
763800
2. **Run tests** → Use `#run-tests`
764801

765802
> 💡 You typically only need to run this setup prompt **once** per machine or after major changes.

0 commit comments

Comments
 (0)