Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/abn/pep621-project-dependencies
https://github.com/abn/pep621-project-dependencies
Last synced: 7 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/abn/pep621-project-dependencies
- Owner: abn
- Created: 2020-09-06T19:48:19.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-09-07T10:31:08.000Z (over 4 years ago)
- Last Synced: 2024-11-18T07:50:02.551Z (about 1 month ago)
- Language: Python
- Size: 17.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PEP 621 Dependency Specification: TOML Proposal Library
This is a library demonstrating loading proposed TOML dependency specification from and to
[PEP 508](https://www.python.org/dev/peps/pep-0508/) strings for [PEP 621](https://www.python.org/dev/peps/pep-0621).The library also implements a sample dataclass based instances with validation for dependency specifications. As an
additional example, this also makes use of [lark-parser](https://github.com/lark-parser/lark) to parse a provided PEP 508
string.This is not supported code, this is put together for demonstration purposes only.
## Example Usage
### From PEP 508 to TOML
#### Versioned Dependencies
```console
$ python -m pep621_project_dependencies -f toml "pycowsay (==0.0.0.1)"
[project.dependencies]
pycowsay = { version = "==0.0.0.1" }[project.optional-dependencies]
$ python -m pep621_project_dependencies -f toml "requests[security,tests] (>= 2.8.1, == 2.8.*) ; python_version < '2.7'"
[project.dependencies]
requests = { extras = [ "security", "tests",], markers = "python_version < '2.7'", version = ">= 2.8.1, == 2.8.*" }[project.optional-dependencies]
```
#### Direct References (URL)
```console
$ python -m pep621_project_dependencies -f toml "pip @ https://github.com/pypa/pip/archive/1.3.1.zip#sha1=da9234ee9982d4bbb3c72346a6de940a148ea686"
[project.dependencies]
pip = { url = "https://github.com/pypa/pip/archive/1.3.1.zip", hash = "sha1=da9234ee9982d4bbb3c72346a6de940a148ea686" }[project.optional-dependencies]
```
#### Direct References (VCS)
```console
$ python -m pep621_project_dependencies -f toml "sphinx @ git+ssh://[email protected]/sphinx-doc/sphinx.git@master"
[project.dependencies]
[project.dependencies]
sphinx = { url = "ssh://[email protected]/sphinx-doc/sphinx.git", vcs = "git", revision = "master" }[project.optional-dependencies]
$ python -m pep621_project_dependencies -f toml "sphinx @ git+ssh://[email protected]/sphinx-doc/sphinx.git@master ; extra == 'doc'"
[project.dependencies][project.optional-dependencies.doc]
sphinx = { url = "ssh://[email protected]/sphinx-doc/sphinx.git", vcs = "git", revision = "master" }
```### From TOML to PEP 508
```console
$ python -m pep621_project_dependencies -f pep508 tests/fixtures/complete.toml
flask
numpy (~=1.18)
pycowsay (==0.0.0.1)
sphinx @ git+ssh://[email protected]/sphinx-doc/sphinx.git@master
pip @ https://github.com/pypa/pip/archive/1.3.1.zip#sha1=da9234ee9982d4bbb3c72346a6de940a148ea686
docker[ssh] (>= 4.2.2, < 5)
requests[security,tests] (>= 2.8.1, == 2.8.*) ; python_version < '2.7'
backports.shutil_get_terminal_size (== 1.0.0) ; python_version < '3.3'
backports.ssl_match_hostname (>= 3.5, < 4) ; python_version < '3.5'
colorama (>= 0.4, < 1) ; sys_platform == 'win32'
enum34 (>= 1.0.4, < 2) ; python_version < '3.4'
keyring (>=18.0.1, <18.1.0) ; python_version ~= '2.7'
keyring (>=20.0.1, <21.0.0) ; python_version ~= '3.5'
keyring (>=21.2.0) ; python_version >= '3.6'
PySocks (>= 1.5.6, != 1.5.7, < 2) ; extra == 'socks'
ddt (>= 1.2.2, < 2) ; extra == 'tests'
pytest (<6) ; python_version < '3.5' and extra == 'tests'
pytest (>=6) ; python_version >= '3.5' and extra == 'tests'
mock (>= 1.0.1, < 4) ; python_version < '3.4' and extra == 'tests'
```### Validation Error
```console
$ python -m pep621_project_dependencies -f pep508 tests/fixtures/invalid.toml
ERROR: Invalid direct dependency (pip) specified, only vcs dependencies can request a revision
```## TODO
- [x] Enhance PEP 508 URI parsing to decompose revision
- [ ] Add examples with multiple URI fragments?