|
| 1 | +# Refactoring Complete: Summary |
| 2 | + |
| 3 | +## 🎉 Migration Status: COMPLETE |
| 4 | + |
| 5 | +All planned phases of the refactoring have been successfully completed. The codebase has been split into two packages with full backward compatibility maintained. |
| 6 | + |
| 7 | +## Package Structure |
| 8 | + |
| 9 | +### vcs-versioning (Core Package) |
| 10 | +**Location**: `nextgen/vcs-versioning/` |
| 11 | + |
| 12 | +**Purpose**: VCS-agnostic versioning logic |
| 13 | + |
| 14 | +**Contents**: |
| 15 | +- **Public API**: |
| 16 | + - `Configuration` - Main configuration class |
| 17 | + - `ScmVersion` - Version representation |
| 18 | + - `Version` - Version class from packaging |
| 19 | + - `DEFAULT_*` constants |
| 20 | + |
| 21 | +- **Private modules** (all prefixed with `_`): |
| 22 | + - `_backends/` - VCS implementations (git, hg, hg_git, scm_workdir) |
| 23 | + - `_version_schemes.py` - Version scheme implementations |
| 24 | + - `_discover.py` - SCM discovery logic |
| 25 | + - `_fallbacks.py` - Fallback version parsing |
| 26 | + - `_cli.py` - CLI implementation |
| 27 | + - `_get_version_impl.py` - Core version logic |
| 28 | + - And more utility modules... |
| 29 | + |
| 30 | +**Entry Points**: |
| 31 | +- `setuptools_scm.parse_scm` - VCS parsers |
| 32 | +- `setuptools_scm.parse_scm_fallback` - Fallback parsers |
| 33 | +- `setuptools_scm.local_scheme` - Local version schemes |
| 34 | +- `setuptools_scm.version_scheme` - Version schemes |
| 35 | +- `vcs-versioning` script |
| 36 | + |
| 37 | +**Tests**: 79 passing |
| 38 | + |
| 39 | +### setuptools-scm (Integration Package) |
| 40 | +**Location**: Root directory |
| 41 | + |
| 42 | +**Purpose**: Setuptools integration and file finders |
| 43 | + |
| 44 | +**Contents**: |
| 45 | +- **Integration modules**: |
| 46 | + - `_integration/setuptools.py` - Setuptools hooks |
| 47 | + - `_integration/dump_version.py` - Version file writing |
| 48 | + - `_integration/pyproject_reading.py` - Extended with setuptools-specific logic |
| 49 | + - `_integration/version_inference.py` - Version inference |
| 50 | + |
| 51 | +- **File finders** (setuptools-specific): |
| 52 | + - `_file_finders/` - Git/Hg file finder implementations |
| 53 | + |
| 54 | +- **Re-export stubs** for backward compatibility: |
| 55 | + - Most core modules re-export from vcs_versioning |
| 56 | + |
| 57 | +- **Public API**: Re-exports Configuration, get_version, etc. |
| 58 | + |
| 59 | +**Entry Points**: |
| 60 | +- `setuptools_scm` script |
| 61 | +- `setuptools.finalize_distribution_options` hooks |
| 62 | +- `setuptools_scm.files_command` - File finders |
| 63 | + |
| 64 | +**Tests**: 329 passing, 10 skipped, 1 xfailed |
| 65 | + |
| 66 | +## Test Results |
| 67 | + |
| 68 | +``` |
| 69 | +✅ vcs-versioning: 79 passed |
| 70 | +✅ setuptools_scm: 329 passed, 10 skipped, 1 xfailed |
| 71 | +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ |
| 72 | + Total: 408 tests passing |
| 73 | +``` |
| 74 | + |
| 75 | +**Parallel execution time**: ~15 seconds with `-n12` |
| 76 | + |
| 77 | +## Key Achievements |
| 78 | + |
| 79 | +### ✅ Logging Unification |
| 80 | +- Separate root loggers for each package (`vcs_versioning`, `setuptools_scm`) |
| 81 | +- Entry point configuration at CLI and setuptools hooks |
| 82 | +- Central logger registry (`LOGGER_NAMES`) |
| 83 | +- Environment variables: `VCS_VERSIONING_DEBUG` and `SETUPTOOLS_SCM_DEBUG` |
| 84 | +- Standard Python pattern: `logging.getLogger(__name__)` everywhere |
| 85 | + |
| 86 | +### ✅ Backward Compatibility |
| 87 | +- All public APIs maintained in `setuptools_scm` |
| 88 | +- Legacy `get_version()` function works |
| 89 | +- Entry point names unchanged from user perspective |
| 90 | +- Tool section names: `[tool.setuptools_scm]` continues to work |
| 91 | + |
| 92 | +### ✅ Clean Separation |
| 93 | +- VCS backends are private in `vcs_versioning` (`_backends/`) |
| 94 | +- Version schemes are private (only configurable via entry points) |
| 95 | +- File finders remain in `setuptools_scm` (setuptools-specific) |
| 96 | +- Clear ownership: core logic in vcs_versioning, integration in setuptools_scm |
| 97 | + |
| 98 | +### ✅ Build System |
| 99 | +- uv workspace configured |
| 100 | +- Both packages build successfully |
| 101 | +- Proper dependency management |
| 102 | +- `vcs-versioning` in `build-system.requires` |
| 103 | + |
| 104 | +## Important Fixes Applied |
| 105 | + |
| 106 | +1. **Empty tag regex warning**: Properly emitted via delegation to vcs_versioning.get_version() |
| 107 | +2. **Test mocks**: Fixed to patch actual module locations (not re-exports) |
| 108 | +3. **Backward compatibility**: Added `__main__.py` shim, fixed imports |
| 109 | +4. **Setuptools conflict warning**: Warns when `tool.setuptools.dynamic.version` conflicts with `setuptools-scm[simple]` |
| 110 | +5. **Module privacy**: Tests import private APIs directly from vcs_versioning |
| 111 | + |
| 112 | +## Next Steps (Recommended) |
| 113 | + |
| 114 | +### 1. CI/CD Validation |
| 115 | +- [ ] Push to GitHub and verify Actions pass |
| 116 | +- [ ] Ensure both packages are tested in CI |
| 117 | +- [ ] Verify matrix testing (Python 3.8-3.13) |
| 118 | + |
| 119 | +### 2. Documentation |
| 120 | +- [ ] Update README.md to mention vcs-versioning |
| 121 | +- [ ] Add migration guide for users who want to use vcs-versioning directly |
| 122 | +- [ ] Document the split and which package to use when |
| 123 | + |
| 124 | +### 3. Release Preparation |
| 125 | +- [ ] Update CHANGELOG.md |
| 126 | +- [ ] Decide on version numbers |
| 127 | +- [ ] Consider if this warrants a major version bump |
| 128 | +- [ ] Update NEWS/release notes |
| 129 | + |
| 130 | +### 4. Additional Testing |
| 131 | +- [ ] Test with real projects that use setuptools_scm |
| 132 | +- [ ] Verify editable installs work |
| 133 | +- [ ] Test build backends besides setuptools (if applicable) |
| 134 | + |
| 135 | +### 5. Community Communication |
| 136 | +- [ ] Announce the refactoring |
| 137 | +- [ ] Explain benefits to users |
| 138 | +- [ ] Provide migration path for advanced users |
| 139 | + |
| 140 | +## File Structure Overview |
| 141 | + |
| 142 | +``` |
| 143 | +setuptools_scm/ |
| 144 | +├── src/setuptools_scm/ # Integration package |
| 145 | +│ ├── __init__.py # Re-exports from vcs_versioning |
| 146 | +│ ├── _integration/ # Setuptools-specific |
| 147 | +│ └── _file_finders/ # File finding (setuptools) |
| 148 | +│ |
| 149 | +└── nextgen/vcs-versioning/ # Core package |
| 150 | + ├── src/vcs_versioning/ |
| 151 | + │ ├── __init__.py # Public API |
| 152 | + │ ├── config.py # Configuration (public) |
| 153 | + │ ├── _backends/ # VCS implementations (private) |
| 154 | + │ ├── _version_schemes.py # Schemes (private) |
| 155 | + │ ├── _cli.py # CLI (private) |
| 156 | + │ └── ... # Other private modules |
| 157 | + └── testing/ # Core tests (79) |
| 158 | +``` |
| 159 | + |
| 160 | +## Commands Reference |
| 161 | + |
| 162 | +```bash |
| 163 | +# Run all tests |
| 164 | +uv run pytest -n12 |
| 165 | + |
| 166 | +# Run setuptools_scm tests only |
| 167 | +uv run pytest testing/ -n12 |
| 168 | + |
| 169 | +# Run vcs-versioning tests only |
| 170 | +uv run pytest nextgen/vcs-versioning/testing/ -n12 |
| 171 | + |
| 172 | +# Sync dependencies |
| 173 | +uv sync |
| 174 | + |
| 175 | +# Build packages |
| 176 | +uv build |
| 177 | + |
| 178 | +# Run with debug logging |
| 179 | +VCS_VERSIONING_DEBUG=1 uv run python -m setuptools_scm |
| 180 | +SETUPTOOLS_SCM_DEBUG=1 uv run python -m setuptools_scm |
| 181 | +``` |
| 182 | + |
| 183 | +## Migration Notes |
| 184 | + |
| 185 | +The refactoring maintains full backward compatibility. Users of setuptools-scm will see no breaking changes. The new vcs-versioning package is intended for: |
| 186 | +- Projects that don't use setuptools |
| 187 | +- Direct integration into other build systems |
| 188 | +- Standalone VCS version detection |
| 189 | + |
| 190 | +## Conclusion |
| 191 | + |
| 192 | +✅ **The refactoring is complete and ready for review/merge.** |
| 193 | + |
| 194 | +All planned work has been completed: |
| 195 | +- Code successfully split into two packages |
| 196 | +- Full test coverage maintained (408 tests passing) |
| 197 | +- Backward compatibility preserved |
| 198 | +- Clean separation of concerns |
| 199 | +- Logging properly unified |
| 200 | +- Ready for CI/CD validation |
| 201 | + |
0 commit comments