Skip to content

Commit

Permalink
#316 - Switch to using plain pyproject.toml
Browse files Browse the repository at this point in the history
- Manage dependencies in requirements files
- Use pip-tools to manage dependencies
- Remove poetry
  • Loading branch information
reckart committed May 6, 2024
1 parent 804540d commit 28478b1
Show file tree
Hide file tree
Showing 13 changed files with 351 additions and 1,189 deletions.
1 change: 0 additions & 1 deletion .github/workflows/publish_to_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:
python-version: '3.11'
- name: Install dependencies
run: |
pip install poetry
make dependencies
- name: Run tests
run: make unit-tests
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install poetry
make dependencies
- name: Lint with flake8
Expand Down
13 changes: 8 additions & 5 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ build:
os: ubuntu-22.04
tools:
python: "3.11"
jobs:
post_create_environment:
- python -m pip install poetry
post_install:
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --only main,docs

sphinx:
configuration: docs/conf.py

python:
install:
- method: pip
path: .
extra_requirements:
- doc
35 changes: 17 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,45 +1,44 @@
.PHONY: docs tests
PYTHON_FILES = cassis tests

clean:
rm -Rf build dkpro_cassis.egg-info dist

# Dependencies
pin:
rm requirements.txt requirements-dev.txt requirements-doc.txt
pip-compile -o requirements.txt pyproject.toml
pip-compile --extra dev -o requirements-dev.txt pyproject.toml
pip-compile --extra doc -o requirements-doc.txt pyproject.toml

dependencies:
poetry install
pip install pip-tools
pip-sync requirements.txt requirements-dev.txt

# Tests
unit-tests:
poetry run py.test --cov=cassis --cov-branch --cov-fail-under=90 tests
python -m pytest --cov=cassis --cov-branch --cov-fail-under=90 tests

tests: unit-tests integ-tests

coverage:
poetry run py.test --cov=cassis --cov-branch --cov-fail-under=90 --cov-report=xml:coverage.xml -m "not performance" tests
python -m pytest --cov=cassis --cov-branch --cov-fail-under=90 --cov-report=xml:coverage.xml -m "not performance" tests

# Static analysis/linting
format:
poetry run ruff format $(PYTHON_FILES)
ruff format $(PYTHON_FILES)

lint:
# stop the build if there are Python syntax errors or undefined names
poetry run ruff check --select=E9,F63,F7,F82 --output-format=full $(PYTHON_FILES)
ruff check --select=E9,F63,F7,F82 --output-format=full $(PYTHON_FILES)
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
poetry run ruff check --exit-zero $(PYTHON_FILES)
ruff check --exit-zero $(PYTHON_FILES)

# Docs
docs:
cd docs && make html

# Building and publishing
build: unit-tests lint
poetry build

publish: build
poetry publish

# CI

ci-publish:
poetry publish --build --username "${PYPI_USERNAME}" --password "${PYPI_PASSWORD}" --no-interaction

ci-bump-version:
poetry run bump2version patch
python -m build
35 changes: 29 additions & 6 deletions cassis/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,35 @@
from toposort import toposort_flatten

from cassis.cas import NAME_DEFAULT_SOFA, Cas, IdGenerator, Sofa, View
from cassis.typesystem import TYPE_NAME_ANNOTATION, TypeSystem, is_predefined, merge_typesystems, TYPE_NAME_SOFA, \
FEATURE_BASE_NAME_SOFAARRAY, array_type_name_for_type, FEATURE_BASE_NAME_SOFASTRING, FEATURE_BASE_NAME_SOFAID, \
FEATURE_BASE_NAME_SOFAMIME, FEATURE_BASE_NAME_SOFANUM, FEATURE_BASE_NAME_SOFAURI, TYPE_NAME_FS_ARRAY, \
TYPE_NAME_BYTE_ARRAY, TYPE_NAME_FLOAT_ARRAY, TYPE_NAME_DOUBLE_ARRAY, TypeSystemMode, TYPE_NAME_DOCUMENT_ANNOTATION, \
Type, Feature, TYPE_NAME_TOP, is_primitive_array, TYPE_NAME_FLOAT, TYPE_NAME_DOUBLE, \
element_type_name_for_array_type, is_primitive, is_array
from cassis.typesystem import (
TYPE_NAME_ANNOTATION,
TypeSystem,
is_predefined,
merge_typesystems,
TYPE_NAME_SOFA,
FEATURE_BASE_NAME_SOFAARRAY,
array_type_name_for_type,
FEATURE_BASE_NAME_SOFASTRING,
FEATURE_BASE_NAME_SOFAID,
FEATURE_BASE_NAME_SOFAMIME,
FEATURE_BASE_NAME_SOFANUM,
FEATURE_BASE_NAME_SOFAURI,
TYPE_NAME_FS_ARRAY,
TYPE_NAME_BYTE_ARRAY,
TYPE_NAME_FLOAT_ARRAY,
TYPE_NAME_DOUBLE_ARRAY,
TypeSystemMode,
TYPE_NAME_DOCUMENT_ANNOTATION,
Type,
Feature,
TYPE_NAME_TOP,
is_primitive_array,
TYPE_NAME_FLOAT,
TYPE_NAME_DOUBLE,
element_type_name_for_array_type,
is_primitive,
is_array,
)

RESERVED_FIELD_PREFIX = "%"
REF_FEATURE_PREFIX = "@"
Expand Down
1,119 changes: 0 additions & 1,119 deletions poetry.lock

This file was deleted.

59 changes: 20 additions & 39 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
[tool.poetry]
[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[project]
name = "dkpro-cassis"
version = "0.10.0-dev"
readme = "README.rst"
homepage = "https://dkpro.github.io"
repository = "https://github.com/dkpro/dkpro-cassis"
documentation = "https://cassis.readthedocs.io"
dynamic = ["dependencies", "optional-dependencies"]
requires-python = ">=3.8"
authors = [ { name = "The DKPro cassis team" } ]
maintainers = [ { name = "Richard Eckart de Castilho" } ]
description = "UIMA CAS processing library in Python"
authors = ["The DKPro cassis team"]
maintainers = [ "Richard Eckart de Castilho" ]
license = "Apache-2.0"
packages = [
{ include = "cassis" },
]
readme = "README.rst"
license = {file = "LICENSE"}
keywords = []
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
Expand All @@ -27,39 +28,19 @@ classifiers = [
"Topic :: Text Processing :: Linguistic"
]

[tool.poetry.dependencies]
python = ">=3.8.0"
lxml = "^4.9.1"
attrs = "^21.2,<24"
sortedcontainers = "==2.4.*"
toposort = "==1.7"
more-itertools = "^8.12,<9"
deprecation = "==2.1.*"
importlib_resources = "==5.4.*"

[tool.poetry.dev-dependencies]
pytest = "^7.2"
tox = "==3.24.*"
lxml-asserts = "==0.1.*"
pytest-lazy-fixture = "==0.6.*"
pytest-cov = "^3.0"
codecov = "^2.1"
rstcheck = "==3.3.*"
docutils = "!=0.21"
ruff = "^0.4.3"
[tool.setuptools.dynamic]
dependencies = { file = ["requirements.in"] }
optional-dependencies.dev = { file = ["requirements-dev.in"] }
optional-dependencies.doc = { file = ["requirements-dev.in"] }

[tool.poetry.group.docs.dependencies]
sphinx = "^7.1.2"
sphinx-autodoc-typehints = "^1.25.3"
sphinx-rtd-theme = "^2.0.0"
[project.urls]
Homepage = "https://dkpro.github.io"
Documentation = "https://cassis.readthedocs.io"
Repository = "https://github.com/dkpro/dkpro-cassis"

[tool.ruff]
line-length = 120
target-version = "py38"

[tool.ruff.lint.per-file-ignores]
"**/{tests,docs,tools}/*" = [ "F403", "F405" ]

[build-system]
requires = ["poetry_core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
10 changes: 10 additions & 0 deletions requirements-dev.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pytest~=7.2
tox~=3.24
lxml-asserts~=0.1
pytest-lazy-fixture~=0.6
pytest-cov~=3.0
codecov~=2.1
rstcheck~=3.3
docutils~=0.20,!=0.21.*
ruff~=0.4.3
pip-tools~=7.4.1
116 changes: 116 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile --extra=dev --output-file=requirements-dev.txt pyproject.toml
#
attrs==23.2.0
# via dkpro-cassis (pyproject.toml)
build==1.2.1
# via pip-tools
certifi==2024.2.2
# via requests
charset-normalizer==3.3.2
# via requests
click==8.1.7
# via pip-tools
codecov==2.1.13
# via dkpro-cassis (pyproject.toml)
coverage[toml]==7.5.1
# via
# codecov
# pytest-cov
deprecation==2.1.0
# via dkpro-cassis (pyproject.toml)
distlib==0.3.8
# via virtualenv
docutils==0.20.1
# via
# dkpro-cassis (pyproject.toml)
# rstcheck
exceptiongroup==1.2.1
# via pytest
filelock==3.14.0
# via
# tox
# virtualenv
idna==3.7
# via requests
importlib-metadata==7.1.0
# via build
importlib-resources==5.13.0
# via dkpro-cassis (pyproject.toml)
iniconfig==2.0.0
# via pytest
lxml==4.9.4
# via
# dkpro-cassis (pyproject.toml)
# lxml-asserts
lxml-asserts==0.1.2
# via dkpro-cassis (pyproject.toml)
more-itertools==8.14.0
# via dkpro-cassis (pyproject.toml)
packaging==24.0
# via
# build
# deprecation
# pytest
# tox
pip-tools==7.4.1
# via dkpro-cassis (pyproject.toml)
platformdirs==4.2.1
# via virtualenv
pluggy==1.5.0
# via
# pytest
# tox
py==1.11.0
# via tox
pyproject-hooks==1.1.0
# via
# build
# pip-tools
pytest==7.4.4
# via
# dkpro-cassis (pyproject.toml)
# pytest-cov
# pytest-lazy-fixture
pytest-cov==3.0.0
# via dkpro-cassis (pyproject.toml)
pytest-lazy-fixture==0.6.3
# via dkpro-cassis (pyproject.toml)
requests==2.31.0
# via codecov
rstcheck==3.5.0
# via dkpro-cassis (pyproject.toml)
ruff==0.4.3
# via dkpro-cassis (pyproject.toml)
six==1.16.0
# via tox
sortedcontainers==2.4.0
# via dkpro-cassis (pyproject.toml)
tomli==2.0.1
# via
# build
# coverage
# pip-tools
# pytest
# tox
toposort==1.10
# via dkpro-cassis (pyproject.toml)
tox==3.28.0
# via dkpro-cassis (pyproject.toml)
urllib3==2.2.1
# via requests
virtualenv==20.26.1
# via tox
wheel==0.43.0
# via pip-tools
zipp==3.18.1
# via
# importlib-metadata
# importlib-resources

# The following packages are considered to be unsafe in a requirements file:
# pip
# setuptools
4 changes: 4 additions & 0 deletions requirements-doc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sphinx
sphinx-autodoc-typehints
sphinx-rtd-theme
docutils~=0.20,!=0.21.*
Loading

0 comments on commit 28478b1

Please sign in to comment.