Skip to content

Commit f914cc4

Browse files
chore: migrate project from Poetry to uv
1 parent 5f4a16b commit f914cc4

File tree

6 files changed

+2867
-3103
lines changed

6 files changed

+2867
-3103
lines changed

contributing/DEVELOPMENT.md

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### Prerequisites
66
- Python 3.9-3.12
7-
- Poetry for dependency management
7+
- [uv](https://docs.astral.sh/uv/) for dependency management
88
- Apache Spark 4.0+ (or Databricks Runtime 15.4 LTS+)
99

1010
### Installation
@@ -14,14 +14,14 @@
1414
git clone https://github.com/allisonwang-db/pyspark-data-sources.git
1515
cd pyspark-data-sources
1616

17-
# Install dependencies
18-
poetry install
17+
# Install dependencies (creates .venv/ automatically)
18+
uv sync
1919

2020
# Install with all optional dependencies
21-
poetry install --extras all
21+
uv sync --extra all
2222

23-
# Activate virtual environment
24-
poetry shell
23+
# Activate virtual environment (optional)
24+
source .venv/bin/activate
2525
```
2626

2727
### macOS Setup
@@ -84,27 +84,27 @@ This project uses [Ruff](https://github.com/astral-sh/ruff) for code formatting
8484

8585
```bash
8686
# Format code
87-
poetry run ruff format .
87+
uv run ruff format .
8888

8989
# Run linter
90-
poetry run ruff check .
90+
uv run ruff check .
9191

9292
# Run linter with auto-fix
93-
poetry run ruff check . --fix
93+
uv run ruff check . --fix
9494

9595
# Check specific file
96-
poetry run ruff check pyspark_datasources/fake.py
96+
uv run ruff check pyspark_datasources/fake.py
9797
```
9898

9999
### Pre-commit Hooks (Optional)
100100

101101
```bash
102102
# Install pre-commit hooks
103-
poetry add --group dev pre-commit
104-
pre-commit install
103+
uv add --dev pre-commit
104+
uv run pre-commit install
105105

106106
# Run manually
107-
pre-commit run --all-files
107+
uv run pre-commit run --all-files
108108
```
109109

110110
## Documentation
@@ -228,24 +228,24 @@ Add your data source to the table in README.md with examples.
228228

229229
```bash
230230
# Add required dependency
231-
poetry add requests
231+
uv add requests
232232

233233
# Add optional dependency
234-
poetry add --optional faker
234+
uv add --optional faker faker
235235

236236
# Add dev dependency
237-
poetry add --group dev pytest-cov
237+
uv add --dev pytest-cov
238238

239239
# Update dependencies
240-
poetry update
240+
uv sync --upgrade
241241
```
242242

243243
### Managing Extras
244244

245245
Edit `pyproject.toml` to add optional dependency groups:
246246

247247
```toml
248-
[tool.poetry.extras]
248+
[project.optional-dependencies]
249249
mynewsource = ["special-library"]
250250
all = ["faker", "datasets", "special-library", ...]
251251
```
@@ -346,17 +346,18 @@ import os
346346
os.environ["OBJC_DISABLE_INITIALIZE_FORK_SAFETY"] = "YES"
347347
```
348348

349-
### Poetry Issues
349+
### uv Troubleshooting
350350

351351
```bash
352352
# Clear cache
353-
poetry cache clear pypi --all
353+
uv cache clean
354354

355-
# Update lock file
356-
poetry lock --no-update
355+
# Check that the lockfile matches pyproject
356+
uv lock --check
357357

358-
# Reinstall
359-
poetry install --remove-untracked
358+
# Recreate the virtual environment
359+
rm -rf .venv
360+
uv sync
360361
```
361362

362363
### Spark Session Issues

contributing/RELEASE.md

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,44 @@ This document outlines the steps to create a new release for the `pyspark-data-s
44

55
## Prerequisites
66

7-
- Ensure you have Poetry installed
7+
- Ensure you have [uv](https://docs.astral.sh/uv/) installed
88
- Ensure you have GitHub CLI installed (optional, for enhanced releases)
99
- Ensure you have push access to the repository
1010
- Ensure all tests pass and the code is ready for release
1111

1212
## Release Steps
1313

14-
### 1. Update Version (Using Poetry Commands)
14+
### 1. Update Version
1515

16-
Use Poetry's built-in version bumping commands:
16+
`uv` does not manage versions directly, but you can use the Hatch CLI via `uvx` or edit `pyproject.toml` manually.
1717

1818
```bash
1919
# Bump patch version (0.1.6 → 0.1.7) - for bug fixes
20-
poetry version patch
20+
uvx hatch version patch
2121

2222
# Bump minor version (0.1.6 → 0.2.0) - for new features
23-
poetry version minor
23+
uvx hatch version minor
2424

2525
# Bump major version (0.1.6 → 1.0.0) - for breaking changes
26-
poetry version major
26+
uvx hatch version major
2727

2828
# Or set a specific version
29-
poetry version 1.2.3
29+
uvx hatch version 1.2.3
3030
```
3131

32-
This automatically updates the version in `pyproject.toml`.
32+
These commands update the `version` field under `[project]` in `pyproject.toml`. You can also open the file and edit the value manually if you prefer.
3333

3434
### 2. Build and Publish
3535

3636
```bash
37-
# Build the package
38-
poetry build
37+
# Build the package (creates dist/ artifacts)
38+
uv build
3939

40-
# Publish to PyPI (requires PyPI credentials)
41-
poetry publish
40+
# Publish to PyPI (requires token or username/password)
41+
uv publish
42+
43+
# Optional: dry-run to verify upload without publishing
44+
uv publish --dry-run
4245
```
4346

4447
### 3. Commit Version Changes
@@ -48,7 +51,8 @@ poetry publish
4851
git add pyproject.toml
4952

5053
# Commit with the current version (automatically retrieved)
51-
git commit -m "Bump version to $(poetry version -s)"
54+
VERSION=$(uvx hatch version)
55+
git commit -m "Bump version to ${VERSION}"
5256

5357
# Push to main branch
5458
git push
@@ -59,35 +63,37 @@ git push
5963
#### Option A: Simple Git Tag
6064
```bash
6165
# Create an annotated tag with current version
62-
git tag -a "v$(poetry version -s)" -m "Release version $(poetry version -s)"
66+
VERSION=$(uvx hatch version)
67+
git tag -a "v${VERSION}" -m "Release version ${VERSION}"
6368

6469
# Push the tag to GitHub
65-
git push origin "v$(poetry version -s)"
70+
git push origin "v${VERSION}"
6671
```
6772

6873
#### Option B: Rich GitHub Release (Recommended)
6974
```bash
7075
# Create a GitHub release with current version
71-
gh release create "v$(poetry version -s)" \
72-
--title "Release v$(poetry version -s)" \
73-
--notes "Release notes for version $(poetry version -s)" \
76+
VERSION=$(uvx hatch version)
77+
gh release create "v${VERSION}" \
78+
--title "Release v${VERSION}" \
79+
--notes "Release notes for version ${VERSION}" \
7480
--latest
7581
```
7682

7783
## Version Numbering
7884

7985
Follow [Semantic Versioning](https://semver.org/):
8086

81-
- **Patch** (`poetry version patch`): Bug fixes, no breaking changes
82-
- **Minor** (`poetry version minor`): New features, backward compatible
83-
- **Major** (`poetry version major`): Breaking changes
87+
- **Patch** (`uvx hatch version patch`): Bug fixes, no breaking changes
88+
- **Minor** (`uvx hatch version minor`): New features, backward compatible
89+
- **Major** (`uvx hatch version major`): Breaking changes
8490

8591
## Manual Version Update (Alternative)
8692

8793
If you prefer to manually edit `pyproject.toml`:
8894

8995
```toml
90-
[tool.poetry]
96+
[project]
9197
version = "x.y.z" # Update this line manually
9298
```
9399

@@ -98,21 +104,27 @@ Then follow steps 2-4 above.
98104
- [ ] All tests pass
99105
- [ ] Documentation is up to date
100106
- [ ] CHANGELOG.md is updated (if applicable)
101-
- [ ] Version is bumped using `poetry version [patch|minor|major]`
102-
- [ ] Package builds successfully (`poetry build`)
103-
- [ ] Package publishes successfully (`poetry publish`)
107+
- [ ] Version is bumped using `uvx hatch version [patch|minor|major]` (or manual edit)
108+
- [ ] Package builds successfully (`uv build`)
109+
- [ ] Package publishes successfully (`uv publish`)
104110
- [ ] Version changes are committed and pushed
105111
- [ ] GitHub release/tag is created
106112
- [ ] Release notes are written
107113

108114
## Troubleshooting
109115

110116
### Publishing Issues
111-
- Ensure you're authenticated with PyPI: `poetry config pypi-token.pypi your-token`
117+
- Ensure you're authenticated with PyPI: `uv publish --token <pypi-token>` or set credentials via environment variables
112118
- Check if the version already exists on PyPI
113119

114120
### Git Tag Issues
115-
- If tag already exists: `git tag -d "v$(poetry version -s)"` (delete local) and `git push origin :refs/tags/"v$(poetry version -s)"` (delete remote)
121+
- If tag already exists:
122+
123+
```bash
124+
VERSION=$(uvx hatch version)
125+
git tag -d "v${VERSION}"
126+
git push origin :refs/tags/"v${VERSION}"
127+
```
116128
- Ensure you have push permissions to the repository
117129

118130
### GitHub CLI Issues
@@ -127,26 +139,21 @@ If you see `objc_initializeAfterForkError` crashes on macOS, set this environmen
127139
# For single commands
128140
OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES python your_script.py
129141

130-
# For Poetry environment
131-
OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES poetry run python your_script.py
142+
# For commands that run inside the uv environment
143+
OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES uv run python your_script.py
132144

133145
# To set permanently in your shell (add to ~/.zshrc or ~/.bash_profile):
134146
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
135147
```
136148

137-
## Useful Poetry Version Commands
149+
## Useful Version Commands
138150

139151
```bash
140152
# Check current version
141-
poetry version
142-
143-
# Show version number only (useful for scripts)
144-
poetry version -s
153+
uvx hatch version
145154

146-
# Preview what the next version would be (without changing it)
147-
poetry version --dry-run patch
148-
poetry version --dry-run minor
149-
poetry version --dry-run major
155+
# Bump to an explicit version
156+
uvx hatch version 0.2.0
150157
```
151158

152159
## Documentation Releases

0 commit comments

Comments
 (0)