Skip to content

Commit

Permalink
Migrate from poetry to PDM
Browse files Browse the repository at this point in the history
  • Loading branch information
PSU3D0 committed May 10, 2024
1 parent 61fa41d commit 14bac96
Show file tree
Hide file tree
Showing 12 changed files with 494 additions and 2,699 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ jobs:
run: |
sudo apt update && sudo apt install -y ghostscript
python -m pip install --upgrade pip
pip install poetry
poetry install --no-root --all-extras
pip install -U pdm
pdm install -d
- name: Lint with Ruff
run: |
poetry run ruff --output-format=github .
pdm run ruff --output-format=github .
- name: Test with pytest
run: |
poetry run pytest -sxv --cov --cov-report=xml .
pdm run pytest -sxv --cov --cov-report=xml .
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,16 @@ jobs:
run: |
sudo apt update && sudo apt install -y ghostscript
python -m pip install --upgrade pip
pip install poetry
poetry install --no-root --all-extras
pip install pdm
pdm install -d
- name: Run Pytest
run:
poetry run pytest -sxv
pdm run pytest -sxv

- name: Build wheels and source tarball
run: |
poetry version $(poetry version --short)-dev.$GITHUB_RUN_NUMBER
poetry version --short
poetry build
pdm build
- name: Publish package distributions to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
pip install pdm
- name: Build wheels and source tarball
run: >-
poetry build
pdm build
- name: show temporary files
run: >-
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,5 @@ site/
.creds/

data/

.pdm-python
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ repos:
args: [ --fix ]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/pappasam/toml-sort
rev: v0.23.1
hooks:
- id: toml-sort
- id: toml-sort-fix
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ Ready to contribute? Here's how to set up `docprompt` for local development.
$ git clone git@github.com:your_name_here/docprompt.git
```
3. Ensure [poetry](https://python-poetry.org/docs/) is installed.
3. Ensure [pdm](https://pdm-project.org/en/latest/) is installed.
4. Install dependencies and start your virtualenv:
```
$ poetry install -E test -E doc -E dev
$ pdm install -d
```
5. Create a branch for local development:
Expand All @@ -74,7 +74,7 @@ Ready to contribute? Here's how to set up `docprompt` for local development.
tests, including testing other Python versions, with tox:
```
$ poetry run tox
$ pdm run tox
```
7. Commit your changes and push your branch to GitHub:
Expand Down Expand Up @@ -102,7 +102,7 @@ Before you submit a pull request, check that it meets these guidelines:
## Tips
```
$ poetry run pytest tests/test_docprompt.py
$ pdm run pytest tests/test_docprompt.py
```
To run a subset of tests.
Expand All @@ -115,7 +115,7 @@ Make sure all your changes are committed (including an entry in CHANGELOG.md).
Then run:
```
$ poetry run bump2version patch # possible: major / minor / patch
$ pdm run bump2version patch # possible: major / minor / patch
$ git push
$ git push --tags
```
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![python](https://img.shields.io/pypi/pyversions/docprompt.svg)](https://pypi.org/project/docprompt/)
[![Build Status](https://github.com/Page-Leaf/Docprompt/actions/workflows/dev.yml/badge.svg)](https://github.com/Page-Leaf/docprompt/actions/workflows/dev.yml)
[![codecov](https://codecov.io/gh/Page-Leaf/Docprompt/branch/main/graphs/badge.svg)](https://codecov.io/github/Page-Leaf/Docprompt)

[![pdm-managed](https://img.shields.io/badge/pdm-managed-blueviolet)](https://pdm-project.org)

<br />
<div align="center">
Expand Down Expand Up @@ -154,3 +154,7 @@ document_node.locator.search("Jane Doe", page_number=4) # Just return results a
```
This functionality uses a combination of `rtree` and the Rust library `tantivy`, allowing you to perform thousands of searches in **seconds** :fire: :rocket:
<a href="https://trackgit.com">
<img src="https://us-central1-trackgit-analytics.cloudfunctions.net/token/ping/lw098gfpjhrd7b2ev4rl" alt="trackgit-views" />
</a>
423 changes: 423 additions & 0 deletions pdm.lock

Large diffs are not rendered by default.

2,568 changes: 0 additions & 2,568 deletions poetry.lock

This file was deleted.

153 changes: 42 additions & 111 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,108 +1,43 @@
[tool]
[tool.poetry]
[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"

[project]
name = "docprompt"
version = "0.4.4"
homepage = "https://github.com/Page-Leaf/docprompt"
description = "Documents and large language models."
authors = ["Frankie Colson <frank@pageleaf.io>"]
readme = "README.md"
license = "Apache-2.0"
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
]
packages = [
{ include = "docprompt" },
{ include = "tests", format = "sdist" },
]

[tool.poetry.dependencies]
python = ">=3.8.1,<3.13"

isort = { version = "^5.12.0", optional = true}
flake8 = { version = "^6.1.0", optional = true}
flake8-docstrings = { version = "^1.7.0", optional = true }
mypy = {version = "^1.6.1", optional = true}
pytest = { version = "^7.4.2", optional = true}
pytest-cov = { version = "^4.1.0", optional = true}
tox = { version = "^3.20.1", optional = true}
virtualenv = { version = "^20.2.2", optional = true}
pip = { version = "^20.3.1", optional = true}
mkdocs = { version = "^1.1.2", optional = true}
mkdocs-include-markdown-plugin = { version = "^1.0.0", optional = true}
mkdocs-material = { version = "^6.1.7", optional = true}
mkdocstrings = { version = "^0.15.2", optional = true}
mkdocs-material-extensions = { version = "^1.0.1", optional = true}
twine = { version = "^3.3.0", optional = true}
mkdocs-autorefs = {version = "^0.2.1", optional = true}
pre-commit = {version = "^2.12.0", optional = true}
toml = {version = "^0.10.2", optional = true}
bump2version = {version = "^1.0.1", optional = true}
python-dateutil = "^2.8.2"

numpy = {version = "^1.20.3", optional = true}
pillow = ">=9.0.1"
python-magic = ">=0.4.24"
google-cloud-documentai = {version = ">=2.20.0", optional = true}
azure-ai-formrecognizer = {version = ">=3.3.0", optional = true}
tqdm = ">=4.61.0"
fsspec = ">=2022.11.0"
pydantic = ">=2.1.0"
tenacity = ">=7.0.0"
pypdfium2 = "^4.28.0"
tantivy = {version = "^0.21.0", optional = true}
rtree = {version = "^1.2.0", optional = true}
networkx = {version = ">=2.8.8", optional = true}
rapidfuzz = ">=3.0.0"
ruff = {version = "^0.3.3", optional = true}

[tool.poetry.extras]
test = [
"pytest",
"isort",
"mypy",
"flake8",
"flake8-docstrings",
"pytest-cov",
"ruff"
]

dev = ["tox", "pre-commit", "virtualenv", "pip", "twine", "toml", "bump2version"]

doc = [
"mkdocs",
"mkdocs-include-markdown-plugin",
"mkdocs-material",
"mkdocstrings",
"mkdocs-material-extension",
"mkdocs-autorefs"
]

google = [
"google-cloud-documentai"
authors = [
{name = "Frank Colson", email = "frank@pageleaf.io"}
]

azure = [
"azure-ai-formrecognizer"
dependencies = [
"python-dateutil<3.0.0,>=2.8.2",
"pillow>=9.0.1",
"python-magic>=0.4.24",
"tqdm>=4.50.2",
"fsspec>=2022.11.0",
"pydantic>=2.1.0",
"tenacity>=7.0.0",
"pypdfium2<5.0.0,>=4.28.0",
"rapidfuzz>=3.0.0"
]
requires-python = "<3.13,>=3.8.1"
readme = "README.md"
license = {text = "Apache-2.0"}
classifiers = ["Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12"]

search = [
"tantivy",
"rtree",
"networkx"
]
[project.optional-dependencies]
test = ["isort<6.0.0,>=5.12.0", "flake8<7.0.0,>=6.1.0", "flake8-docstrings<2.0.0,>=1.7.0", "mypy<2.0.0,>=1.6.1", "pytest<8.0.0,>=7.4.2", "pytest-cov<5.0.0,>=4.1.0", "ruff<1.0.0,>=0.3.3"]
dev = ["tox<4.0.0,>=3.20.1", "virtualenv<21.0.0,>=20.2.2", "pip<21.0.0,>=20.3.1", "twine<4.0.0,>=3.3.0", "pre-commit<3.0.0,>=2.12.0", "toml<1.0.0,>=0.10.2", "bump2version<2.0.0,>=1.0.1"]
doc = ["mkdocs<2.0.0,>=1.1.2", "mkdocs-include-markdown-plugin<2.0.0,>=1.0.0", "mkdocs-material<7.0.0,>=6.1.7", "mkdocstrings<1.0.0,>=0.15.2", "mkdocs-autorefs<1.0.0,>=0.2.1"]
google = ["google-cloud-documentai>=2.20.0"]
azure = ["azure-ai-formrecognizer>=3.3.0"]
search = ["tantivy<1.0.0,>=0.21.0", "rtree<2.0.0,>=1.2.0", "networkx>=2.8.8"]

[project.scripts]
docprompt = "docprompt.cli:main"

[tool.poetry.scripts]
docprompt = 'docprompt.cli:main'
[project.urls]
homepage = "https://github.com/Page-Leaf/docprompt"

[tool.black]
line-length = 120
Expand All @@ -124,6 +59,11 @@ exclude = '''
)/
'''

[tool.flake8]
ignore = [
"E501"
]

[tool.isort]
multi_line_output = 3
include_trailing_comma = true
Expand All @@ -132,33 +72,24 @@ use_parentheses = true
ensure_newline_before_comments = true
line_length = 120
skip_gitignore = true
# you can skip files as below
#skip_glob = docs/conf.py

[tool.flake8]
ignore = [
"E501",
]
[tool.pdm]
distribution = true

[tool.pdm.build]
includes = ["docprompt", "tests"]

[tool.ruff]
target-version = "py38"


[tool.ruff.lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["E4", "E7", "E9", "F"]
ignore = []

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"


[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ commands =

[testenv:build]
allowlist_externals =
poetry
pdm
mkdocs
twine
extras =
doc
dev
commands =
poetry build
pdm build
mkdocs build
twine check dist/*
Empty file added src/docprompt/__init__.py
Empty file.

0 comments on commit 14bac96

Please sign in to comment.