# uv-to-pipfile
A tool and pre-commit hook to convert `uv.lock` files to `Pipfile.lock` format, allowing you to use [uv](https://github.com/astral-sh/uv) for dependency resolution while maintaining compatibility with Pipenv workflows.
## Installation
<!-- Install from PyPI:
```bash
pip install uv-to-pipfile
```
## Using uv-to-pipfile
### As a CLI Tool
Run directly from the command line:
```bash
# Convert uv.lock to Pipfile.lock in the current directory
uv-to-pipfile
# Specify an output file path
uv-to-pipfile --pipfile-lock custom_path/Pipfile.lock
``` -->
### With pre-commit
Add this to your `.pre-commit-config.yaml`:
```yaml
- repo: https://github.com/FlavioAmurrioCS/uv-to-pipfile
rev: v0.0.7 # Use the ref you want to point at
hooks:
- id: uv-to-pipfile
```
## How it works
### Packages
The conversion process follows these steps:
- `uv.lock` lists packages as an array. We parse all of these and create a dictionary where the key is the package name and the value is the package metadata.
- We identify the virtual package which represents the project itself. This lists the dependencies.
- We create a queue with these packages and iterate through them, adding each to the respective section (default or develop).
- We then add their dependencies to the queue and continue processing.
- We repeat the same process for dev packages.
### Python Version Detection
The tool determines Python version requirements in the following order:
1. Check for a `.python-version` file in the same directory as the `uv.lock` file
2. Extract the `requires-python` field from the `uv.lock` (ignoring range markers such as `>=`)
3. Default to Python 3.11 if no version information is found
## Python Version Compatibility
This tool is compatible with Python 3.8 and later versions. The implementation is designed to work seamlessly across different Python environments:
- For Python 3.11+: No additional dependencies are required as `tomllib` is included in the standard library
- For Python 3.8-3.10: The `tomli` package is automatically installed as a dependency
The script can be executed in several ways:
- As an installed package via `uv-to-pipfile` command
- Directly as a PEP 723 compliant script using `pipx run`, `hatch run`, or `uv run`
- With Python 3.11+ using standard `python uv_to_pipfile.py`
## Known Issues and Limitations
- `uv.lock` does not provide markers information. Pipenv doesn't seem to mind this omission.
- `uv.lock` does not list all the hashes for a specific version. Some hashes might be filtered out.
- Potential solution: Call the PyPI API to fetch missing hashes
- Challenge: Additional work would be needed to support non-REST pip indexes like Artifactory
- The `_meta.hash.sha256` value will be missing from generated `Pipfile.lock` files. This appears to be a hash of the Pipfile and doesn't seem necessary.
- Currently, the tool only supports one index. Multi-index support could be added if needed.
- System-specific dependencies might be handled differently:
- For example, `colorama` is only needed on Windows machines
- It may not be listed in the original `Pipfile.lock` but gets listed in `uv.lock`
- Installing the generated `Pipfile.lock` might install packages not strictly needed on your platform
- Dependencies installed in different ways across package sections may have different mappings:
- For example, if `requests` is installed from a git source in main packages and as a transitive dependency from PyPI in dev packages
- In Pipenv, it will be listed with the git URL and ref hash in main dependencies but with package name and version in dev dependencies
- Potential fix: Forward metadata from the virtual root package, which would populate the correct fields depending on how it's listed
## Development Roadmap
The following enhancements are planned for future releases:
### Code Improvements
- Refactor package traversal logic to eliminate code duplication between main and dev package handling
- Move type definitions into a separate module to improve code organization
- Add type validation using Pydantic TypeAdapter to ensure proper type definitions
### Testing Enhancements
- Improve test infrastructure by adding direct `uv` and `pipenv` execution capabilities
- Implement integration tests that compare virtual environments created from both `uv.lock` and `Pipfile.lock`
- Optimize test performance:
- Current approach: Generate `uv.lock`, then use `pipenv install <deps...>` for dependency resolution
- Planned approach: Create `requirements.txt` from `uv` with pinned versions, then use with `pipenv`
### Feature Development
- Implement recursive approach for package traversal to simplify marker forwarding
- Add multi-index support for more complex dependency configurations
- Implement PyPI API integration to retrieve missing hashes
- Consider publishing as a PyPI package based on community adoption
## Contributing
Contributions are welcome! Feel free to open issues or pull requests on GitHub.
## License
MIT
Raw data
{
"_id": null,
"home_page": null,
"name": "uv-to-pipfile",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "Pipfile.lock, dependency management, hook, pre-commit, python, uv.lock",
"author": null,
"author_email": "Flavio Amurrio <25621374+FlavioAmurrioCS@users.noreply.github.com>",
"download_url": "https://files.pythonhosted.org/packages/1a/25/52186608ca6c5eaaddba110818ff14c476fe072e4ec4797e55fe5ebf25db/uv_to_pipfile-0.0.7.tar.gz",
"platform": null,
"description": "# uv-to-pipfile\n\nA tool and pre-commit hook to convert `uv.lock` files to `Pipfile.lock` format, allowing you to use [uv](https://github.com/astral-sh/uv) for dependency resolution while maintaining compatibility with Pipenv workflows.\n\n## Installation\n\n<!-- Install from PyPI:\n\n```bash\npip install uv-to-pipfile\n```\n\n## Using uv-to-pipfile\n\n### As a CLI Tool\n\nRun directly from the command line:\n\n```bash\n# Convert uv.lock to Pipfile.lock in the current directory\nuv-to-pipfile\n\n# Specify an output file path\nuv-to-pipfile --pipfile-lock custom_path/Pipfile.lock\n``` -->\n\n### With pre-commit\n\nAdd this to your `.pre-commit-config.yaml`:\n\n```yaml\n- repo: https://github.com/FlavioAmurrioCS/uv-to-pipfile\n rev: v0.0.7 # Use the ref you want to point at\n hooks:\n - id: uv-to-pipfile\n```\n\n## How it works\n\n### Packages\n\nThe conversion process follows these steps:\n\n- `uv.lock` lists packages as an array. We parse all of these and create a dictionary where the key is the package name and the value is the package metadata.\n- We identify the virtual package which represents the project itself. This lists the dependencies.\n- We create a queue with these packages and iterate through them, adding each to the respective section (default or develop).\n- We then add their dependencies to the queue and continue processing.\n- We repeat the same process for dev packages.\n\n### Python Version Detection\n\nThe tool determines Python version requirements in the following order:\n\n1. Check for a `.python-version` file in the same directory as the `uv.lock` file\n2. Extract the `requires-python` field from the `uv.lock` (ignoring range markers such as `>=`)\n3. Default to Python 3.11 if no version information is found\n\n## Python Version Compatibility\n\nThis tool is compatible with Python 3.8 and later versions. The implementation is designed to work seamlessly across different Python environments:\n\n- For Python 3.11+: No additional dependencies are required as `tomllib` is included in the standard library\n- For Python 3.8-3.10: The `tomli` package is automatically installed as a dependency\n\nThe script can be executed in several ways:\n- As an installed package via `uv-to-pipfile` command\n- Directly as a PEP 723 compliant script using `pipx run`, `hatch run`, or `uv run`\n- With Python 3.11+ using standard `python uv_to_pipfile.py`\n\n## Known Issues and Limitations\n\n- `uv.lock` does not provide markers information. Pipenv doesn't seem to mind this omission.\n- `uv.lock` does not list all the hashes for a specific version. Some hashes might be filtered out.\n - Potential solution: Call the PyPI API to fetch missing hashes\n - Challenge: Additional work would be needed to support non-REST pip indexes like Artifactory\n- The `_meta.hash.sha256` value will be missing from generated `Pipfile.lock` files. This appears to be a hash of the Pipfile and doesn't seem necessary.\n- Currently, the tool only supports one index. Multi-index support could be added if needed.\n- System-specific dependencies might be handled differently:\n - For example, `colorama` is only needed on Windows machines\n - It may not be listed in the original `Pipfile.lock` but gets listed in `uv.lock`\n - Installing the generated `Pipfile.lock` might install packages not strictly needed on your platform\n- Dependencies installed in different ways across package sections may have different mappings:\n - For example, if `requests` is installed from a git source in main packages and as a transitive dependency from PyPI in dev packages\n - In Pipenv, it will be listed with the git URL and ref hash in main dependencies but with package name and version in dev dependencies\n - Potential fix: Forward metadata from the virtual root package, which would populate the correct fields depending on how it's listed\n\n## Development Roadmap\n\nThe following enhancements are planned for future releases:\n\n### Code Improvements\n- Refactor package traversal logic to eliminate code duplication between main and dev package handling\n- Move type definitions into a separate module to improve code organization\n- Add type validation using Pydantic TypeAdapter to ensure proper type definitions\n\n### Testing Enhancements\n- Improve test infrastructure by adding direct `uv` and `pipenv` execution capabilities\n- Implement integration tests that compare virtual environments created from both `uv.lock` and `Pipfile.lock`\n- Optimize test performance:\n - Current approach: Generate `uv.lock`, then use `pipenv install <deps...>` for dependency resolution\n - Planned approach: Create `requirements.txt` from `uv` with pinned versions, then use with `pipenv`\n\n### Feature Development\n- Implement recursive approach for package traversal to simplify marker forwarding\n- Add multi-index support for more complex dependency configurations\n- Implement PyPI API integration to retrieve missing hashes\n- Consider publishing as a PyPI package based on community adoption\n\n## Contributing\n\nContributions are welcome! Feel free to open issues or pull requests on GitHub.\n\n## License\n\nMIT\n",
"bugtrack_url": null,
"license": null,
"summary": "A tool to convert uv.lock files to Pipfile.lock.",
"version": "0.0.7",
"project_urls": {
"Documentation": "https://github.com/FlavioAmurrioCS/uv-to-pipfile#readme",
"Issues": "https://github.com/FlavioAmurrioCS/uv-to-pipfile/issues",
"Source": "https://github.com/FlavioAmurrioCS/uv-to-pipfile"
},
"split_keywords": [
"pipfile.lock",
" dependency management",
" hook",
" pre-commit",
" python",
" uv.lock"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "e4b3983d0a930c482067b97661fd0b5346e33a2b0e1dd45aaacbfcff7d91565a",
"md5": "9d9365a7388a55b6804626b3bd28db9c",
"sha256": "39a86ada0780215e7be9d207222342959caa2b4e3df7ab6d8b9cced852ec708d"
},
"downloads": -1,
"filename": "uv_to_pipfile-0.0.7-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9d9365a7388a55b6804626b3bd28db9c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 11531,
"upload_time": "2025-09-10T13:52:15",
"upload_time_iso_8601": "2025-09-10T13:52:15.651865Z",
"url": "https://files.pythonhosted.org/packages/e4/b3/983d0a930c482067b97661fd0b5346e33a2b0e1dd45aaacbfcff7d91565a/uv_to_pipfile-0.0.7-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "1a2552186608ca6c5eaaddba110818ff14c476fe072e4ec4797e55fe5ebf25db",
"md5": "ba5c18b8eec37a82209f9cfa7a7b3303",
"sha256": "d028502342615807e0c18152beb1913b377bd8604de94df3ede4cd7abeb6324f"
},
"downloads": -1,
"filename": "uv_to_pipfile-0.0.7.tar.gz",
"has_sig": false,
"md5_digest": "ba5c18b8eec37a82209f9cfa7a7b3303",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 17333,
"upload_time": "2025-09-10T13:52:17",
"upload_time_iso_8601": "2025-09-10T13:52:17.020565Z",
"url": "https://files.pythonhosted.org/packages/1a/25/52186608ca6c5eaaddba110818ff14c476fe072e4ec4797e55fe5ebf25db/uv_to_pipfile-0.0.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-10 13:52:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "FlavioAmurrioCS",
"github_project": "uv-to-pipfile#readme",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "uv-to-pipfile"
}