diff --git a/.circleci/config.yml b/.circleci/config.yml index 047780b810..8d3667af6f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,9 +16,10 @@ jobs: PIP_INSTALL: pip3 install --user steps: - checkout - - run: HOMEBREW_NO_AUTO_UPDATE=1 brew install imagemagick geos bash + - run: HOMEBREW_NO_AUTO_UPDATE=1 brew install imagemagick geos bash opencv + - run: $PIP_INSTALL -U pip setuptools - run: make install - - run: PATH="/Users/distiller/Library/Python/3.9/bin:$PATH" make deps-test test benchmark + - run: export PATH="/Users/distiller/Library/Python/3.9/bin:$PATH"; make deps-test test benchmark test-python37: docker: @@ -121,4 +122,4 @@ workflows: - test-python39 - test-python310 - test-python311 - - test-macos + # - test-macos diff --git a/.dockerignore b/.dockerignore index aefc504c60..fc93d25fe7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,9 @@ * -!ocrd* +!src* +!pyproject.toml +!requirements.txt !Makefile +!VERSION !LICENSE !README.md !.git diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 25999a199e..85a602a1b2 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -28,6 +28,10 @@ jobs: - name: Build the Docker image with GPU support # default tag uses docker.io, so override on command-line run: make docker-cuda DOCKER_TAG=${{ env.DOCKER_TAG }}-cuda DOCKER_BASE_IMAGE=${{ env.DOCKER_TAG }} + - name: Smoke Test that ocrd --help works + run: | + docker run --rm ${{ env.DOCKER_TAG }} ocrd --version + docker run --rm ${{ env.DOCKER_TAG }}-cuda ocrd --version - name: Login to GitHub Container Registry uses: docker/login-action@v2 with: diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml new file mode 100644 index 0000000000..cfe282cd54 --- /dev/null +++ b/.github/workflows/unit-test.yml @@ -0,0 +1,63 @@ +name: Test core installation and run tests + +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + python-version: + - '3.7' + - '3.8' + - '3.9' + - '3.10' + - '3.11' + os: + - ubuntu-22.04 + - ubuntu-20.04 + - macos-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Homebrew + id: set-up-homebrew + uses: Homebrew/actions/setup-homebrew@master + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + if [[ "${{ matrix.os }}" == "ubuntu"* ]];then + sudo apt-get -y update + sudo make deps-ubuntu + else + HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 \ + HOMEBREW_NO_AUTO_UPDATE=1 \ + brew install imagemagick geos bash # opencv + fi + make install deps-test + - name: Test with pytest + run: | + make test benchmark + - name: test to ensure that --editable install works + run: | + make install-dev; ocrd --version + - name: Lint with flake8 + run: | + python -m pip install flake8 + # stop the build if there are Python syntax errors or undefined names + flake8 src --count --exit-zero --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 src --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics diff --git a/.gitignore b/.gitignore index 21aa725bf8..aff9382067 100644 --- a/.gitignore +++ b/.gitignore @@ -109,7 +109,6 @@ env2/ ocrd.egg-info .pytest_cache -/src /profile .~lock* .pynative @@ -125,5 +124,5 @@ tests/assets/test.ocrd.zip /foo sanders* ws1 -*.doctree +*.doctrees .vscode diff --git a/CHANGELOG.md b/CHANGELOG.md index d9c7119f3f..1888ac1a62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,32 @@ Versioned according to [Semantic Versioning](http://semver.org/). ## Unreleased +## [2.61.2] - 2024-01-24 + +Fixed: + + * another regression to docker deployment (requirements.txt missing), #1173 + +## [2.61.1] - 2024-01-23 + +Fixed: + + * deps-cuda: add workaround for keras-team/tf-keras#62, #1169 + * fix regression docker deployment, #1172 + + +## [2.61.0] - 2024-01-23 + +Changed: + + * :fire: simplify the project layout and distribution policy, #1166 + * In the future there will be only one distribution `ocrd` + * The previous separate distributions of the `ocrd_utils`, `ocrd_models`, `ocrd_modelfactory`, `ocrd_validators` and `ocrd_network` are all part of `ocrd` now + * Nothing needs to be changed in code using OCR-D/core, the package structure and API is the same as before + * Until the next major release, we will continue to provide distributions for `ocrd_utils` etc. that contain the same code as `ocrd` + * Using `ocrd_utils` etc. as distributions in `requirements.txt` or `install_requires` is now deprecated + * Once we release v3.0.0, these distributions will be depublished + ## [2.60.3] - 2024-01-10 Fixed: @@ -1957,6 +1983,9 @@ Fixed Initial Release +[2.61.2]: ../../compare/v2.61.2..v2.61.1 +[2.61.1]: ../../compare/v2.61.1..v2.61.1 +[2.61.0]: ../../compare/v2.61.0..v2.60.3 [2.60.3]: ../../compare/v2.60.3..v2.60.2 [2.60.2]: ../../compare/v2.60.2..v2.60.1 [2.60.1]: ../../compare/v2.60.1..v2.60.0 diff --git a/Dockerfile b/Dockerfile index 00bd8bb30a..9cdb648372 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,17 +9,17 @@ ENV LANG=C.UTF-8 ENV PIP=pip WORKDIR /build-ocrd -COPY ocrd ./ocrd -COPY ocrd_modelfactory ./ocrd_modelfactory/ -COPY ocrd_models ./ocrd_models -COPY ocrd_utils ./ocrd_utils -RUN mv ./ocrd_utils/ocrd_logging.conf /etc -COPY ocrd_validators/ ./ocrd_validators -COPY ocrd_network/ ./ocrd_network + +COPY src ./src +COPY pyproject.toml . +COPY VERSION ./VERSION +COPY requirements.txt ./requirements.txt +RUN mv ./src/ocrd_utils/ocrd_logging.conf /etc COPY Makefile . COPY README.md . COPY LICENSE . COPY .git ./.git + RUN echo 'APT::Install-Recommends "0"; APT::Install-Suggests "0";' >/etc/apt/apt.conf.d/ocr-d.conf RUN apt-get update && apt-get -y install software-properties-common \ && apt-get update && apt-get -y install \ @@ -36,7 +36,6 @@ RUN apt-get update && apt-get -y install software-properties-common \ && make deps-ubuntu \ && python3 -m venv /usr/local \ && hash -r \ - && pip install --upgrade pip setuptools wheel \ && make install \ && eval $FIXUP \ && rm -rf /build-ocrd diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000000..f002905188 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,3 @@ +include README*.md +include requirements.txt +include VERSION diff --git a/Makefile b/Makefile index f2adfdca59..f863684d0d 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ LOG_LEVEL = INFO PYTHONIOENCODING=utf8 TESTDIR = $(CURDIR)/tests PYTEST_ARGS = --continue-on-collection-errors +VERSION = $(shell cat VERSION) SPHINX_APIDOC = @@ -61,6 +62,8 @@ deps-cuda: mv bin/micromamba $(CONDA_EXE) # Install Conda system-wide (for interactive / login shells) echo 'export MAMBA_EXE=$(CONDA_EXE) MAMBA_ROOT_PREFIX=$(CONDA_PREFIX) CONDA_PREFIX=$(CONDA_PREFIX) PATH=$(CONDA_PREFIX)/bin:$$PATH' >> /etc/profile.d/98-conda.sh +# workaround for tf-keras#62 + echo 'export XLA_FLAGS=--xla_gpu_cuda_data_dir=$(CONDA_PREFIX)/' >> /etc/profile.d/98-conda.sh mkdir -p $(CONDA_PREFIX)/lib $(CONDA_PREFIX)/include echo $(CONDA_PREFIX)/lib >> /etc/ld.so.conf.d/conda.conf # Get CUDA toolkit, including compiler and libraries with dev, @@ -119,14 +122,15 @@ deps-test: .PHONY: build install install-dev uninstall build: - $(PIP) install build setuptools_scm - $(foreach MODULE,$(BUILD_ORDER),$(PYTHON) -m build ./$(MODULE) &&) echo done + $(PIP) install build + $(PYTHON) -m build . # or use -n ? # (Re)install the tool install: #build -# $(PIP_INSTALL) $(BUILD_ORDER:%=./%/dist/ocrd*`$(PYTHON) -m setuptools_scm 2>/dev/null`*.whl) - $(foreach MODULE,$(BUILD_ORDER),$(PIP_INSTALL) ./$(MODULE) $(PIP_INSTALL_CONFIG_OPTION) &&) echo done + # not stricttly necessary but a precaution against outdated python build tools, https://github.com/OCR-D/core/pull/1166 + $(PIP) install -U pip wheel setuptools + $(PIP_INSTALL) . $(PIP_INSTALL_CONFIG_OPTION) @# workaround for shapely#1598 $(PIP) config set global.no-binary shapely @@ -138,11 +142,11 @@ install-dev: uninstall # Uninstall the tool uninstall: - $(PIP) uninstall -y $(call reverse,$(BUILD_ORDER)) + $(PIP) uninstall --yes ocrd # Regenerate python code from PAGE XSD -generate-page: GDS_PAGE = ocrd_models/ocrd_models/ocrd_page_generateds.py -generate-page: GDS_PAGE_USER = ocrd_models/ocrd_page_user_methods.py +generate-page: GDS_PAGE = src/ocrd_models/ocrd_page_generateds.py +generate-page: GDS_PAGE_USER = src/ocrd_page_user_methods.py generate-page: repo/assets generateDS \ -f \ @@ -152,7 +156,7 @@ generate-page: repo/assets --export "write etree" \ --disable-generatedssuper-lookup \ --user-methods=$(GDS_PAGE_USER) \ - ocrd_validators/ocrd_validators/page.xsd + src/ocrd_validators/page.xsd # hack to prevent #451: enum keys will be strings sed -i 's/(Enum):$$/(str, Enum):/' $(GDS_PAGE) # hack to ensure output has pc: prefix @@ -236,8 +240,8 @@ coverage: assets # Build documentation docs: for mod in $(BUILD_ORDER);do sphinx-apidoc -f -M -e \ - -o docs/api/$$mod $$mod/$$mod \ - 'ocrd_models/ocrd_models/ocrd_page_generateds.py' \ + -o docs/api/$$mod src/$$mod \ + 'src/ocrd_models/ocrd_page_generateds.py' \ ;done cd docs ; $(MAKE) html @@ -263,8 +267,12 @@ gh-pages: # pyclean: + rm -rf ./build + rm -rf ./dist + rm -rf htmlcov + rm -rf .benchmarks rm -f **/*.pyc - find . -name '__pycache__' -exec rm -rf '{}' \; + -find . -name '__pycache__' -exec rm -rf '{}' \; rm -rf .pytest_cache # @@ -292,4 +300,38 @@ docker docker-cuda: # Build wheels and source dist and twine upload them pypi: build - twine upload ocrd*/dist/ocrd*`$(PYTHON) -m setuptools_scm 2>/dev/null`*{tar.gz,whl} + twine upload dist/ocrd-$(VERSION)*{tar.gz,whl} + +pypi-workaround: build-workaround + for dist in $(BUILD_ORDER);do twine upload dist/$$dist-$(VERSION)*{tar.gz,whl};done + +# Only in place until v3 so we don't break existing installations +build-workaround: pyclean + cp pyproject.toml pyproject.toml.BAK + cp src/ocrd_utils/constants.py src/ocrd_utils/constants.py.BAK + cp src/ocrd/cli/__init__.py src/ocrd/cli/__init__.py.BAK + for dist in $(BUILD_ORDER);do \ + cat pyproject.toml.BAK | sed "s,^name =.*,name = \"$$dist\"," > pyproject.toml; \ + cat src/ocrd_utils/constants.py.BAK | sed "s,get_distribution('ocrd'),get_distribution('$$dist')," > src/ocrd_utils/constants.py; \ + cat src/ocrd/cli/__init__.py.BAK | sed "s,package_name='ocrd',package_name='$$dist'," > src/ocrd/cli/__init__.py; \ + $(MAKE) build; \ + done + rm pyproject.toml.BAK + rm src/ocrd_utils/constants.py.BAK + rm src/ocrd/cli/__init__.py.BAK + +# test that the aliased packages work in isolation and combined +test-workaround: build-workaround + for dist in $(BUILD_ORDER);do pip uninstall --yes $$dist;done + for dist in $(BUILD_ORDER);do \ + pip install dist/$$dist-*.whl ;\ + ocrd --version ;\ + make test ;\ + pip uninstall --yes $$dist ;\ + done + for dist in $(BUILD_ORDER);do \ + pip install dist/$$dist-*.whl ;\ + done + ocrd --version ;\ + make test ;\ + for dist in $(BUILD_ORDER);do pip uninstall --yes $$dist;done diff --git a/README.md b/README.md index 23fa8ab6b2..f2ad546316 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ [![image](https://img.shields.io/pypi/v/ocrd.svg)](https://pypi.org/project/ocrd/) [![image](https://circleci.com/gh/OCR-D/core.svg?style=svg)](https://circleci.com/gh/OCR-D/core) [![Docker Image CI](https://github.com/OCR-D/core/actions/workflows/docker-image.yml/badge.svg)](https://github.com/OCR-D/core/actions/workflows/docker-image.yml) +[![Unit Test CI](https://github.com/OCR-D/core/actions/workflows/unit-test.yml/badge.svg)](https://github.com/OCR-D/core/actions/workflows/unit-test.yml) [![image](https://scrutinizer-ci.com/g/OCR-D/core/badges/build.png?b=master)](https://scrutinizer-ci.com/g/OCR-D/core) [![image](https://codecov.io/gh/OCR-D/core/branch/master/graph/badge.svg)](https://codecov.io/gh/OCR-D/core) [![image](https://scrutinizer-ci.com/g/OCR-D/core/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/OCR-D/core) @@ -27,13 +28,6 @@ * [ocrd_network](#ocrd_network) * [ocrd](#ocrd) * [bash library](#bash-library) - * [bashlib API](#bashlib-api) - * [`ocrd__raise`](#ocrd__raise) - * [`ocrd__log`](#ocrd__log) - * [`ocrd__minversion`](#ocrd__minversion) - * [`ocrd__dumpjson`](#ocrd__dumpjson) - * [`ocrd__usage`](#ocrd__usage) - * [`ocrd__parse_argv`](#ocrd__parse_argv) * [Testing](#testing) * [See Also](#see-also) @@ -121,31 +115,31 @@ Some parts of the software are configured via environement variables: Contains utilities and constants, e.g. for logging, path normalization, coordinate calculation etc. -See [README for `ocrd_utils`](./ocrd_utils/README.md) for further information. +See [README for `ocrd_utils`](./README_ocrd_utils.md) for further information. ### ocrd_models Contains file format wrappers for PAGE-XML, METS, EXIF metadata etc. -See [README for `ocrd_models`](./ocrd_models/README.md) for further information. +See [README for `ocrd_models`](./README_ocrd_models.md) for further information. ### ocrd_modelfactory Code to instantiate [models](#ocrd-models) from existing data. -See [README for `ocrd_modelfactory`](./ocrd_modelfactory/README.md) for further information. +See [README for `ocrd_modelfactory`](./README_ocrd_modelfactory.md) for further information. ### ocrd_validators Schemas and routines for validating BagIt, `ocrd-tool.json`, workspaces, METS, page, CLI parameters etc. -See [README for `ocrd_validators`](./ocrd_validators/README.md) for further information. +See [README for `ocrd_validators`](./README_ocrd_validators.md) for further information. ### ocrd_network Components related to OCR-D Web API -See [README for `ocrd_network`](./ocrd_network/README.md) for further information. +See [README for `ocrd_network`](./README_ocrd_network.md) for further information. ### ocrd @@ -153,166 +147,13 @@ Depends on all of the above, also contains decorators and classes for creating O Also contains the command line tool `ocrd`. -See [README for `ocrd`](./ocrd/README.md) for further information. +See [README for `ocrd`](./README_ocrd.md) for further information. ## bash library Builds a bash script that can be sourced by other bash scripts to create OCRD-compliant CLI. -For example: - - source `ocrd bashlib filename` - declare -A NAMESPACES MIMETYPES - eval NAMESPACES=( `ocrd bashlib constants NAMESPACES` ) - echo ${NAMESPACES[page]} - eval MIMETYPE_PAGE=( `ocrd bashlib constants MIMETYPE_PAGE` ) - echo $MIMETYPE_PAGE - eval MIMETYPES=( `ocrd bashlib constants EXT_TO_MIME` ) - echo ${MIMETYPES[.jpg]} - - -### bashlib CLI - -See [CLI usage](https://ocr-d.de/core/api/ocrd/ocrd.cli.bashlib.html) - -### bashlib API - -### `ocrd__raise` - -Raise an error and exit. - -### `ocrd__log` - -Delegate logging to [`ocrd log`](#ocrd-cli) - -### `ocrd__minversion` - -Ensure minimum version - -### `ocrd__dumpjson` - -Output ocrd-tool.json content verbatim. - -Requires `$OCRD_TOOL_JSON` and `$OCRD_TOOL_NAME` to be set: - -```sh -export OCRD_TOOL_JSON=/path/to/ocrd-tool.json -export OCRD_TOOL_NAME=ocrd-foo-bar -``` - -(Which you automatically get from [`ocrd__wrap`](#ocrd__wrap).) - -### `ocrd__show_resource` - -Output given resource file's content. - -### `ocrd__list_resources` - -Output all resource files' names. - -### `ocrd__usage` - -Print help on CLI usage. - -### `ocrd__parse_argv` - -Parses arguments according to [OCR-D CLI](https://ocr-d.de/en/spec/cli). -In doing so, depending on the values passed to it, may delegate to … -- [`ocrd__raise`](#ocrd__raise) and exit (if something went wrong) -- [`ocrd__usage`](#ocrd__usage) and exit -- [`ocrd__dumpjson`](#ocrd__dumpjson) and exit -- [`ocrd__show_resource`](#ocrd__show_resource) and exit -- [`ocrd__list_resources`](#ocrd__list_resources) and exit -- [`ocrd validate tasks`](#ocrd-cli) and return - -Expects an associative array ("hash"/"dict") **`ocrd__argv`** to be predefined: - - declare -A ocrd__argv=() - -This will be filled by the parser along the following keys: -- `overwrite`: whether `--overwrite` is enabled -- `profile`: whether `--profile` is enabled -- `profile_file`: the argument of `--profile-file` -- `log_level`: the argument of `--log-level` -- `mets_file`: absolute path of the `--mets` argument -- `working_dir`: absolute path of the `--working-dir` argument or the parent of `mets_file` -- `page_id`: the argument of `--page-id` -- `input_file_grp`: the argument of `--input-file-grp` -- `output_file_grp`: the argument of `--output-file-grp` - -Moreover, there will be an associative array **`params`** -with the fully expanded runtime values of the ocrd-tool.json parameters. - -### `ocrd__wrap` - -Parses an [ocrd-tool.json](https://ocr-d.de/en/spec/ocrd_tool) for a specific `tool` (i.e. processor `executable`). - -Delegates to … -- [`ocrd__parse_argv`](#ocrd__parse_argv), creating the `ocrd__argv` associative array -- [`ocrd bashlib input-files`](#ocrd-cli), creating the data structures used by [`ocrd__input_file`](#ocrd__input_file) - -Usage: `ocrd__wrap PATH/TO/OCRD-TOOL.JSON EXECUTABLE ARGS` - -For example: - - ocrd__wrap $SHAREDIR/ocrd-tool.json ocrd-olena-binarize "$@" - ... - -### `ocrd__input_file` - -(Requires [`ocrd__wrap`](#ocrd__wrap) to have been run first.) - -Access information on the input files according to the parsed CLI arguments: -- their file `url` (or local file path) -- their file `ID` -- their `mimetype` -- their `pageId` -- their proposed corresponding `outputFileId` (generated from `${ocrd__argv[output__file_grp]}` and input file `ID`) - -Usage: `ocrd__input_file NR KEY` - -For example: - - pageId=`ocrd__input_file 3 pageId` - -To be used in a **loop over all selected pages**: - - for ((n=0; n<${#ocrd__files[*]}; n++)); do - local in_fpath=($(ocrd__input_file $n url)) - local in_id=($(ocrd__input_file $n ID)) - local in_mimetype=($(ocrd__input_file $n mimetype)) - local in_pageId=($(ocrd__input_file $n pageId)) - local out_id=$(ocrd__input_file $n outputFileId) - local out_fpath="${ocrd__argv[output_file_grp]}/${out_id}.xml - - # process $in_fpath to $out_fpath ... - - declare -a options - if [ -n "$in_pageId" ]; then - options=( -g $in_pageId ) - else - options=() - fi - if [[ "${ocrd__argv[overwrite]}" == true ]];then - options+=( --force ) - fi - options+=( -G ${ocrd__argv[output_file_grp]} - -m $MIMETYPE_PAGE -i "$out_id" - "$out_fpath" ) - ocrd -l ${ocrd__argv[log_level]} workspace -d ${ocrd__argv[working_dir]} add "${options[@]}" - -> **Note**: If the `--input-file-grp` is **multi-valued** (N fileGrps separated by commas), -> then usage is similar: -> * The function `ocrd__input_file` can be used, but -> its results will be **lists** (delimited by whitespace and surrounded by single quotes), -> e.g. `[url]='file1.xml file2.xml' [ID]='id_file1 id_file2' [mimetype]='application/vnd.prima.page+xml image/tiff' ...`. -> * Therefore its results should be encapsulated in a (non-associative) **array variable** -> and without extra quotes, e.g. `in_file=($(ocrd__input_file 3 url))`, or as shown above. -> * This will yield the first fileGrp's results on index 0, -> which in bash will always be the same as if you referenced the array without index -> (so code does not need to be changed much), e.g. `test -f $in_file` which equals `test -f ${in_file[0]}`. -> * Additional fileGrps will have to be fetched from higher indexes, e.g. `test -f ${in_file[1]}`. - +See [README for `bashlib`](./README_bashlib.md) for further information. ## Testing diff --git a/README_bashlib.md b/README_bashlib.md new file mode 100644 index 0000000000..09199468cc --- /dev/null +++ b/README_bashlib.md @@ -0,0 +1,169 @@ +# bashlib + +> Builds a bash script that can be sourced by other bash scripts to create OCRD-compliant CLI. + +For example: + + source `ocrd bashlib filename` + declare -A NAMESPACES MIMETYPES + eval NAMESPACES=( `ocrd bashlib constants NAMESPACES` ) + echo ${NAMESPACES[page]} + eval MIMETYPE_PAGE=( `ocrd bashlib constants MIMETYPE_PAGE` ) + echo $MIMETYPE_PAGE + eval MIMETYPES=( `ocrd bashlib constants EXT_TO_MIME` ) + echo ${MIMETYPES[.jpg]} + + + +* [bashlib CLI](#bashlib-cli) +* [bashlib API](#bashlib-api) +* [`ocrd__raise`](#ocrd__raise) +* [`ocrd__log`](#ocrd__log) +* [`ocrd__minversion`](#ocrd__minversion) +* [`ocrd__dumpjson`](#ocrd__dumpjson) +* [`ocrd__usage`](#ocrd__usage) +* [`ocrd__parse_argv`](#ocrd__parse_argv) + + +## bashlib CLI + +See [CLI usage](https://ocr-d.de/core/api/ocrd/ocrd.cli.bashlib.html) + +## bashlib API + +### `ocrd__raise` + +Raise an error and exit. + +### `ocrd__log` + +Delegate logging to [`ocrd log`](#ocrd-cli) + +### `ocrd__minversion` + +Ensure minimum version + +### `ocrd__dumpjson` + +Output ocrd-tool.json content verbatim. + +Requires `$OCRD_TOOL_JSON` and `$OCRD_TOOL_NAME` to be set: + +```sh +export OCRD_TOOL_JSON=/path/to/ocrd-tool.json +export OCRD_TOOL_NAME=ocrd-foo-bar +``` + +(Which you automatically get from [`ocrd__wrap`](#ocrd__wrap).) + +### `ocrd__show_resource` + +Output given resource file's content. + +### `ocrd__list_resources` + +Output all resource files' names. + +### `ocrd__usage` + +Print help on CLI usage. + +### `ocrd__parse_argv` + +Parses arguments according to [OCR-D CLI](https://ocr-d.de/en/spec/cli). +In doing so, depending on the values passed to it, may delegate to … +- [`ocrd__raise`](#ocrd__raise) and exit (if something went wrong) +- [`ocrd__usage`](#ocrd__usage) and exit +- [`ocrd__dumpjson`](#ocrd__dumpjson) and exit +- [`ocrd__show_resource`](#ocrd__show_resource) and exit +- [`ocrd__list_resources`](#ocrd__list_resources) and exit +- [`ocrd validate tasks`](#ocrd-cli) and return + +Expects an associative array ("hash"/"dict") **`ocrd__argv`** to be predefined: + + declare -A ocrd__argv=() + +This will be filled by the parser along the following keys: +- `overwrite`: whether `--overwrite` is enabled +- `profile`: whether `--profile` is enabled +- `profile_file`: the argument of `--profile-file` +- `log_level`: the argument of `--log-level` +- `mets_file`: absolute path of the `--mets` argument +- `working_dir`: absolute path of the `--working-dir` argument or the parent of `mets_file` +- `page_id`: the argument of `--page-id` +- `input_file_grp`: the argument of `--input-file-grp` +- `output_file_grp`: the argument of `--output-file-grp` + +Moreover, there will be an associative array **`params`** +with the fully expanded runtime values of the ocrd-tool.json parameters. + +### `ocrd__wrap` + +Parses an [ocrd-tool.json](https://ocr-d.de/en/spec/ocrd_tool) for a specific `tool` (i.e. processor `executable`). + +Delegates to … +- [`ocrd__parse_argv`](#ocrd__parse_argv), creating the `ocrd__argv` associative array +- [`ocrd bashlib input-files`](#ocrd-cli), creating the data structures used by [`ocrd__input_file`](#ocrd__input_file) + +Usage: `ocrd__wrap PATH/TO/OCRD-TOOL.JSON EXECUTABLE ARGS` + +For example: + + ocrd__wrap $SHAREDIR/ocrd-tool.json ocrd-olena-binarize "$@" + ... + +### `ocrd__input_file` + +(Requires [`ocrd__wrap`](#ocrd__wrap) to have been run first.) + +Access information on the input files according to the parsed CLI arguments: +- their file `url` (or local file path) +- their file `ID` +- their `mimetype` +- their `pageId` +- their proposed corresponding `outputFileId` (generated from `${ocrd__argv[output__file_grp]}` and input file `ID`) + +Usage: `ocrd__input_file NR KEY` + +For example: + + pageId=`ocrd__input_file 3 pageId` + +To be used in a **loop over all selected pages**: + + for ((n=0; n<${#ocrd__files[*]}; n++)); do + local in_fpath=($(ocrd__input_file $n url)) + local in_id=($(ocrd__input_file $n ID)) + local in_mimetype=($(ocrd__input_file $n mimetype)) + local in_pageId=($(ocrd__input_file $n pageId)) + local out_id=$(ocrd__input_file $n outputFileId) + local out_fpath="${ocrd__argv[output_file_grp]}/${out_id}.xml + + # process $in_fpath to $out_fpath ... + + declare -a options + if [ -n "$in_pageId" ]; then + options=( -g $in_pageId ) + else + options=() + fi + if [[ "${ocrd__argv[overwrite]}" == true ]];then + options+=( --force ) + fi + options+=( -G ${ocrd__argv[output_file_grp]} + -m $MIMETYPE_PAGE -i "$out_id" + "$out_fpath" ) + ocrd -l ${ocrd__argv[log_level]} workspace -d ${ocrd__argv[working_dir]} add "${options[@]}" + +> **Note**: If the `--input-file-grp` is **multi-valued** (N fileGrps separated by commas), +> then usage is similar: +> * The function `ocrd__input_file` can be used, but +> its results will be **lists** (delimited by whitespace and surrounded by single quotes), +> e.g. `[url]='file1.xml file2.xml' [ID]='id_file1 id_file2' [mimetype]='application/vnd.prima.page+xml image/tiff' ...`. +> * Therefore its results should be encapsulated in a (non-associative) **array variable** +> and without extra quotes, e.g. `in_file=($(ocrd__input_file 3 url))`, or as shown above. +> * This will yield the first fileGrp's results on index 0, +> which in bash will always be the same as if you referenced the array without index +> (so code does not need to be changed much), e.g. `test -f $in_file` which equals `test -f ${in_file[0]}`. +> * Additional fileGrps will have to be fetched from higher indexes, e.g. `test -f ${in_file[1]}`. + diff --git a/ocrd/README.md b/README_ocrd.md similarity index 100% rename from ocrd/README.md rename to README_ocrd.md diff --git a/ocrd_modelfactory/README.md b/README_ocrd_modelfactory.md similarity index 100% rename from ocrd_modelfactory/README.md rename to README_ocrd_modelfactory.md diff --git a/ocrd_models/README.md b/README_ocrd_models.md similarity index 100% rename from ocrd_models/README.md rename to README_ocrd_models.md diff --git a/ocrd_network/README.md b/README_ocrd_network.md similarity index 100% rename from ocrd_network/README.md rename to README_ocrd_network.md diff --git a/ocrd_utils/README.md b/README_ocrd_utils.md similarity index 100% rename from ocrd_utils/README.md rename to README_ocrd_utils.md diff --git a/ocrd_validators/README.md b/README_ocrd_validators.md similarity index 100% rename from ocrd_validators/README.md rename to README_ocrd_validators.md diff --git a/VERSION b/VERSION new file mode 100644 index 0000000000..fb82db5291 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +2.61.2 diff --git a/docs/api/ocrd_network/ocrd_network.constants.rst b/docs/api/ocrd_network/ocrd_network.constants.rst new file mode 100644 index 0000000000..041c77f22d --- /dev/null +++ b/docs/api/ocrd_network/ocrd_network.constants.rst @@ -0,0 +1,7 @@ +ocrd\_network.constants module +============================== + +.. automodule:: ocrd_network.constants + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/api/ocrd_network/ocrd_network.models.rst b/docs/api/ocrd_network/ocrd_network.models.rst index dba609ccb5..27bb84ad38 100644 --- a/docs/api/ocrd_network/ocrd_network.models.rst +++ b/docs/api/ocrd_network/ocrd_network.models.rst @@ -15,4 +15,5 @@ Submodules ocrd_network.models.job ocrd_network.models.messages ocrd_network.models.ocrd_tool + ocrd_network.models.workflow ocrd_network.models.workspace diff --git a/docs/api/ocrd_network/ocrd_network.models.workflow.rst b/docs/api/ocrd_network/ocrd_network.models.workflow.rst new file mode 100644 index 0000000000..f9046cd8e7 --- /dev/null +++ b/docs/api/ocrd_network/ocrd_network.models.workflow.rst @@ -0,0 +1,7 @@ +ocrd\_network.models.workflow module +==================================== + +.. automodule:: ocrd_network.models.workflow + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/api/ocrd_network/ocrd_network.rst b/docs/api/ocrd_network/ocrd_network.rst index bcecb065c8..ae12ae1f5d 100644 --- a/docs/api/ocrd_network/ocrd_network.rst +++ b/docs/api/ocrd_network/ocrd_network.rst @@ -23,6 +23,7 @@ Submodules :maxdepth: 4 ocrd_network.client + ocrd_network.constants ocrd_network.database ocrd_network.deployer ocrd_network.deployment_utils diff --git a/docs/conf.py b/docs/conf.py index cd2ef233f1..3ab2e1826f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -12,23 +12,21 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # -import os -import sys -sys.path.insert(0, os.path.abspath('..')) -import json -import re -with open(os.path.join(os.path.abspath('..'), 'ocrd_utils', 'setup.py'), 'r', encoding='utf-8') as f: - VERSION = re.findall(r'\bversion=\'([^\']*)\'', f.read())[0] +# import os +# import sys +# # sys.path.insert(0, os.path.abspath('..')) +with open('VERSION', encoding='utf-8') as f: + VERSION = f.read() # -- Project information ----------------------------------------------------- project = u'ocrd' -copyright = u'2018-2021, OCR-D' +copyright = u'2018-2024, OCR-D' author = u'OCR-D' # The short X.Y version -version = VERSION +version = VERSION.rsplit('.', 1)[0] # The full version, including alpha/beta/rc tags release = VERSION diff --git a/ocrd/MANIFEST.in b/ocrd/MANIFEST.in deleted file mode 100644 index af6a7f6bad..0000000000 --- a/ocrd/MANIFEST.in +++ /dev/null @@ -1,3 +0,0 @@ -recursive-include ocrd *.json *.yml *.yaml *.bash *.xml -include requirements.txt -include README.md diff --git a/ocrd/ocrd/.doctrees/environment.pickle b/ocrd/ocrd/.doctrees/environment.pickle deleted file mode 100644 index d941ba88ab..0000000000 Binary files a/ocrd/ocrd/.doctrees/environment.pickle and /dev/null differ diff --git a/ocrd/requirements.txt b/ocrd/requirements.txt deleted file mode 100644 index 9c057532a2..0000000000 --- a/ocrd/requirements.txt +++ /dev/null @@ -1,23 +0,0 @@ -bagit >= 1.7.0 -bagit_profile >= 1.3.0 -click >=7 -requests < 2.30 -lxml -opencv-python-headless -Flask -jsonschema -pyyaml -Deprecated == 1.2.0 -memory-profiler >= 0.58.0 -sparklines >= 0.4.2 -python-magic -uvicorn -fastapi -python-multipart -requests_unixsocket -gdown -ocrd_utils -ocrd_models -ocrd_modelfactory -ocrd_validators -ocrd_network diff --git a/ocrd/setup.py b/ocrd/setup.py deleted file mode 100644 index 929849c9f5..0000000000 --- a/ocrd/setup.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- -from setuptools import setup, Command -from setuptools.command.build import build as orig_build - -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( - cmdclass={"build": build} -) diff --git a/ocrd_modelfactory/MANIFEST.in b/ocrd_modelfactory/MANIFEST.in deleted file mode 100644 index 4fae91089a..0000000000 --- a/ocrd_modelfactory/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -include requirements.txt -include README.md diff --git a/ocrd_modelfactory/ocrd_modelfactory/.doctrees/environment.pickle b/ocrd_modelfactory/ocrd_modelfactory/.doctrees/environment.pickle deleted file mode 100644 index b7405edc62..0000000000 Binary files a/ocrd_modelfactory/ocrd_modelfactory/.doctrees/environment.pickle and /dev/null differ diff --git a/ocrd_modelfactory/pyproject.toml b/ocrd_modelfactory/pyproject.toml deleted file mode 100644 index 34798daf29..0000000000 --- a/ocrd_modelfactory/pyproject.toml +++ /dev/null @@ -1,40 +0,0 @@ -[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 = "unixprog@gmail.com"}] -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 = ".." diff --git a/ocrd_modelfactory/requirements.txt b/ocrd_modelfactory/requirements.txt deleted file mode 100644 index c577acff93..0000000000 --- a/ocrd_modelfactory/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -lxml -ocrd_utils -ocrd_models diff --git a/ocrd_modelfactory/setup.py b/ocrd_modelfactory/setup.py deleted file mode 100644 index 929849c9f5..0000000000 --- a/ocrd_modelfactory/setup.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- -from setuptools import setup, Command -from setuptools.command.build import build as orig_build - -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( - cmdclass={"build": build} -) diff --git a/ocrd_models/MANIFEST.in b/ocrd_models/MANIFEST.in deleted file mode 100644 index 4fae91089a..0000000000 --- a/ocrd_models/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -include requirements.txt -include README.md diff --git a/ocrd_models/ocrd_models/.doctrees/environment.pickle b/ocrd_models/ocrd_models/.doctrees/environment.pickle deleted file mode 100644 index 4ff69b98d5..0000000000 Binary files a/ocrd_models/ocrd_models/.doctrees/environment.pickle and /dev/null differ diff --git a/ocrd_models/pyproject.toml b/ocrd_models/pyproject.toml deleted file mode 100644 index 5f8e3ebb1a..0000000000 --- a/ocrd_models/pyproject.toml +++ /dev/null @@ -1,40 +0,0 @@ -[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 = "unixprog@gmail.com"}] -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 = ".." diff --git a/ocrd_models/requirements.txt b/ocrd_models/requirements.txt deleted file mode 100644 index 299120a695..0000000000 --- a/ocrd_models/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -lxml -ocrd_utils diff --git a/ocrd_models/setup.py b/ocrd_models/setup.py deleted file mode 100644 index 929849c9f5..0000000000 --- a/ocrd_models/setup.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- -from setuptools import setup, Command -from setuptools.command.build import build as orig_build - -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( - cmdclass={"build": build} -) diff --git a/ocrd_network/MANIFEST.in b/ocrd_network/MANIFEST.in deleted file mode 100644 index 4fae91089a..0000000000 --- a/ocrd_network/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -include requirements.txt -include README.md diff --git a/ocrd_network/pyproject.toml b/ocrd_network/pyproject.toml deleted file mode 100644 index 778038ab8d..0000000000 --- a/ocrd_network/pyproject.toml +++ /dev/null @@ -1,37 +0,0 @@ -[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 = "unixprog@gmail.com"}, {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 = ".." diff --git a/ocrd_network/requirements.txt b/ocrd_network/requirements.txt deleted file mode 100644 index 60b66e5383..0000000000 --- a/ocrd_network/requirements.txt +++ /dev/null @@ -1,11 +0,0 @@ -uvicorn>=0.17.6 -fastapi>=0.78.0 -pydantic==1.* -docker -paramiko -pika>=1.2.0 -beanie~=1.7 -httpx>=0.22.0 -ocrd_validators -ocrd_utils -# ocrd # commented to avoid circular dependency diff --git a/ocrd_network/setup.py b/ocrd_network/setup.py deleted file mode 100644 index 929849c9f5..0000000000 --- a/ocrd_network/setup.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- -from setuptools import setup, Command -from setuptools.command.build import build as orig_build - -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( - cmdclass={"build": build} -) diff --git a/ocrd_utils/MANIFEST.in b/ocrd_utils/MANIFEST.in deleted file mode 100644 index b6ae33acad..0000000000 --- a/ocrd_utils/MANIFEST.in +++ /dev/null @@ -1,3 +0,0 @@ -include README.md -include ocrd_logging.conf -include requirements.txt diff --git a/ocrd_utils/pyproject.toml b/ocrd_utils/pyproject.toml deleted file mode 100644 index dec419a9bf..0000000000 --- a/ocrd_utils/pyproject.toml +++ /dev/null @@ -1,40 +0,0 @@ -[build-system] -requires = [ - "setuptools>=61", - "setuptools_scm[toml]", - "wheel", -] # PEP 508 specifications. -build-backend = "setuptools.build_meta" - -[project] -name = "ocrd_utils" -authors = [{name = "Konstantin Baierer", email = "unixprog@gmail.com"}] -license = {text = "Apache License 2.0"} -description = "OCR-D framework - shared code, helpers, constants" -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 = ".." diff --git a/ocrd_utils/requirements.txt b/ocrd_utils/requirements.txt deleted file mode 100644 index 328783adda..0000000000 --- a/ocrd_utils/requirements.txt +++ /dev/null @@ -1,7 +0,0 @@ -Pillow >= 7.2.0 -# XXX explicitly do not restrict the numpy version because different -# tensorflow versions might require different versions -numpy -atomicwrites >= 1.3.0 -frozendict>=2.3.4 -filetype diff --git a/ocrd_utils/setup.py b/ocrd_utils/setup.py deleted file mode 100644 index 53d3ffceba..0000000000 --- a/ocrd_utils/setup.py +++ /dev/null @@ -1,4 +0,0 @@ -# -*- coding: utf-8 -*- -from setuptools import setup - -setup() diff --git a/ocrd_validators/MANIFEST.in b/ocrd_validators/MANIFEST.in deleted file mode 100644 index 4fae91089a..0000000000 --- a/ocrd_validators/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -include requirements.txt -include README.md diff --git a/ocrd_validators/ocrd_validators/.doctrees/environment.pickle b/ocrd_validators/ocrd_validators/.doctrees/environment.pickle deleted file mode 100644 index cb19bf22c1..0000000000 Binary files a/ocrd_validators/ocrd_validators/.doctrees/environment.pickle and /dev/null differ diff --git a/ocrd_validators/pyproject.toml b/ocrd_validators/pyproject.toml deleted file mode 100644 index e039baeff4..0000000000 --- a/ocrd_validators/pyproject.toml +++ /dev/null @@ -1,40 +0,0 @@ -[build-system] -requires = [ - "setuptools>=61", - "setuptools_scm[toml]", - "wheel", -] # PEP 508 specifications. -build-backend = "setuptools.build_meta" - -[project] -name = "ocrd_validators" -authors = [{name = "Konstantin Baierer", email = "unixprog@gmail.com"}] -license = {text = "Apache License 2.0"} -description = "OCR-D framework - data validators" -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] -"*" = ["*.yml"] # *.xsd - -[tool.setuptools.packages.find] -namespaces = false - -[tool.setuptools_scm] -root = ".." diff --git a/ocrd_validators/requirements.txt b/ocrd_validators/requirements.txt deleted file mode 100644 index 2d5bff4ad5..0000000000 --- a/ocrd_validators/requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -bagit >= 1.7.0 -bagit_profile >= 1.3.0 -click >=7 -jsonschema -pyyaml -shapely -ocrd_utils -ocrd_models -ocrd_modelfactory diff --git a/ocrd_validators/setup.py b/ocrd_validators/setup.py deleted file mode 100644 index 929849c9f5..0000000000 --- a/ocrd_validators/setup.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- -from setuptools import setup, Command -from setuptools.command.build import build as orig_build - -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( - cmdclass={"build": build} -) diff --git a/ocrd/pyproject.toml b/pyproject.toml similarity index 78% rename from ocrd/pyproject.toml rename to pyproject.toml index fb8dd79ecc..4e6d12cd89 100644 --- a/ocrd/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,6 @@ [build-system] requires = [ - "setuptools>=61", - "setuptools_scm[toml]", + "setuptools>=44", "wheel", ] # PEP 508 specifications. build-backend = "setuptools.build_meta" @@ -12,7 +11,7 @@ authors = [{name = "Konstantin Baierer", email = "unixprog@gmail.com"}] license = {text = "Apache License 2.0"} description = "OCR-D framework" requires-python = ">=3.7" -dynamic = ["version", "dependencies"] +dynamic = ['version', 'dependencies'] [project.readme] file = "README.md" @@ -21,6 +20,9 @@ content-type = "text/markdown" [tool.setuptools.dynamic.dependencies] file = ["requirements.txt"] +[tool.setuptools.dynamic.version] +file = ["VERSION"] + [project.urls] Homepage = "https://ocr-d.de" Documentation = "https://ocr-d.de/core" @@ -34,9 +36,9 @@ ocrd-dummy = "ocrd.processor.builtin.dummy_processor:cli" [tool.setuptools] include-package-data = true +[tool.setuptools.package-data] +"*" = ["*.json", '*.yml', '*.xml', '*.conf', '*.bash', '*.xsd'] + [tool.setuptools.packages.find] -exclude = ["tests"] # docs +where = ["src"] namespaces = false - -[tool.setuptools_scm] -root = ".." diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000..9a9b217218 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,34 @@ +atomicwrites >= 1.3.0 +bagit >= 1.7.0 +bagit_profile >= 1.3.0 +beanie~=1.7 +click >=7 +Deprecated == 1.2.0 +docker +fastapi +fastapi>=0.78.0 +filetype +Flask +frozendict>=2.3.4 +gdown +httpx>=0.22.0 +jsonschema +lxml +memory-profiler >= 0.58.0 +numpy +opencv-python-headless +paramiko +pika>=1.2.0 +Pillow >= 7.2.0 +pydantic==1.* +python-magic +python-multipart +pyyaml +requests < 2.30 +requests_unixsocket +shapely +sparklines >= 0.4.2 +# tensorflow versions might require different versions +uvicorn +uvicorn>=0.17.6 +# XXX explicitly do not restrict the numpy version because different diff --git a/ocrd/ocrd/__init__.py b/src/ocrd/__init__.py similarity index 100% rename from ocrd/ocrd/__init__.py rename to src/ocrd/__init__.py diff --git a/ocrd/ocrd/cli/__init__.py b/src/ocrd/cli/__init__.py similarity index 100% rename from ocrd/ocrd/cli/__init__.py rename to src/ocrd/cli/__init__.py diff --git a/ocrd/ocrd/cli/bashlib.py b/src/ocrd/cli/bashlib.py similarity index 100% rename from ocrd/ocrd/cli/bashlib.py rename to src/ocrd/cli/bashlib.py diff --git a/ocrd/ocrd/cli/log.py b/src/ocrd/cli/log.py similarity index 100% rename from ocrd/ocrd/cli/log.py rename to src/ocrd/cli/log.py diff --git a/ocrd/ocrd/cli/network.py b/src/ocrd/cli/network.py similarity index 100% rename from ocrd/ocrd/cli/network.py rename to src/ocrd/cli/network.py diff --git a/ocrd/ocrd/cli/ocrd_tool.py b/src/ocrd/cli/ocrd_tool.py similarity index 100% rename from ocrd/ocrd/cli/ocrd_tool.py rename to src/ocrd/cli/ocrd_tool.py diff --git a/ocrd/ocrd/cli/process.py b/src/ocrd/cli/process.py similarity index 100% rename from ocrd/ocrd/cli/process.py rename to src/ocrd/cli/process.py diff --git a/ocrd/ocrd/cli/resmgr.py b/src/ocrd/cli/resmgr.py similarity index 100% rename from ocrd/ocrd/cli/resmgr.py rename to src/ocrd/cli/resmgr.py diff --git a/ocrd/ocrd/cli/validate.py b/src/ocrd/cli/validate.py similarity index 100% rename from ocrd/ocrd/cli/validate.py rename to src/ocrd/cli/validate.py diff --git a/ocrd/ocrd/cli/workspace.py b/src/ocrd/cli/workspace.py similarity index 100% rename from ocrd/ocrd/cli/workspace.py rename to src/ocrd/cli/workspace.py diff --git a/ocrd/ocrd/cli/zip.py b/src/ocrd/cli/zip.py similarity index 100% rename from ocrd/ocrd/cli/zip.py rename to src/ocrd/cli/zip.py diff --git a/ocrd/ocrd/constants.py b/src/ocrd/constants.py similarity index 100% rename from ocrd/ocrd/constants.py rename to src/ocrd/constants.py diff --git a/ocrd/ocrd/decorators/__init__.py b/src/ocrd/decorators/__init__.py similarity index 100% rename from ocrd/ocrd/decorators/__init__.py rename to src/ocrd/decorators/__init__.py diff --git a/ocrd/ocrd/decorators/loglevel_option.py b/src/ocrd/decorators/loglevel_option.py similarity index 100% rename from ocrd/ocrd/decorators/loglevel_option.py rename to src/ocrd/decorators/loglevel_option.py diff --git a/ocrd/ocrd/decorators/mets_find_options.py b/src/ocrd/decorators/mets_find_options.py similarity index 100% rename from ocrd/ocrd/decorators/mets_find_options.py rename to src/ocrd/decorators/mets_find_options.py diff --git a/ocrd/ocrd/decorators/ocrd_cli_options.py b/src/ocrd/decorators/ocrd_cli_options.py similarity index 100% rename from ocrd/ocrd/decorators/ocrd_cli_options.py rename to src/ocrd/decorators/ocrd_cli_options.py diff --git a/ocrd/ocrd/decorators/parameter_option.py b/src/ocrd/decorators/parameter_option.py similarity index 100% rename from ocrd/ocrd/decorators/parameter_option.py rename to src/ocrd/decorators/parameter_option.py diff --git a/ocrd/ocrd/lib.bash b/src/ocrd/lib.bash similarity index 100% rename from ocrd/ocrd/lib.bash rename to src/ocrd/lib.bash diff --git a/ocrd/ocrd/mets_server.py b/src/ocrd/mets_server.py similarity index 100% rename from ocrd/ocrd/mets_server.py rename to src/ocrd/mets_server.py diff --git a/ocrd/ocrd/processor/__init__.py b/src/ocrd/processor/__init__.py similarity index 100% rename from ocrd/ocrd/processor/__init__.py rename to src/ocrd/processor/__init__.py diff --git a/ocrd/ocrd/processor/base.py b/src/ocrd/processor/base.py similarity index 100% rename from ocrd/ocrd/processor/base.py rename to src/ocrd/processor/base.py diff --git a/ocrd/ocrd/processor/builtin/__init__.py b/src/ocrd/processor/builtin/__init__.py similarity index 100% rename from ocrd/ocrd/processor/builtin/__init__.py rename to src/ocrd/processor/builtin/__init__.py diff --git a/ocrd/ocrd/processor/builtin/dummy/__init__.py b/src/ocrd/processor/builtin/dummy/__init__.py similarity index 100% rename from ocrd/ocrd/processor/builtin/dummy/__init__.py rename to src/ocrd/processor/builtin/dummy/__init__.py diff --git a/ocrd/ocrd/processor/builtin/dummy/ocrd-tool.json b/src/ocrd/processor/builtin/dummy/ocrd-tool.json similarity index 100% rename from ocrd/ocrd/processor/builtin/dummy/ocrd-tool.json rename to src/ocrd/processor/builtin/dummy/ocrd-tool.json diff --git a/ocrd/ocrd/processor/builtin/dummy_processor.py b/src/ocrd/processor/builtin/dummy_processor.py similarity index 100% rename from ocrd/ocrd/processor/builtin/dummy_processor.py rename to src/ocrd/processor/builtin/dummy_processor.py diff --git a/ocrd/ocrd/processor/helpers.py b/src/ocrd/processor/helpers.py similarity index 100% rename from ocrd/ocrd/processor/helpers.py rename to src/ocrd/processor/helpers.py diff --git a/ocrd/ocrd/resolver.py b/src/ocrd/resolver.py similarity index 100% rename from ocrd/ocrd/resolver.py rename to src/ocrd/resolver.py diff --git a/ocrd/ocrd/resource_list.yml b/src/ocrd/resource_list.yml similarity index 100% rename from ocrd/ocrd/resource_list.yml rename to src/ocrd/resource_list.yml diff --git a/ocrd/ocrd/resource_manager.py b/src/ocrd/resource_manager.py similarity index 99% rename from ocrd/ocrd/resource_manager.py rename to src/ocrd/resource_manager.py index 9d1e6ac596..c668028e9c 100644 --- a/ocrd/ocrd/resource_manager.py +++ b/src/ocrd/resource_manager.py @@ -60,9 +60,9 @@ def xdg_data_home(self): @property def xdg_config_home(self): - if not self._xdg_config_home: - self._xdg_config_home = config.XDG_CONFIG_HOME - return self._xdg_config_home + if self._xdg_config_home: + return self._xdg_config_home + return config.XDG_CONFIG_HOME def save_user_list(self, database=None): if not database: diff --git a/ocrd/ocrd/task_sequence.py b/src/ocrd/task_sequence.py similarity index 100% rename from ocrd/ocrd/task_sequence.py rename to src/ocrd/task_sequence.py diff --git a/ocrd/ocrd/workspace.py b/src/ocrd/workspace.py similarity index 100% rename from ocrd/ocrd/workspace.py rename to src/ocrd/workspace.py diff --git a/ocrd/ocrd/workspace_backup.py b/src/ocrd/workspace_backup.py similarity index 100% rename from ocrd/ocrd/workspace_backup.py rename to src/ocrd/workspace_backup.py diff --git a/ocrd/ocrd/workspace_bagger.py b/src/ocrd/workspace_bagger.py similarity index 100% rename from ocrd/ocrd/workspace_bagger.py rename to src/ocrd/workspace_bagger.py diff --git a/ocrd_modelfactory/ocrd_modelfactory/__init__.py b/src/ocrd_modelfactory/__init__.py similarity index 100% rename from ocrd_modelfactory/ocrd_modelfactory/__init__.py rename to src/ocrd_modelfactory/__init__.py diff --git a/ocrd_models/ocrd_models/__init__.py b/src/ocrd_models/__init__.py similarity index 100% rename from ocrd_models/ocrd_models/__init__.py rename to src/ocrd_models/__init__.py diff --git a/ocrd_models/ocrd_models/constants.py b/src/ocrd_models/constants.py similarity index 100% rename from ocrd_models/ocrd_models/constants.py rename to src/ocrd_models/constants.py diff --git a/ocrd_models/ocrd_models/mets-empty.xml b/src/ocrd_models/mets-empty.xml similarity index 100% rename from ocrd_models/ocrd_models/mets-empty.xml rename to src/ocrd_models/mets-empty.xml diff --git a/ocrd_models/ocrd_models/ocrd_agent.py b/src/ocrd_models/ocrd_agent.py similarity index 100% rename from ocrd_models/ocrd_models/ocrd_agent.py rename to src/ocrd_models/ocrd_agent.py diff --git a/ocrd_models/ocrd_models/ocrd_exif.py b/src/ocrd_models/ocrd_exif.py similarity index 100% rename from ocrd_models/ocrd_models/ocrd_exif.py rename to src/ocrd_models/ocrd_exif.py diff --git a/ocrd_models/ocrd_models/ocrd_file.py b/src/ocrd_models/ocrd_file.py similarity index 100% rename from ocrd_models/ocrd_models/ocrd_file.py rename to src/ocrd_models/ocrd_file.py diff --git a/ocrd_models/ocrd_models/ocrd_mets.py b/src/ocrd_models/ocrd_mets.py similarity index 100% rename from ocrd_models/ocrd_models/ocrd_mets.py rename to src/ocrd_models/ocrd_mets.py diff --git a/ocrd_models/ocrd_models/ocrd_page.py b/src/ocrd_models/ocrd_page.py similarity index 100% rename from ocrd_models/ocrd_models/ocrd_page.py rename to src/ocrd_models/ocrd_page.py diff --git a/ocrd_models/ocrd_models/ocrd_page_generateds.py b/src/ocrd_models/ocrd_page_generateds.py similarity index 100% rename from ocrd_models/ocrd_models/ocrd_page_generateds.py rename to src/ocrd_models/ocrd_page_generateds.py diff --git a/ocrd_models/ocrd_models/ocrd_xml_base.py b/src/ocrd_models/ocrd_xml_base.py similarity index 100% rename from ocrd_models/ocrd_models/ocrd_xml_base.py rename to src/ocrd_models/ocrd_xml_base.py diff --git a/ocrd_models/ocrd_models/report.py b/src/ocrd_models/report.py similarity index 100% rename from ocrd_models/ocrd_models/report.py rename to src/ocrd_models/report.py diff --git a/ocrd_models/ocrd_models/utils.py b/src/ocrd_models/utils.py similarity index 100% rename from ocrd_models/ocrd_models/utils.py rename to src/ocrd_models/utils.py diff --git a/ocrd_network/ocrd_network/__init__.py b/src/ocrd_network/__init__.py similarity index 100% rename from ocrd_network/ocrd_network/__init__.py rename to src/ocrd_network/__init__.py diff --git a/ocrd_network/ocrd_network/cli/__init__.py b/src/ocrd_network/cli/__init__.py similarity index 100% rename from ocrd_network/ocrd_network/cli/__init__.py rename to src/ocrd_network/cli/__init__.py diff --git a/ocrd_network/ocrd_network/cli/client.py b/src/ocrd_network/cli/client.py similarity index 100% rename from ocrd_network/ocrd_network/cli/client.py rename to src/ocrd_network/cli/client.py diff --git a/ocrd_network/ocrd_network/cli/processing_server.py b/src/ocrd_network/cli/processing_server.py similarity index 100% rename from ocrd_network/ocrd_network/cli/processing_server.py rename to src/ocrd_network/cli/processing_server.py diff --git a/ocrd_network/ocrd_network/cli/processing_worker.py b/src/ocrd_network/cli/processing_worker.py similarity index 100% rename from ocrd_network/ocrd_network/cli/processing_worker.py rename to src/ocrd_network/cli/processing_worker.py diff --git a/ocrd_network/ocrd_network/cli/processor_server.py b/src/ocrd_network/cli/processor_server.py similarity index 100% rename from ocrd_network/ocrd_network/cli/processor_server.py rename to src/ocrd_network/cli/processor_server.py diff --git a/ocrd_network/ocrd_network/client.py b/src/ocrd_network/client.py similarity index 100% rename from ocrd_network/ocrd_network/client.py rename to src/ocrd_network/client.py diff --git a/ocrd_network/ocrd_network/constants.py b/src/ocrd_network/constants.py similarity index 100% rename from ocrd_network/ocrd_network/constants.py rename to src/ocrd_network/constants.py diff --git a/ocrd_network/ocrd_network/database.py b/src/ocrd_network/database.py similarity index 100% rename from ocrd_network/ocrd_network/database.py rename to src/ocrd_network/database.py diff --git a/ocrd_network/ocrd_network/deployer.py b/src/ocrd_network/deployer.py similarity index 100% rename from ocrd_network/ocrd_network/deployer.py rename to src/ocrd_network/deployer.py diff --git a/ocrd_network/ocrd_network/deployment_utils.py b/src/ocrd_network/deployment_utils.py similarity index 100% rename from ocrd_network/ocrd_network/deployment_utils.py rename to src/ocrd_network/deployment_utils.py diff --git a/ocrd_network/ocrd_network/logging.py b/src/ocrd_network/logging.py similarity index 100% rename from ocrd_network/ocrd_network/logging.py rename to src/ocrd_network/logging.py diff --git a/ocrd_network/ocrd_network/models/__init__.py b/src/ocrd_network/models/__init__.py similarity index 100% rename from ocrd_network/ocrd_network/models/__init__.py rename to src/ocrd_network/models/__init__.py diff --git a/ocrd_network/ocrd_network/models/job.py b/src/ocrd_network/models/job.py similarity index 100% rename from ocrd_network/ocrd_network/models/job.py rename to src/ocrd_network/models/job.py diff --git a/ocrd_network/ocrd_network/models/messages.py b/src/ocrd_network/models/messages.py similarity index 100% rename from ocrd_network/ocrd_network/models/messages.py rename to src/ocrd_network/models/messages.py diff --git a/ocrd_network/ocrd_network/models/ocrd_tool.py b/src/ocrd_network/models/ocrd_tool.py similarity index 100% rename from ocrd_network/ocrd_network/models/ocrd_tool.py rename to src/ocrd_network/models/ocrd_tool.py diff --git a/ocrd_network/ocrd_network/models/workflow.py b/src/ocrd_network/models/workflow.py similarity index 100% rename from ocrd_network/ocrd_network/models/workflow.py rename to src/ocrd_network/models/workflow.py diff --git a/ocrd_network/ocrd_network/models/workspace.py b/src/ocrd_network/models/workspace.py similarity index 100% rename from ocrd_network/ocrd_network/models/workspace.py rename to src/ocrd_network/models/workspace.py diff --git a/ocrd_network/ocrd_network/param_validators.py b/src/ocrd_network/param_validators.py similarity index 100% rename from ocrd_network/ocrd_network/param_validators.py rename to src/ocrd_network/param_validators.py diff --git a/ocrd_network/ocrd_network/process_helpers.py b/src/ocrd_network/process_helpers.py similarity index 100% rename from ocrd_network/ocrd_network/process_helpers.py rename to src/ocrd_network/process_helpers.py diff --git a/ocrd_network/ocrd_network/processing_server.py b/src/ocrd_network/processing_server.py similarity index 100% rename from ocrd_network/ocrd_network/processing_server.py rename to src/ocrd_network/processing_server.py diff --git a/ocrd_network/ocrd_network/processing_worker.py b/src/ocrd_network/processing_worker.py similarity index 100% rename from ocrd_network/ocrd_network/processing_worker.py rename to src/ocrd_network/processing_worker.py diff --git a/ocrd_network/ocrd_network/processor_server.py b/src/ocrd_network/processor_server.py similarity index 100% rename from ocrd_network/ocrd_network/processor_server.py rename to src/ocrd_network/processor_server.py diff --git a/ocrd_network/ocrd_network/rabbitmq_utils/__init__.py b/src/ocrd_network/rabbitmq_utils/__init__.py similarity index 100% rename from ocrd_network/ocrd_network/rabbitmq_utils/__init__.py rename to src/ocrd_network/rabbitmq_utils/__init__.py diff --git a/ocrd_network/ocrd_network/rabbitmq_utils/connector.py b/src/ocrd_network/rabbitmq_utils/connector.py similarity index 100% rename from ocrd_network/ocrd_network/rabbitmq_utils/connector.py rename to src/ocrd_network/rabbitmq_utils/connector.py diff --git a/ocrd_network/ocrd_network/rabbitmq_utils/constants.py b/src/ocrd_network/rabbitmq_utils/constants.py similarity index 100% rename from ocrd_network/ocrd_network/rabbitmq_utils/constants.py rename to src/ocrd_network/rabbitmq_utils/constants.py diff --git a/ocrd_network/ocrd_network/rabbitmq_utils/consumer.py b/src/ocrd_network/rabbitmq_utils/consumer.py similarity index 100% rename from ocrd_network/ocrd_network/rabbitmq_utils/consumer.py rename to src/ocrd_network/rabbitmq_utils/consumer.py diff --git a/ocrd_network/ocrd_network/rabbitmq_utils/ocrd_messages.py b/src/ocrd_network/rabbitmq_utils/ocrd_messages.py similarity index 100% rename from ocrd_network/ocrd_network/rabbitmq_utils/ocrd_messages.py rename to src/ocrd_network/rabbitmq_utils/ocrd_messages.py diff --git a/ocrd_network/ocrd_network/rabbitmq_utils/publisher.py b/src/ocrd_network/rabbitmq_utils/publisher.py similarity index 100% rename from ocrd_network/ocrd_network/rabbitmq_utils/publisher.py rename to src/ocrd_network/rabbitmq_utils/publisher.py diff --git a/ocrd_network/ocrd_network/runtime_data.py b/src/ocrd_network/runtime_data.py similarity index 100% rename from ocrd_network/ocrd_network/runtime_data.py rename to src/ocrd_network/runtime_data.py diff --git a/ocrd_network/ocrd_network/server_cache.py b/src/ocrd_network/server_cache.py similarity index 100% rename from ocrd_network/ocrd_network/server_cache.py rename to src/ocrd_network/server_cache.py diff --git a/ocrd_network/ocrd_network/server_utils.py b/src/ocrd_network/server_utils.py similarity index 100% rename from ocrd_network/ocrd_network/server_utils.py rename to src/ocrd_network/server_utils.py diff --git a/ocrd_network/ocrd_network/utils.py b/src/ocrd_network/utils.py similarity index 100% rename from ocrd_network/ocrd_network/utils.py rename to src/ocrd_network/utils.py diff --git a/ocrd_models/ocrd_page_user_methods.py b/src/ocrd_page_user_methods.py similarity index 100% rename from ocrd_models/ocrd_page_user_methods.py rename to src/ocrd_page_user_methods.py diff --git a/ocrd_models/ocrd_page_user_methods/__hash__.py b/src/ocrd_page_user_methods/__hash__.py similarity index 100% rename from ocrd_models/ocrd_page_user_methods/__hash__.py rename to src/ocrd_page_user_methods/__hash__.py diff --git a/ocrd_models/ocrd_page_user_methods/clear_AllIndexed.py b/src/ocrd_page_user_methods/clear_AllIndexed.py similarity index 100% rename from ocrd_models/ocrd_page_user_methods/clear_AllIndexed.py rename to src/ocrd_page_user_methods/clear_AllIndexed.py diff --git a/ocrd_models/ocrd_page_user_methods/exportChildren_GroupType.py b/src/ocrd_page_user_methods/exportChildren_GroupType.py similarity index 100% rename from ocrd_models/ocrd_page_user_methods/exportChildren_GroupType.py rename to src/ocrd_page_user_methods/exportChildren_GroupType.py diff --git a/ocrd_models/ocrd_page_user_methods/extend_AllIndexed.py b/src/ocrd_page_user_methods/extend_AllIndexed.py similarity index 100% rename from ocrd_models/ocrd_page_user_methods/extend_AllIndexed.py rename to src/ocrd_page_user_methods/extend_AllIndexed.py diff --git a/ocrd_models/ocrd_page_user_methods/get_AllAlternativeImagePaths.py b/src/ocrd_page_user_methods/get_AllAlternativeImagePaths.py similarity index 100% rename from ocrd_models/ocrd_page_user_methods/get_AllAlternativeImagePaths.py rename to src/ocrd_page_user_methods/get_AllAlternativeImagePaths.py diff --git a/ocrd_models/ocrd_page_user_methods/get_AllAlternativeImages.py b/src/ocrd_page_user_methods/get_AllAlternativeImages.py similarity index 100% rename from ocrd_models/ocrd_page_user_methods/get_AllAlternativeImages.py rename to src/ocrd_page_user_methods/get_AllAlternativeImages.py diff --git a/ocrd_models/ocrd_page_user_methods/get_AllIndexed.py b/src/ocrd_page_user_methods/get_AllIndexed.py similarity index 100% rename from ocrd_models/ocrd_page_user_methods/get_AllIndexed.py rename to src/ocrd_page_user_methods/get_AllIndexed.py diff --git a/ocrd_models/ocrd_page_user_methods/get_AllRegions.py b/src/ocrd_page_user_methods/get_AllRegions.py similarity index 100% rename from ocrd_models/ocrd_page_user_methods/get_AllRegions.py rename to src/ocrd_page_user_methods/get_AllRegions.py diff --git a/ocrd_models/ocrd_page_user_methods/get_AllTextLines.py b/src/ocrd_page_user_methods/get_AllTextLines.py similarity index 100% rename from ocrd_models/ocrd_page_user_methods/get_AllTextLines.py rename to src/ocrd_page_user_methods/get_AllTextLines.py diff --git a/ocrd_models/ocrd_page_user_methods/get_UnorderedGroupChildren.py b/src/ocrd_page_user_methods/get_UnorderedGroupChildren.py similarity index 100% rename from ocrd_models/ocrd_page_user_methods/get_UnorderedGroupChildren.py rename to src/ocrd_page_user_methods/get_UnorderedGroupChildren.py diff --git a/ocrd_models/ocrd_page_user_methods/id.py b/src/ocrd_page_user_methods/id.py similarity index 100% rename from ocrd_models/ocrd_page_user_methods/id.py rename to src/ocrd_page_user_methods/id.py diff --git a/ocrd_models/ocrd_page_user_methods/invalidate_AlternativeImage.py b/src/ocrd_page_user_methods/invalidate_AlternativeImage.py similarity index 100% rename from ocrd_models/ocrd_page_user_methods/invalidate_AlternativeImage.py rename to src/ocrd_page_user_methods/invalidate_AlternativeImage.py diff --git a/ocrd_models/ocrd_page_user_methods/prune_ReadingOrder.py b/src/ocrd_page_user_methods/prune_ReadingOrder.py similarity index 100% rename from ocrd_models/ocrd_page_user_methods/prune_ReadingOrder.py rename to src/ocrd_page_user_methods/prune_ReadingOrder.py diff --git a/ocrd_models/ocrd_page_user_methods/set_Border.py b/src/ocrd_page_user_methods/set_Border.py similarity index 100% rename from ocrd_models/ocrd_page_user_methods/set_Border.py rename to src/ocrd_page_user_methods/set_Border.py diff --git a/ocrd_models/ocrd_page_user_methods/set_Coords.py b/src/ocrd_page_user_methods/set_Coords.py similarity index 100% rename from ocrd_models/ocrd_page_user_methods/set_Coords.py rename to src/ocrd_page_user_methods/set_Coords.py diff --git a/ocrd_models/ocrd_page_user_methods/set_orientation.py b/src/ocrd_page_user_methods/set_orientation.py similarity index 100% rename from ocrd_models/ocrd_page_user_methods/set_orientation.py rename to src/ocrd_page_user_methods/set_orientation.py diff --git a/ocrd_models/ocrd_page_user_methods/set_points.py b/src/ocrd_page_user_methods/set_points.py similarity index 100% rename from ocrd_models/ocrd_page_user_methods/set_points.py rename to src/ocrd_page_user_methods/set_points.py diff --git a/ocrd_models/ocrd_page_user_methods/sort_AllIndexed.py b/src/ocrd_page_user_methods/sort_AllIndexed.py similarity index 100% rename from ocrd_models/ocrd_page_user_methods/sort_AllIndexed.py rename to src/ocrd_page_user_methods/sort_AllIndexed.py diff --git a/ocrd_utils/ocrd_utils/__init__.py b/src/ocrd_utils/__init__.py similarity index 100% rename from ocrd_utils/ocrd_utils/__init__.py rename to src/ocrd_utils/__init__.py diff --git a/ocrd_utils/ocrd_utils/config.py b/src/ocrd_utils/config.py similarity index 99% rename from ocrd_utils/ocrd_utils/config.py rename to src/ocrd_utils/config.py index 7b4538223b..cc12a31152 100644 --- a/ocrd_utils/ocrd_utils/config.py +++ b/src/ocrd_utils/config.py @@ -179,10 +179,12 @@ def _ocrd_download_timeout_parser(val): config.add("XDG_DATA_HOME", description="Directory to look for `./ocrd/resources.yml` (i.e. `ocrd resmgr` user database)", + parser=lambda val: Path(val), default=(True, lambda: Path(config.HOME, '.local/share'))) config.add("XDG_CONFIG_HOME", description="Directory to look for `./ocrd-resources/*` (i.e. `ocrd resmgr` data location)", + parser=lambda val: Path(val), default=(True, lambda: Path(config.HOME, '.config'))) config.add("OCRD_LOGGING_DEBUG", diff --git a/ocrd_utils/ocrd_utils/constants.py b/src/ocrd_utils/constants.py similarity index 98% rename from ocrd_utils/ocrd_utils/constants.py rename to src/ocrd_utils/constants.py index 1fbd9bf421..0b9f0ae02b 100644 --- a/ocrd_utils/ocrd_utils/constants.py +++ b/src/ocrd_utils/constants.py @@ -18,7 +18,7 @@ 'VERSION', ] -VERSION = get_distribution('ocrd_utils').version +VERSION = get_distribution('ocrd').version MIMETYPE_PAGE = 'application/vnd.prima.page+xml' diff --git a/ocrd_utils/ocrd_utils/deprecate.py b/src/ocrd_utils/deprecate.py similarity index 100% rename from ocrd_utils/ocrd_utils/deprecate.py rename to src/ocrd_utils/deprecate.py diff --git a/ocrd_utils/ocrd_utils/image.py b/src/ocrd_utils/image.py similarity index 100% rename from ocrd_utils/ocrd_utils/image.py rename to src/ocrd_utils/image.py diff --git a/ocrd_utils/ocrd_utils/introspect.py b/src/ocrd_utils/introspect.py similarity index 100% rename from ocrd_utils/ocrd_utils/introspect.py rename to src/ocrd_utils/introspect.py diff --git a/ocrd_utils/ocrd_utils/logging.py b/src/ocrd_utils/logging.py similarity index 100% rename from ocrd_utils/ocrd_utils/logging.py rename to src/ocrd_utils/logging.py diff --git a/ocrd_utils/ocrd_logging.conf b/src/ocrd_utils/ocrd_logging.conf similarity index 100% rename from ocrd_utils/ocrd_logging.conf rename to src/ocrd_utils/ocrd_logging.conf diff --git a/ocrd_utils/ocrd_utils/os.py b/src/ocrd_utils/os.py similarity index 100% rename from ocrd_utils/ocrd_utils/os.py rename to src/ocrd_utils/os.py diff --git a/ocrd_utils/ocrd_utils/str.py b/src/ocrd_utils/str.py similarity index 100% rename from ocrd_utils/ocrd_utils/str.py rename to src/ocrd_utils/str.py diff --git a/ocrd_validators/ocrd_validators/__init__.py b/src/ocrd_validators/__init__.py similarity index 100% rename from ocrd_validators/ocrd_validators/__init__.py rename to src/ocrd_validators/__init__.py diff --git a/ocrd_validators/ocrd_validators/bagit-profile.yml b/src/ocrd_validators/bagit-profile.yml similarity index 100% rename from ocrd_validators/ocrd_validators/bagit-profile.yml rename to src/ocrd_validators/bagit-profile.yml diff --git a/ocrd_validators/ocrd_validators/constants.py b/src/ocrd_validators/constants.py similarity index 100% rename from ocrd_validators/ocrd_validators/constants.py rename to src/ocrd_validators/constants.py diff --git a/ocrd_validators/ocrd_validators/json_validator.py b/src/ocrd_validators/json_validator.py similarity index 100% rename from ocrd_validators/ocrd_validators/json_validator.py rename to src/ocrd_validators/json_validator.py diff --git a/ocrd_validators/ocrd_validators/message_processing.schema.yml b/src/ocrd_validators/message_processing.schema.yml similarity index 100% rename from ocrd_validators/ocrd_validators/message_processing.schema.yml rename to src/ocrd_validators/message_processing.schema.yml diff --git a/ocrd_validators/ocrd_validators/message_result.schema.yml b/src/ocrd_validators/message_result.schema.yml similarity index 100% rename from ocrd_validators/ocrd_validators/message_result.schema.yml rename to src/ocrd_validators/message_result.schema.yml diff --git a/ocrd_validators/ocrd_validators/mets.xsd b/src/ocrd_validators/mets.xsd similarity index 100% rename from ocrd_validators/ocrd_validators/mets.xsd rename to src/ocrd_validators/mets.xsd diff --git a/ocrd_validators/ocrd_validators/ocrd_network_message_validator.py b/src/ocrd_validators/ocrd_network_message_validator.py similarity index 100% rename from ocrd_validators/ocrd_validators/ocrd_network_message_validator.py rename to src/ocrd_validators/ocrd_network_message_validator.py diff --git a/ocrd_validators/ocrd_validators/ocrd_tool.schema.yml b/src/ocrd_validators/ocrd_tool.schema.yml similarity index 100% rename from ocrd_validators/ocrd_validators/ocrd_tool.schema.yml rename to src/ocrd_validators/ocrd_tool.schema.yml diff --git a/ocrd_validators/ocrd_validators/ocrd_tool_validator.py b/src/ocrd_validators/ocrd_tool_validator.py similarity index 100% rename from ocrd_validators/ocrd_validators/ocrd_tool_validator.py rename to src/ocrd_validators/ocrd_tool_validator.py diff --git a/ocrd_validators/ocrd_validators/ocrd_zip_validator.py b/src/ocrd_validators/ocrd_zip_validator.py similarity index 100% rename from ocrd_validators/ocrd_validators/ocrd_zip_validator.py rename to src/ocrd_validators/ocrd_zip_validator.py diff --git a/ocrd_validators/ocrd_validators/page.xsd b/src/ocrd_validators/page.xsd similarity index 100% rename from ocrd_validators/ocrd_validators/page.xsd rename to src/ocrd_validators/page.xsd diff --git a/ocrd_validators/ocrd_validators/page_validator.py b/src/ocrd_validators/page_validator.py similarity index 100% rename from ocrd_validators/ocrd_validators/page_validator.py rename to src/ocrd_validators/page_validator.py diff --git a/ocrd_validators/ocrd_validators/parameter_validator.py b/src/ocrd_validators/parameter_validator.py similarity index 100% rename from ocrd_validators/ocrd_validators/parameter_validator.py rename to src/ocrd_validators/parameter_validator.py diff --git a/ocrd_validators/ocrd_validators/processing_server_config.schema.yml b/src/ocrd_validators/processing_server_config.schema.yml similarity index 100% rename from ocrd_validators/ocrd_validators/processing_server_config.schema.yml rename to src/ocrd_validators/processing_server_config.schema.yml diff --git a/ocrd_validators/ocrd_validators/processing_server_config_validator.py b/src/ocrd_validators/processing_server_config_validator.py similarity index 100% rename from ocrd_validators/ocrd_validators/processing_server_config_validator.py rename to src/ocrd_validators/processing_server_config_validator.py diff --git a/ocrd_validators/ocrd_validators/resource_list_validator.py b/src/ocrd_validators/resource_list_validator.py similarity index 100% rename from ocrd_validators/ocrd_validators/resource_list_validator.py rename to src/ocrd_validators/resource_list_validator.py diff --git a/ocrd_validators/ocrd_validators/workspace_validator.py b/src/ocrd_validators/workspace_validator.py similarity index 100% rename from ocrd_validators/ocrd_validators/workspace_validator.py rename to src/ocrd_validators/workspace_validator.py diff --git a/ocrd_validators/ocrd_validators/xlink.xsd b/src/ocrd_validators/xlink.xsd similarity index 100% rename from ocrd_validators/ocrd_validators/xlink.xsd rename to src/ocrd_validators/xlink.xsd diff --git a/ocrd_validators/ocrd_validators/xsd_mets_validator.py b/src/ocrd_validators/xsd_mets_validator.py similarity index 100% rename from ocrd_validators/ocrd_validators/xsd_mets_validator.py rename to src/ocrd_validators/xsd_mets_validator.py diff --git a/ocrd_validators/ocrd_validators/xsd_page_validator.py b/src/ocrd_validators/xsd_page_validator.py similarity index 100% rename from ocrd_validators/ocrd_validators/xsd_page_validator.py rename to src/ocrd_validators/xsd_page_validator.py diff --git a/ocrd_validators/ocrd_validators/xsd_validator.py b/src/ocrd_validators/xsd_validator.py similarity index 100% rename from ocrd_validators/ocrd_validators/xsd_validator.py rename to src/ocrd_validators/xsd_validator.py diff --git a/tests/cli/test_bashlib.py b/tests/cli/test_bashlib.py index c0e8854f3b..74a623d1b6 100644 --- a/tests/cli/test_bashlib.py +++ b/tests/cli/test_bashlib.py @@ -102,8 +102,8 @@ def test_bashlib_minversion(self): exit_code, out, err = self.invoke_bash( "source $(ocrd bashlib filename) && ocrd__minversion 2.29.0") assert exit_code == 0 - major, minor = map(int, VERSION.split('.')[0:2]) - version = "%d.%d.%d" % (major, minor + 1, 0) + (major, minor, patch) = map(int, str(VERSION).split('.')) + version = "%d.%d.%d" % (major, minor + 1, patch) exit_code, out, err = self.invoke_bash( "source $(ocrd bashlib filename) && ocrd__minversion " + version) assert exit_code > 0 diff --git a/tests/test_logging_conf.py b/tests/test_logging_conf.py index 1bfe742b76..898722a413 100644 --- a/tests/test_logging_conf.py +++ b/tests/test_logging_conf.py @@ -30,7 +30,7 @@ def resetLogging(): def _fixture_loggin_conf(tmpdir): path_logging_conf_orig = os.path.join( - str(TEST_ROOT), 'ocrd_utils', 'ocrd_logging.conf') + str(TEST_ROOT), 'src', 'ocrd_utils', 'ocrd_logging.conf') path_logging_conf_dest = os.path.join(str(tmpdir), 'ocrd_logging.conf') shutil.copy(path_logging_conf_orig, path_logging_conf_dest) return str(tmpdir) diff --git a/tests/test_resource_manager.py b/tests/test_resource_manager.py index 785b568833..fb6db3adc4 100644 --- a/tests/test_resource_manager.py +++ b/tests/test_resource_manager.py @@ -1,8 +1,9 @@ import os from pathlib import Path -import pdb +# import pdb from ocrd.resource_manager import OcrdResourceManager +from ocrd_utils import config from ocrd_utils.os import get_ocrd_tool_json from pytest import raises, fixture @@ -20,6 +21,7 @@ def test_resources_manager_config_default(monkeypatch, tmp_path): # arrange monkeypatch.setenv('HOME', str(tmp_path)) + monkeypatch.delenv('XDG_CONFIG_HOME', raising=False) # act mgr = OcrdResourceManager() @@ -27,8 +29,11 @@ def test_resources_manager_config_default(monkeypatch, tmp_path): # assert default_config_dir = os.path.join(os.environ['HOME'], '.config', 'ocrd') f = Path(default_config_dir) / CONST_RESOURCE_YML - assert f.exists() + assert os.environ['HOME'] == str(tmp_path) + assert config.HOME == tmp_path + assert Path.home() == tmp_path assert f == mgr.user_list + assert f.exists() assert mgr.add_to_user_database('ocrd-foo', f) # pdb.set_trace()