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

mkdir -p sharedir before touch #16

Merged
merged 3 commits into from
Dec 18, 2019
Merged

Conversation

kba
Copy link
Member

@kba kba commented Dec 6, 2019

Otherwise I get a build failure for make ocrd-tesserocr-binarize with a newly created venv.

@kba kba requested review from bertsky and stweil December 6, 2019 11:12
Copy link
Collaborator

@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.

Sorry, didn't see that one. But better do it as an OO dependency. (And maybe the others need that as well?)

BTW, GNU make 4.2 now has syntax for multiple (parallel) targets in one rule (:& instead of :), which would make solutions like this obsolete. But of course, we cannot rely on such features (yet).

@kba kba requested a review from bertsky December 6, 2019 18:49
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.

I'd prefer a more direct solution: mkdir -p sharedir before touch (as the subject already says).

@mkdir -p $(SHARE) && touch $@

@stweil
Copy link
Collaborator

stweil commented Dec 6, 2019

And while changing that issue, I also suggest to change

SHARE := $(VIRTUAL_ENV)/share/ocrd_all

Then there are no stray empty files on the share level which typically only contains directories, and it is also clear were those files belong to.

@bertsky
Copy link
Collaborator

bertsky commented Dec 6, 2019

I'd prefer a more direct solution: mkdir -p sharedir before touch (as the subject already says).

@mkdir -p $(SHARE) && touch $@

But this is actually the indirect solution! And it's exactly equivalent to the first version of this PR. I specifically requested above changes (doing mkdir via a order-only prerequisite) because:

  1. SHARE directory is needed by other rules, too
  2. shorter than the extra mkdir in every such rule
  3. slightly faster

@bertsky
Copy link
Collaborator

bertsky commented Dec 6, 2019

And while changing that issue, I also suggest to change

SHARE := $(VIRTUAL_ENV)/share/ocrd_all

Then there are no stray empty files on the share level which typically only contains directories, and it is also clear were those files belong to.

I don't quite see the point because it's our local venv only (or our Docker image), and we=ocrd_all – except if you want to set VIRTUAL_ENV=/usr/local in the host system. But I have no objection either.

Copy link
Collaborator

@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.

Thanks!

@stweil
Copy link
Collaborator

stweil commented Dec 6, 2019

It's direct because it is easy for me to see where it is used. Which other rules need SHARE?

@stweil
Copy link
Collaborator

stweil commented Dec 6, 2019

slightly faster

Then put it in $(VIRTUAL_ENV). That already exists, there is no subdirectory needed, no extra code is needed, and it's our local venv, so we can do anything. :-)

@bertsky
Copy link
Collaborator

bertsky commented Dec 6, 2019

Apart from the pattern rule:

@kba, you need to add | $(SHARE) there as well – but as I said, I cannot make suggestions outside of the hunk context in GH.

@bertsky
Copy link
Collaborator

bertsky commented Dec 6, 2019

Then put it in $(VIRTUAL_ENV). No subdirectory needed, no extra code needed, and it's our local venv, so we can do anything. :-)

Sure, why not!

@stweil
Copy link
Collaborator

stweil commented Dec 6, 2019

numpy, clstm

Sure, that's the same kind of code, so it's not really new. Automatically fine when putting the touched files in $(VIRTUAL_ENV).

@stweil
Copy link
Collaborator

stweil commented Dec 6, 2019

That makes the patch too trivial. What about adding _timestamp to the touched filenames?

@bertsky
Copy link
Collaborator

bertsky commented Dec 6, 2019

That makes the patch too trivial.

Less is more. Took 3 devs to arrive at! And it's not even done yet.

What about adding _timestamp to the touched filenames?

What for? OO deps don't ever update their dependents due to being older (by design).

The only reason for these pseudo-targets is to avoid installing the same pkg 11 times if the module has 11 CLIs, just because they are all mentioned in the same rule. There used to be no way to tell make that these targets are all built at once by the same recipe, except by formulating it as a pseudo-pattern rule (which is highly unreadable and next to incomprehensible). But no one wants to wait for or require GNU make 4.2.

@bertsky
Copy link
Collaborator

bertsky commented Dec 13, 2019

There used to be no way to tell make that these targets are all built at once by the same recipe, except by formulating it as a pseudo-pattern rule (which is highly unreadable and next to incomprehensible). But no one wants to wait for or require GNU make 4.2.

Or maybe we should in fact use pseudo-pattern rules to get the single-rule-multiple-output behaviour. That would not only eliminate the need for the above discussed pseudo-targets for numpy names, but also avoid running make install as many times as there are executables per module. I will make a PR for that so we can better discuss this option.

@bertsky
Copy link
Collaborator

bertsky commented Dec 13, 2019

Apart from the pattern rule:

* the [numpy rule](https://github.com/OCR-D/ocrd_all/blob/097948b6807385d3c7afe03765e9b432915f0a63/Makefile#L84)

* the [clstm rule](https://github.com/OCR-D/ocrd_all/blob/097948b6807385d3c7afe03765e9b432915f0a63/Makefile#L115)

@kba, you need to add | $(SHARE) there as well – but as I said, I cannot make suggestions outside of the hunk context in GH.

Done (along with rebase).

@bertsky
Copy link
Collaborator

bertsky commented Dec 14, 2019

There used to be no way to tell make that these targets are all built at once by the same recipe, except by formulating it as a pseudo-pattern rule (which is highly unreadable and next to incomprehensible). But no one wants to wait for or require GNU make 4.2.

Or maybe we should in fact use pseudo-pattern rules to get the single-rule-multiple-output behaviour. That would not only eliminate the need for the above discussed pseudo-targets for numpy names, but also avoid running make install as many times as there are executables per module. I will make a PR for that so we can better discuss this option.

Sorry, this was completely unrelated, as I can see now. The above is now in #25.

@bertsky
Copy link
Collaborator

bertsky commented Dec 14, 2019

@stweil are you ok with the current state of this PR, or do you insist we should change the make tokens of the pip targets for numpy, clstm and tesserocr from files in $(SHARE) to files in $(VIRTUAL_ENV)?

@kba
Copy link
Member Author

kba commented Dec 18, 2019

That makes the patch too trivial.

I think trivial is good. I like trivial. Can we merge this? It fixes the initial problem without complicating the Makefile further IMHO.

@stweil stweil merged commit ba7a53e into OCR-D:master Dec 18, 2019
@kba kba deleted the mkdir-before-touch branch December 18, 2019 13:00
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