dep-logic


Namedep-logic JSON
Version 0.2.0 PyPI version JSON
download
home_page
SummaryPython dependency specifications supporting logical operations
upload_time2024-02-23 05:01:45
maintainer
docs_urlNone
author
requires_python>=3.8
licenseApache-2.0
keywords dependency specification logic packaging
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Dep-Logic

![PyPI - Version](https://img.shields.io/pypi/v/dep-logic)
![Python Version from PEP 621 TOML](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2Fpdm-project%2Fdep-logic%2Fmain%2Fpyproject.toml)
![GitHub License](https://img.shields.io/github/license/pdm-project/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).

## Caveats

Logic operations with `===<string>` specifiers is partially supported.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "dep-logic",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "dependency specification logic packaging",
    "author": "",
    "author_email": "Frost Ming <me@frostming.com>",
    "download_url": "https://files.pythonhosted.org/packages/21/d5/c365826c3d0b65b9cc273bdf2e99022ada232fb95502f4efd98a8f9e31aa/dep_logic-0.2.0.tar.gz",
    "platform": null,
    "description": "# Dep-Logic\n\n![PyPI - Version](https://img.shields.io/pypi/v/dep-logic)\n![Python Version from PEP 621 TOML](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2Fpdm-project%2Fdep-logic%2Fmain%2Fpyproject.toml)\n![GitHub License](https://img.shields.io/github/license/pdm-project/dep-logic)\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\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.2.0",
    "project_urls": null,
    "split_keywords": [
        "dependency",
        "specification",
        "logic",
        "packaging"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a3e8ec37271adcae1f4f98f47d02b1b34a3c83a09425d173d40cb25ea98de75f",
                "md5": "a1ac4b25a3db8a6f24f0abecd826c079",
                "sha256": "af439c2acaf7522dd321a71f30e0c4fd59b7553eb99967af07d53320902cde39"
            },
            "downloads": -1,
            "filename": "dep_logic-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a1ac4b25a3db8a6f24f0abecd826c079",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 26925,
            "upload_time": "2024-02-23T05:01:42",
            "upload_time_iso_8601": "2024-02-23T05:01:42.513657Z",
            "url": "https://files.pythonhosted.org/packages/a3/e8/ec37271adcae1f4f98f47d02b1b34a3c83a09425d173d40cb25ea98de75f/dep_logic-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "21d5c365826c3d0b65b9cc273bdf2e99022ada232fb95502f4efd98a8f9e31aa",
                "md5": "d42f4da62c6d8be6c9eca73a4d7412bd",
                "sha256": "cff502b515aff2d413d19d6afc70174fc67da19e821be4a9b68460ccee2514c9"
            },
            "downloads": -1,
            "filename": "dep_logic-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "d42f4da62c6d8be6c9eca73a4d7412bd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 27758,
            "upload_time": "2024-02-23T05:01:45",
            "upload_time_iso_8601": "2024-02-23T05:01:45.861373Z",
            "url": "https://files.pythonhosted.org/packages/21/d5/c365826c3d0b65b9cc273bdf2e99022ada232fb95502f4efd98a8f9e31aa/dep_logic-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-23 05:01:45",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "dep-logic"
}
        
Elapsed time: 0.19112s