Skip to content

Commit

Permalink
Merge branch 'git-versioning'
Browse files Browse the repository at this point in the history
  • Loading branch information
kba committed Dec 15, 2023
2 parents 8a8c1e7 + 29d4c23 commit 65c6f03
Show file tree
Hide file tree
Showing 19 changed files with 327 additions and 147 deletions.
30 changes: 18 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ SPHINX_APIDOC =
BUILD_ORDER = ocrd_utils ocrd_models ocrd_modelfactory ocrd_validators ocrd_network ocrd
reverse = $(if $(wordlist 2,2,$(1)),$(call reverse,$(wordlist 2,$(words $(1)),$(1))) $(firstword $(1)),$(1))

PEP_440_PATTERN := '([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*((a|b|rc)(0|[1-9][0-9]*))?(\.post(0|[1-9][0-9]*))?(\.dev(0|[1-9][0-9]*))?'
OCRD_VERSION != fgrep version= ocrd_utils/setup.py | grep -Eo $(PEP_440_PATTERN)

# BEGIN-EVAL makefile-parser --make-help Makefile

help:
Expand All @@ -25,9 +22,10 @@ help:
@echo " deps-cuda Dependencies for deployment with GPU support via Conda"
@echo " deps-ubuntu Dependencies for deployment in an Ubuntu/Debian Linux"
@echo " deps-test Install test python deps via pip"
@echo " install (Re)install the tool"
@echo " build (Re)build source and binary distributions of pkges"
@echo " install (Re)install the packages"
@echo " install-dev Install with pip install -e"
@echo " uninstall Uninstall the tool"
@echo " uninstall Uninstall the packages"
@echo " generate-page Regenerate python code from PAGE XSD"
@echo " spec Copy JSON Schema, OpenAPI from OCR-D/spec"
@echo " assets Setup test assets"
Expand All @@ -52,6 +50,8 @@ help:
# pip install command. Default: $(PIP_INSTALL)
PIP_INSTALL ?= $(PIP) install

.PHONY: deps-cuda deps-ubuntu deps-test

deps-cuda: CONDA_EXE ?= /usr/local/bin/conda
deps-cuda: export CONDA_PREFIX ?= /conda
deps-cuda: PYTHON_PREFIX != $(PYTHON) -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])'
Expand Down Expand Up @@ -115,16 +115,24 @@ deps-test:
$(PIP) install -U pip
$(PIP) install -r requirements_test.txt

.PHONY: build install install-dev uninstall

build:
$(PIP) install build setuptools_scm
$(foreach MODULE,$(BUILD_ORDER),$(PYTHON) -m build ./$(MODULE) &&) echo done
# or use -n ?

# (Re)install the tool
install:
# $(PIP_INSTALL) $(BUILD_ORDER:%=./%/dist/ocrd$*(OCRD_VERSION)*.whl)
install: #build
# $(PIP_INSTALL) $(BUILD_ORDER:%=./%/dist/ocrd*`$(PYTHON) -m setuptools_scm 2>/dev/null`*.whl)
$(foreach MODULE,$(BUILD_ORDER),$(PIP_INSTALL) ./$(MODULE) &&) echo done
@# workaround for shapely#1598
$(PIP) config set global.no-binary shapely

# Install with pip install -e
install-dev: PIP_INSTALL = $(PIP) install -e
install-dev: uninstall
$(MAKE) install PIP_INSTALL="$(PIP) install -e"
$(MAKE) install

# Uninstall the tool
uninstall:
Expand Down Expand Up @@ -281,7 +289,5 @@ docker docker-cuda:
docker build --progress=plain -f $(DOCKER_FILE) -t $(DOCKER_TAG) --build-arg BASE_IMAGE=$(DOCKER_BASE_IMAGE) $(DOCKER_ARGS) .

# Build wheels and source dist and twine upload them
pypi: uninstall install
$(PIP) install build
$(foreach MODULE,$(BUILD_ORDER),$(PYTHON) -m build -n ./$(MODULE) &&) echo done
twine upload ocrd*/dist/ocrd*$(OCRD_VERSION)*{tar.gz,whl}
pypi: build
twine upload ocrd*/dist/ocrd*`$(PYTHON) -m setuptools_scm 2>/dev/null`*{tar.gz,whl}
42 changes: 42 additions & 0 deletions ocrd/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[build-system]
requires = [
"setuptools>=61",
"setuptools_scm[toml]",
"wheel",
] # PEP 508 specifications.
build-backend = "setuptools.build_meta"

[project]
name = "ocrd"
authors = [{name = "Konstantin Baierer", email = "[email protected]"}]
license = {text = "Apache License 2.0"}
description = "OCR-D framework"
requires-python = ">=3.7"
dynamic = ["version", "dependencies"]

[project.readme]
file = "README.md"
content-type = "text/markdown"

[tool.setuptools.dynamic.dependencies]
file = ["requirements.txt"]

[project.urls]
Homepage = "https://ocr-d.de"
Documentation = "https://ocr-d.de/core"
Repository = "https://github.com/OCR-D/core"
Issues = "https://github.com/OCR-D/core/issues"

[project.scripts]
ocrd = "ocrd.cli:cli"
ocrd-dummy = "ocrd.processor.builtin.dummy_processor:cli"

[tool.setuptools]
include-package-data = true

[tool.setuptools.packages.find]
exclude = ["tests"] # docs
namespaces = false

[tool.setuptools_scm]
root = ".."
5 changes: 5 additions & 0 deletions ocrd/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ fastapi
python-multipart
requests_unixsocket
gdown
ocrd_utils
ocrd_models
ocrd_modelfactory
ocrd_validators
ocrd_network
38 changes: 11 additions & 27 deletions ocrd/setup.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,16 @@
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages
from ocrd_utils import VERSION
from setuptools import setup, Command
from setuptools.command.build import build as orig_build

install_requires = open('requirements.txt').read().split('\n')
install_requires.append('ocrd_utils == %s' % VERSION)
install_requires.append('ocrd_models == %s' % VERSION)
install_requires.append('ocrd_modelfactory == %s' % VERSION)
install_requires.append('ocrd_validators == %s' % VERSION)
install_requires.append('ocrd_network == %s' % VERSION)
class build(orig_build):
def finalize_options(self):
vers = ' == ' + self.distribution.metadata.version
self.distribution.install_requires = [
req + vers if req.startswith('ocrd') and '==' not in req else req
for req in self.distribution.install_requires
]
orig_build.finalize_options(self)

setup(
name='ocrd',
version=VERSION,
description='OCR-D framework',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
author='Konstantin Baierer',
author_email='[email protected]',
url='https://github.com/OCR-D/core',
license='Apache License 2.0',
packages=find_packages(exclude=('tests', 'docs')),
include_package_data=True,
python_requires=">=3.7",
install_requires=install_requires,
entry_points={
'console_scripts': [
'ocrd=ocrd.cli:cli',
'ocrd-dummy=ocrd.processor.builtin.dummy_processor:cli',
]
},
cmdclass={"build": build}
)
40 changes: 40 additions & 0 deletions ocrd_modelfactory/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[build-system]
requires = [
"setuptools>=61",
"setuptools_scm[toml]",
"wheel",
] # PEP 508 specifications.
build-backend = "setuptools.build_meta"

[project]
name = "ocrd_modelfactory"
authors = [{name = "Konstantin Baierer", email = "[email protected]"}]
license = {text = "Apache License 2.0"}
description = "OCR-D framework - wrappers to create ocrd_model instances"
requires-python = ">=3.7"
dynamic = ["version", "dependencies"]

[project.readme]
file = "README.md"
content-type = "text/markdown"

[tool.setuptools.dynamic.dependencies]
file = ["requirements.txt"]

[project.urls]
Homepage = "https://ocr-d.de"
Documentation = "https://ocr-d.de/core"
Repository = "https://github.com/OCR-D/core"
Issues = "https://github.com/OCR-D/core/issues"

[tool.setuptools]
include-package-data = true

[tool.setuptools.package-data]
"*" = ["*.json"] # *.yml; *.xml

[tool.setuptools.packages.find]
namespaces = false

[tool.setuptools_scm]
root = ".."
2 changes: 2 additions & 0 deletions ocrd_modelfactory/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
lxml
ocrd_utils
ocrd_models
31 changes: 11 additions & 20 deletions ocrd_modelfactory/setup.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
# -*- coding: utf-8 -*-
from setuptools import setup
from setuptools import setup, Command
from setuptools.command.build import build as orig_build

from ocrd_utils import VERSION

install_requires = open('requirements.txt').read().split('\n')
install_requires.append('ocrd_utils == %s' % VERSION)
install_requires.append('ocrd_models == %s' % VERSION)
class build(orig_build):
def finalize_options(self):
vers = ' == ' + self.distribution.metadata.version
self.distribution.install_requires = [
req + vers if req.startswith('ocrd') and '==' not in req else req
for req in self.distribution.install_requires
]
orig_build.finalize_options(self)

setup(
name='ocrd_modelfactory',
version=VERSION,
description='OCR-D framework - wrappers to create ocrd_model instances',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
author='Konstantin Baierer',
author_email='[email protected]',
url='https://github.com/OCR-D/core',
license='Apache License 2.0',
python_requires=">=3.7",
install_requires=install_requires,
packages=['ocrd_modelfactory'],
package_data={'': ['*.json', '*.yml', '*.xml']},
keywords=['OCR', 'OCR-D']
cmdclass={"build": build}
)
40 changes: 40 additions & 0 deletions ocrd_models/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[build-system]
requires = [
"setuptools>=61",
"setuptools_scm[toml]",
"wheel",
] # PEP 508 specifications.
build-backend = "setuptools.build_meta"

[project]
name = "ocrd_models"
authors = [{name = "Konstantin Baierer", email = "[email protected]"}]
license = {text = "Apache License 2.0"}
description = "OCR-D framework - file format APIs and schemas"
requires-python = ">=3.7"
dynamic = ["version", "dependencies"]

[project.readme]
file = "README.md"
content-type = "text/markdown"

[tool.setuptools.dynamic.dependencies]
file = ["requirements.txt"]

[project.urls]
Homepage = "https://ocr-d.de"
Documentation = "https://ocr-d.de/core"
Repository = "https://github.com/OCR-D/core"
Issues = "https://github.com/OCR-D/core/issues"

[tool.setuptools]
include-package-data = true

[tool.setuptools.package-data]
"*" = ["*.json"] # *.yml; *.xml

[tool.setuptools.packages.find]
namespaces = false

[tool.setuptools_scm]
root = ".."
1 change: 1 addition & 0 deletions ocrd_models/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
lxml
ocrd_utils
30 changes: 11 additions & 19 deletions ocrd_models/setup.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
# -*- coding: utf-8 -*-
from setuptools import setup
from setuptools import setup, Command
from setuptools.command.build import build as orig_build

from ocrd_utils import VERSION

install_requires = open('requirements.txt').read().split('\n')
install_requires.append('ocrd_utils == %s' % VERSION)
class build(orig_build):
def finalize_options(self):
vers = ' == ' + self.distribution.metadata.version
self.distribution.install_requires = [
req + vers if req.startswith('ocrd') and '==' not in req else req
for req in self.distribution.install_requires
]
orig_build.finalize_options(self)

setup(
name='ocrd_models',
version=VERSION,
description='OCR-D framework - file format APIs and schemas',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
author='Konstantin Baierer',
author_email='[email protected]',
url='https://github.com/OCR-D/core',
license='Apache License 2.0',
python_requires=">=3.7",
install_requires=install_requires,
packages=['ocrd_models'],
package_data={'': ['*.json', '*.yml', '*.xml']},
keywords=['OCR', 'OCR-D']
cmdclass={"build": build}
)
37 changes: 37 additions & 0 deletions ocrd_network/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[build-system]
requires = [
"setuptools>=61",
"setuptools_scm[toml]",
"wheel",
] # PEP 508 specifications.
build-backend = "setuptools.build_meta"

[project]
name = "ocrd_network"
authors = [{name = "Mehmed Mustafa", email = "[email protected]"}, {name = "Jonas Schrewe"}, {name = "Triet Doan"}]
license = {text = "Apache License 2.0"}
description = "OCR-D framework - network"
requires-python = ">=3.7"
dynamic = ["version", "dependencies"]

[project.readme]
file = "README.md"
content-type = "text/markdown"

[tool.setuptools.dynamic.dependencies]
file = ["requirements.txt"]

[project.urls]
Homepage = "https://ocr-d.de"
Documentation = "https://ocr-d.de/core"
Repository = "https://github.com/OCR-D/core"
Issues = "https://github.com/OCR-D/core/issues"

[tool.setuptools]
include-package-data = false

[tool.setuptools.packages.find]
namespaces = false

[tool.setuptools_scm]
root = ".."
3 changes: 3 additions & 0 deletions ocrd_network/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ paramiko
pika>=1.2.0
beanie~=1.7
httpx>=0.22.0
ocrd_validators
ocrd_utils
# ocrd # commented to avoid circular dependency
Loading

0 comments on commit 65c6f03

Please sign in to comment.