Skip to content

Commit d9a7ef7

Browse files
Fix broken links and correct pybind directory paths in BUILDGUIDE.md
Co-authored-by: dlevy-msft-sql <194277063+dlevy-msft-sql@users.noreply.github.com>
1 parent 8b1a67b commit d9a7ef7

File tree

1 file changed

+60
-9
lines changed

1 file changed

+60
-9
lines changed

BUILDGUIDE.md

Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This guide will help you set up your environment, build the native bindings, and
77

88
## Table of Contents
99

10+
- [Getting Started](#getting-started)
1011
- [Prerequisites](#prerequisites)
1112
- [Platform-Specific Setup](#platform-specific-setup)
1213
- [Windows](#windows)
@@ -15,11 +16,29 @@ This guide will help you set up your environment, build the native bindings, and
1516
- [Building Native Bindings](#building-native-bindings)
1617
- [Building the Python Wheel (.whl)](#building-the-python-wheel-whl)
1718
- [Running Tests](#running-tests)
19+
- [Setting Up a Test Database (Optional)](#setting-up-a-test-database-optional)
1820
- [Directory Structure](#directory-structure)
1921
- [Troubleshooting](#troubleshooting)
2022

2123
---
2224

25+
## Getting Started
26+
27+
To contribute to this project, you'll need to fork and clone the repository:
28+
29+
1. **Fork the repository** on GitHub by clicking the "Fork" button on the [mssql-python repository page](https://github.com/microsoft/mssql-python).
30+
2. **Clone your fork** to your local machine:
31+
```bash
32+
git clone https://github.com/YOUR-USERNAME/mssql-python.git
33+
cd mssql-python
34+
```
35+
3. **Set up the upstream remote** to keep your fork in sync:
36+
```bash
37+
git remote add upstream https://github.com/microsoft/mssql-python.git
38+
```
39+
40+
---
41+
2342
## Prerequisites
2443

2544
- **Python:** Minimum supported version is 3.10.
@@ -39,6 +58,7 @@ This guide will help you set up your environment, build the native bindings, and
3958
2. **Install Visual Studio Build Tools**
4059
- Include the “Desktop development with C++” workload.
4160
- CMake is included by default.
61+
- **Alternative for VS Code users:** If you already have VS Code installed, you can configure it for C++ development by following [this guide](https://code.visualstudio.com/docs/cpp/config-msvc).
4262
3. **Install Microsoft ODBC Driver for SQL Server:**
4363
[Download here](https://docs.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server).
4464
4. **Install required Python packages:**
@@ -82,14 +102,14 @@ This guide will help you set up your environment, build the native bindings, and
82102

83103
## Building Native Bindings
84104

85-
The native bindings are in the `pybind` directory.
105+
The native bindings are in the `mssql_python/pybind` directory.
86106

87107
### Windows
88108

89109
Open a **Developer Command Prompt for VS** and run:
90110

91111
```bash
92-
cd pybind
112+
cd mssql_python/pybind
93113
build.bat
94114
```
95115

@@ -102,7 +122,7 @@ This will:
102122
### macOS & Linux
103123

104124
```bash
105-
cd pybind
125+
cd mssql_python/pybind
106126
./build.sh
107127
```
108128

@@ -116,17 +136,23 @@ This will:
116136

117137
## Running Tests
118138

119-
Tests require a database connection string.
139+
Tests require a database connection string and must be run from the project root directory.
120140
Set the `DB_CONNECTION_STRING` environment variable before running tests:
121141

122142
### Windows (Command Prompt)
123143
```cmd
144+
# If you're in mssql_python/pybind/, navigate back to the project root:
145+
cd ../..
146+
124147
set DB_CONNECTION_STRING=your-connection-string-here
125148
python -m pytest -v
126149
```
127150

128151
### macOS & Linux (bash/zsh)
129152
```bash
153+
# If you're in mssql_python/pybind/, navigate back to the project root:
154+
cd ../..
155+
130156
export DB_CONNECTION_STRING=your-connection-string-here
131157
python -m pytest -v
132158
```
@@ -154,9 +180,9 @@ From the project root:
154180

155181
```bash
156182
# Build the bindings first!
157-
cd pybind
183+
cd mssql_python/pybind
158184
./build.sh
159-
cd ..
185+
cd ../..
160186

161187
# Then build the wheel:
162188
python setup.py bdist_wheel
@@ -168,23 +194,48 @@ The wheel file will be created in the `dist/` directory.
168194

169195
## Directory Structure
170196

171-
- `pybind/` — Native C++/pybind11 bindings and platform build scripts
197+
- `mssql_python/pybind/` — Native C++/pybind11 bindings and platform build scripts
172198
- `mssql_python/` — Python package source
173199
- `tests/` — Test suite
174200
- `dist/` — Built wheel packages
175201

176202
---
177203

204+
## Setting Up a Test Database (Optional)
205+
206+
If you don't have access to a SQL Server instance, you can quickly set up a containerized SQL Server using go-sqlcmd:
207+
208+
### Windows
209+
```bash
210+
# Install Docker Desktop and sqlcmd
211+
winget install Docker.DockerDesktop
212+
```
213+
Configure Docker, accept EULA, etc., then open a new terminal window:
214+
```bash
215+
winget install sqlcmd
216+
```
217+
Open a new window to get new path variables:
218+
```bash
219+
sqlcmd create mssql --name mssql-python --accept-eula tag 2025-latest --using https://github.com/Microsoft/sql-server-samples/releases/download/wide-world-importers-v1.0/WideWorldImporters-Full.bak
220+
sqlcmd config connection-strings
221+
```
222+
Copy the ODBC connection string and remove the driver clause before storing it in your `DB_CONNECTION_STRING` environment variable.
223+
224+
### macOS & Linux
225+
Similar commands are available for macOS and Linux. See the [go-sqlcmd documentation](https://learn.microsoft.com/en-us/sql/tools/sqlcmd/quickstart-sqlcmd-create-container?view=sql-server-ver17) for platform-specific instructions.
226+
227+
---
228+
178229
## Troubleshooting
179230

180231
- Ensure all prerequisites are installed and on your PATH.
181-
- If a build fails, clean up old artifacts and try again (`pybind/build.bat clean` or `./build.sh clean`).
232+
- If a build fails, clean up old artifacts and try again (`mssql_python/pybind/build.bat clean` or `./build.sh clean`).
182233
- For wheel issues, ensure the native binding (`.pyd` or `.so`) is present in the expected location before building the wheel.
183234
- For test failures, double-check your `DB_CONNECTION_STRING`.
184235

185236
---
186237

187-
For more details on the native bindings, see [`pybind/README.md`](pybind/README.md).
238+
For more details on the native bindings, see [`mssql_python/pybind/README.md`](mssql_python/pybind/README.md).
188239

189240
---
190241

0 commit comments

Comments
 (0)