# Dep-Logic



Python dependency specifications supporting logical operations
## Installation
```bash
pip install dep-logic
```
This library requires Python 3.8 or later.
Currently, it contains two sub-modules:
- `dep_logic.specifier` - a module for parsing and calculating PEP 440 version specifiers.
- `dep_logic.markers` - a module for parsing and calculating PEP 508 environment markers.
## What does it do?
This library allows logic operations on version specifiers and environment markers.
For example:
```pycon
>>> from dep_logic.specifiers import parse_version_specifier
>>>
>>> a = parse_version_specifier(">=1.0.0")
>>> b = parse_version_specifier("<2.0.0")
>>> print(a & b)
>=1.0.0,<2.0.0
>>> a = parse_version_specifier(">=1.0.0,<2.0.0")
>>> b = parse_version_specifier(">1.5")
>>> print(a | b)
>=1.0.0
```
For markers:
```pycon
>>> from dep_logic.markers import parse_marker
>>> m1 = parse_marker("python_version < '3.8'")
>>> m2 = parse_marker("python_version >= '3.6'")
>>> print(m1 & m2)
python_version < "3.8" and python_version >= "3.6"
```
## About the project
This project is based on @sdispater's [poetry-core](https://github.com/python-poetry/poetry-core) code, but it includes additional packages and a lark parser, which increases the package size and makes it less reusable.
Furthermore, `poetry-core` does not always comply with PEP-508. As a result, this project aims to offer a lightweight utility for dependency specification logic using [PyPA's packaging](https://github.com/pypa/packaging).
Submodules:
- `dep_logic.specifiers` - PEP 440 version specifiers
- `dep_logic.markers` - PEP 508 environment markers
- `dep_logic.tags` - PEP 425 platform tags
## Caveats
Logic operations with `===<string>` specifiers is partially supported.
Raw data
{
"_id": null,
"home_page": null,
"name": "dep-logic",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "dependency, specification, logic, packaging",
"author": null,
"author_email": "Frost Ming <me@frostming.com>",
"download_url": "https://files.pythonhosted.org/packages/d8/00/93a90a4ce514e63a181486c6408ea50e8cdf7cdb73ab5580a6f7f5e5a496/dep_logic-0.5.2.tar.gz",
"platform": null,
"description": "# Dep-Logic\n\n\n\n\n\n\nPython dependency specifications supporting logical operations\n\n## Installation\n\n```bash\npip install dep-logic\n```\n\nThis library requires Python 3.8 or later.\n\nCurrently, it contains two sub-modules:\n\n- `dep_logic.specifier` - a module for parsing and calculating PEP 440 version specifiers.\n- `dep_logic.markers` - a module for parsing and calculating PEP 508 environment markers.\n\n## What does it do?\n\nThis library allows logic operations on version specifiers and environment markers.\n\nFor example:\n\n```pycon\n>>> from dep_logic.specifiers import parse_version_specifier\n>>>\n>>> a = parse_version_specifier(\">=1.0.0\")\n>>> b = parse_version_specifier(\"<2.0.0\")\n>>> print(a & b)\n>=1.0.0,<2.0.0\n>>> a = parse_version_specifier(\">=1.0.0,<2.0.0\")\n>>> b = parse_version_specifier(\">1.5\")\n>>> print(a | b)\n>=1.0.0\n```\n\nFor markers:\n\n```pycon\n>>> from dep_logic.markers import parse_marker\n>>> m1 = parse_marker(\"python_version < '3.8'\")\n>>> m2 = parse_marker(\"python_version >= '3.6'\")\n>>> print(m1 & m2)\npython_version < \"3.8\" and python_version >= \"3.6\"\n```\n\n## About the project\n\nThis project is based on @sdispater's [poetry-core](https://github.com/python-poetry/poetry-core) code, but it includes additional packages and a lark parser, which increases the package size and makes it less reusable.\n\nFurthermore, `poetry-core` does not always comply with PEP-508. As a result, this project aims to offer a lightweight utility for dependency specification logic using [PyPA's packaging](https://github.com/pypa/packaging).\n\nSubmodules:\n\n- `dep_logic.specifiers` - PEP 440 version specifiers\n- `dep_logic.markers` - PEP 508 environment markers\n- `dep_logic.tags` - PEP 425 platform tags\n\n## Caveats\n\nLogic operations with `===<string>` specifiers is partially supported.\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Python dependency specifications supporting logical operations",
"version": "0.5.2",
"project_urls": null,
"split_keywords": [
"dependency",
" specification",
" logic",
" packaging"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "0ca4c6927ef27a8da0788da2fa5f577df6423102c0b50cbabd80f867570949ef",
"md5": "9b2d07628b2d20217e033cda7e2b2113",
"sha256": "0e72ab6676afd32fe8702896a8b9886bddd6ccd457b77ba360e7b6c4c95ce4c0"
},
"downloads": -1,
"filename": "dep_logic-0.5.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9b2d07628b2d20217e033cda7e2b2113",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 35733,
"upload_time": "2025-08-02T00:22:19",
"upload_time_iso_8601": "2025-08-02T00:22:19.497809Z",
"url": "https://files.pythonhosted.org/packages/0c/a4/c6927ef27a8da0788da2fa5f577df6423102c0b50cbabd80f867570949ef/dep_logic-0.5.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "d80093a90a4ce514e63a181486c6408ea50e8cdf7cdb73ab5580a6f7f5e5a496",
"md5": "781b9036d1e3205dccc5ffcf8e576891",
"sha256": "f8dc4a74d1bad0d35a45c236572cf5d6534b5c2e84de87f2a354c849eec7e562"
},
"downloads": -1,
"filename": "dep_logic-0.5.2.tar.gz",
"has_sig": false,
"md5_digest": "781b9036d1e3205dccc5ffcf8e576891",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 36816,
"upload_time": "2025-08-02T00:22:20",
"upload_time_iso_8601": "2025-08-02T00:22:20.706435Z",
"url": "https://files.pythonhosted.org/packages/d8/00/93a90a4ce514e63a181486c6408ea50e8cdf7cdb73ab5580a6f7f5e5a496/dep_logic-0.5.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-02 00:22:20",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "dep-logic"
}