---
title: "dep-logic | pypx"
description: "Python dependency specifications supporting logical operations"
canonical_url: "https://pypx.app/packages/dep-logic"
meta:
  "og:description": "Python dependency specifications supporting logical operations"
  "og:image": "https://pypx.app/_og/d/h_630%2Cc_PackageCard%2Cname_dep-logic%2Cversion_0.8.0%2Csummary_Python%2Bdependency%2Bspecifications%2Bsupporting%2Blogical%2Boperations%2Clicense_Apache%2BSoftware%2BLicense%2Cp_Ii9wYWNrYWdlcy9kZXAtbG9naWMi%2Cs_h057ngaA2kL-fC5d.png"
  "og:image:height": "630"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "dep-logic 0.8.0"
  "twitter:image": "https://pypx.app/_og/d/h_630%2Cc_PackageCard%2Cname_dep-logic%2Cversion_0.8.0%2Csummary_Python%2Bdependency%2Bspecifications%2Bsupporting%2Blogical%2Boperations%2Clicense_Apache%2BSoftware%2BLicense%2Cp_Ii9wYWNrYWdlcy9kZXAtbG9naWMi%2Cs_h057ngaA2kL-fC5d.png"
---

> Index of every page on this site: [llms.txt](https://pypx.app/llms.txt)

# **dep-logic**

v0.8.0

Python dependency specifications supporting logical operations

35 KB Python 3.10+ py3-none-anyApache Software License1 deps

[** Diff **](https://pypx.app/packages/dep-logic/diff)

`$ uv add dep-logic`

# 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

```
pip install dep-logic
```

This library requires Python 3.10 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.

## **Details **

<dl>

<dt>Version</dt>
<dd>0.8.0</dd>

<dt>License</dt>
<dd>Apache Software License</dd>

<dt>Python</dt>
<dd>&gt;=3.10</dd>

<dt>Maintainer</dt>
<dd>Frost Ming &lt;me@frostming.com&gt;</dd></dl>

## **Links**

- [View on PyPI](https://pypi.org/project/dep-logic/)

## **Release Cadence **

**5**

releases in the past year

avg 35 days between releases

## **Maintainers **

- Frost Ming · [me@frostming.com](mailto:me@frostming.com)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://pypx.app/#website","@type":"WebSite","description":"The Python Package Index, reimagined. Fast search, dependency insights, download trends, and changelogs — all in one place.","name":"pypx","url":"https://pypx.app/"},{"@id":"https://pypx.app/packages/dep-logic#webpage","@type":"WebPage","description":"Python dependency specifications supporting logical operations","name":"dep-logic","url":"https://pypx.app/packages/dep-logic","isPartOf":{"@id":"https://pypx.app/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://pypx.app/packages/dep-logic"]}]},{"@id":"https://pypx.app/packages/dep-logic#/schema/software-application/1","@type":"SoftwareApplication","applicationCategory":"DeveloperApplication","description":"Python dependency specifications supporting logical operations","license":"Apache Software License","name":"dep-logic","softwareVersion":"0.8.0"}]}
```

## Sitemap

See the full [sitemap](https://pypx.app/sitemap.md) for all pages.
