Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional modules and editable mode installation #24

Merged
merged 19 commits into from
Dec 12, 2019

Conversation

bertsky
Copy link
Collaborator

@bertsky bertsky commented Dec 8, 2019

This is another major leap forward. It encapsulates knowledge about submodule specifics even better (esp. system dependencies) and allows selectively factoring modules out of all targets (including deps-ubuntu and docker). It also allows installing pip packages in editable mode (to save space and enable faster update regimes, both especially helpful in Docker images). Lastly, it adds support for a (non-git controlled) local/site customization makefile.

@stweil, this also avoids installing Tesseract both from source and PPA at the same time.

@kba, this also contains preconfigured Docker builds of different extent (which you could offer on an automatic basis via Dockerhub).

I did 2dfe06a in light of #15, but we probably should find a better way to fix the issue before merging.

Please don't ask me to split 009a042 into multiple commits – it's hard and would not make the changes more comprehensible at all (due to interdependencies). I'll gladly elaborate on any individual change here, though.

Makefile Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
.gitignore Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated

.PHONY: ocrd
ocrd: $(BIN)/ocrd
$(BIN)/ocrd: core
. $(ACTIVATE_VENV) && cd $< && make install PIP_INSTALL="$(PIP_INSTALL) --force-reinstall"
. $(ACTIVATE_VENV) && $(MAKE) -C $< install PIP_INSTALL="$(PIP) install --force-reinstall $(PIP_OPTIONS)"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those --force-reinstall options are sometimes nagging. I'd like an option to disable them in local.mk (after this PR was merged).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! We could wrap them in a variable with install --force-reinstall that you can then override.

But I'm curious: what problems do they give you? I introduced this to ensure the executable files we use as targets always get updated along with new module versions (even if the new version did not directly affect them). So if you remove this option, make will attempt re-building them every time.

Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@bertsky
Copy link
Collaborator Author

bertsky commented Dec 10, 2019

@kba, if you want I can add 2 commits that remove ocrd_kraken and ocrd_ocropy now. Oh, and please tag this repo with the topic ocr-d!

@bertsky
Copy link
Collaborator Author

bertsky commented Dec 11, 2019

So, any more suggestions/objections, or can I merge?

Copy link
Collaborator

@stweil stweil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

~/src/github/OCR-D/ocrd_all/ocrd_cis$ git log b79e1c07b9b1ed695999a529b5e91ba1d9986f95
fatal: bad object b79e1c07b9b1ed695999a529b5e91ba1d9986f95

@bertsky
Copy link
Collaborator Author

bertsky commented Dec 11, 2019

~/src/github/OCR-D/ocrd_all/ocrd_cis$ git log b79e1c07b9b1ed695999a529b5e91ba1d9986f95
fatal: bad object b79e1c07b9b1ed695999a529b5e91ba1d9986f95

Thanks @stweil! I was sloppy with the module updates (ocrd_cis uses/needs the dev branch). I have fixed this and force-pushed to not clutter the history.

bertsky and others added 9 commits December 11, 2019 19:54
- allow overriding OCRD_MODULES to select only a subset of
  git submodules for all targets:
  - only look for git submodules if OCRD_MODULES is empty or unset
  - exclude all rules and variables of deactivated modules
    (in module-local scope with conditionals)
- better encapsulation for `deps-ubuntu`:
  - add modules with local `deps-ubuntu` as prerequisites directly
    instead of aggregating their names in a list
  - aggregate packages for other modules in a list
    (in module-local scope)
- avoid installing Tesseract from both source and PPA at the same time:
  - add `install-tesseract` to `all` if `tesseract` module is active
  - use `deps-ubuntu` from `ocrd_tesseract` iff `tesseract` module is inactive
  - add `libleptonica-dev` if `tesseract` module is active
- try to get similar sets of Tesseract languages/models,
  regardless of whether installing from source or PPA:
  use a single variable TESSERACT_MODELS for both download and apt-get
  (variable can be overridden as usual, and triggering downloads
   manually/selectively remains possible, too)
- provide `clean-tesseract` and `clean-olena`,
  make `clean` depend on them
- allow pip installation in editable mode:
  - allow adding `-e` to `pip install` options
  - split up PIP_INSTALL into PIP and PIP_OPTIONS
    (because `-e` must always be last if present, and must only apply
     to source directories, not mere package names)
- simplify docker build, and add preconfigured selections:
  - use new OCRD_MODULES filtering instead of parsing dependencies
    for DOCKER_MODULES
  - use wildcard on `.git` instead of `git init` to avoid submodule updates
    (more robust, also works with editable mode)
  - when installing in editable mode, don't remove the build directory
    (which now contains the only copy of the modules),
    but only clean its build directories
  - be more selective in workaround for ImageMagick PDF/PS security restriction
  - besides `docker` (now) with user selection of OCRD_MODULES,
    add target `dockers` dependent on 3 new preconfigured subsets of OCRD_MODULES:
    `docker-minimum` / `docker-medium` / `docker-maximum`
  - make editable mode the default for these unless DOCKERS_WITHOUT_REPOS is set:
    `docker-minimum-git` / `docker-medium-git` / `docker-maximum-git`
  - add a subtag for all Docker images based on their target name
    (e.g. use `ocrd/all:medium-git` for docker-medium-git, but keep
     `:latest` when target was just `docker`)
- include `local.mk` if present to allow persisting variable choices
  (or any other customization) across invocations
- update README to reflect above changes

- (during rebase:) use correct module name for ocrd_pc_segmentation
@stweil
Copy link
Collaborator

stweil commented Dec 11, 2019

@bertsky, I rebased your commits and added some more commits. Like that, I think it is ready for merging. Please review my additions.

Copy link
Collaborator

@stweil stweil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make no longer shows the help text, but runs make all.

@stweil
Copy link
Collaborator

stweil commented Dec 11, 2019

make install-tesseract fails now on Linux and macOS because of many missing static libraries.

Copy link
Collaborator Author

@bertsky bertsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stweil These changes break my uniform solution for both wget (for local build) and apt (for PPA install). I cannot even request changes here, because:

Pull request authors can't request changes on their own pull request.

Why didn't you first discuss this with me? If you wanted to keep a minimum list, not overridable by the user, this could have been done much simpler (and without breaking uniformity with the PPA method).

@bertsky
Copy link
Collaborator Author

bertsky commented Dec 11, 2019

The last 2 changes are ok of course. (Strange that the autoconf manual is incorrect and you still need --disable-shared on macOS...)

@bertsky
Copy link
Collaborator Author

bertsky commented Dec 11, 2019

These changes break my uniform solution for both wget (for local build) and apt (for PPA install).

Fixed that now.

@stweil, your review status still says 1 change requested?

@stweil stweil merged commit 3d76f5e into OCR-D:master Dec 12, 2019
@stweil
Copy link
Collaborator

stweil commented Dec 12, 2019

@stweil, your review status still says 1 change requested?

That was because of the broken default help goal (which I fixed later in a commit without updating the status).

@bertsky bertsky deleted the conditional-modules branch August 19, 2020 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants