Skip to content

Conversation

theuni
Copy link
Member

@theuni theuni commented Jun 1, 2016

This fixes the remaining out-of-tree issues:

  • The entire leveldb dir was copied out
  • Python caches were left hanging around
  • A qt file was left dangling in the build-dir
  • The rpc tests couldn't be run
  • OSX's make deploy was broken

make distcheck now passes, and Travis has been switched to an out-of-tree build for dogfooding purposes. Fingers-crossed that it works.

@theuni theuni force-pushed the out-of-tree-clean branch from 5ba8891 to 80f68b7 Compare June 2, 2016 00:25
theuni added 3 commits June 1, 2016 20:31
Don't glob the leveldb for dist. That means we need to enumerate the headers.
- clear the __pycache__ during 'make clean'
- Copy the qrc locale file to a temp location and remove it when finished
  (rcc expects everything to be in the same path)
- Link pull-tester/rpc-tests.py to the build dir
- Add the build-dir's config to the python path so that tests can find it
- The tests themselves are in srcdir
- Clean up __pycache__ in 'make clean'
@theuni theuni force-pushed the out-of-tree-clean branch 2 times, most recently from c2c7a4d to 142ffc7 Compare June 2, 2016 02:14
@@ -37,7 +38,7 @@
# terminal via ANSI escape sequences:
BOLD = ('\033[0m', '\033[1m')

RPC_TESTS_DIR = BUILDDIR + '/qa/rpc-tests/'
RPC_TESTS_DIR = SRCDIR + '/qa/rpc-tests/'
Copy link
Member

Choose a reason for hiding this comment

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

Note to myself: Does the cache (from create_cache.py et al.) end up in SRCDIR now?

Copy link
Member

Choose a reason for hiding this comment

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

Wasn't it always (and still is) the case that the cache ends up in the current directory when the tests are launched?

Copy link
Member

Choose a reason for hiding this comment

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

Correct.

Though, this should be changed. Having different caches lying around in folders that happen to be your working dir right then is misleading at best.

Anyway, this is unrelated to this pull.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm having a hard time answering that question because of the symlink interaction with Python. builddir/rpc-tests.py is now a symlink to sourcedir/rpc-tests.py because it needs to be writable. But that makes the definition of "current dir" hazy.

@MarcoFalke I suppose it would be best to make the location explicit.

Copy link
Member

Choose a reason for hiding this comment

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

Sure, this is on my list of cleanups. If no one beats me to it, you can expect it some time after feature freeze. ;)

@maflcko
Copy link
Member

maflcko commented Jun 2, 2016

Concept ACK

@theuni
Copy link
Member Author

theuni commented Jun 2, 2016

Generally speaking, if it's used as-is from git, it's srcdir. If it's generated or pre-processed, it's builddir.

Put another way: after checkout, think of srcdir as read-only. If anything is modified, it must happen in builddir.

@laanwj
Copy link
Member

laanwj commented Jun 3, 2016

utACK 142ffc7

@maflcko
Copy link
Member

maflcko commented Jun 3, 2016

make check fails with:

Running test/bitcoin-util-test.py...
Traceback (most recent call last):
  File "../../src/test/bitcoin-util-test.py", line 8, in <module>
    import buildenv
ImportError: bad magic number in 'buildenv': b'\x03\xf3\r\n'

@theuni
Copy link
Member Author

theuni commented Jun 3, 2016

@MarcoFalke Yes, I just saw that as well while trying to answer the question above. I'm not sure why Travis passes.

I'll fix that one up.

@theuni
Copy link
Member Author

theuni commented Jun 3, 2016

Pushed a quick fix for @MarcoFalke's problem. I'm not sure if we really need that or not, but it's probably better than each dev running into the problem and googling for themselves.

The issue is this: previous invocations of python2 in an in-tree build would leave a buildenv.pyc hanging around in srcdir. We prepend python's search path with builddir, but for some reason it ends up finding the srcdir/buildenv.pyc (and missing .py) before the builddir/buildenv.py. python3 refuses to load the old python2 .pyc, and errors because it can't find a .py at the same path for recompilation.

With python3, pyc's are organized into a pycache dir, and tagged like: pycache/buildenv.cpython-35.pyc. So it should not be possible to hit this case anymore.

@theuni theuni force-pushed the out-of-tree-clean branch from e5ccf56 to 340012d Compare June 3, 2016 18:42
…builds

This was caused by an pyc files hanging around from previous
python2 invocations, when the matching .py missing from that path.

This should not be a problem with python3's tagged caches.
@maflcko
Copy link
Member

maflcko commented Jun 3, 2016

Tested ACK 340012d

@@ -29,6 +29,7 @@
import tempfile
import re

sys.path.append("qa/pull-tester/")
Copy link
Member

Choose a reason for hiding this comment

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

Is it safe to assume everyone runs the tests from the root of buildir?

Copy link
Member

Choose a reason for hiding this comment

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

Probably not, but FWIW at least I do...

Copy link
Contributor

Choose a reason for hiding this comment

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

I do too.

Copy link
Member

Choose a reason for hiding this comment

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

Heh, I run them from qa/pull-tester. I had no idea you could run them from the root...

Copy link
Member

@maflcko maflcko Jun 4, 2016

Choose a reason for hiding this comment

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

Not sure how to fix this...

What about byte-compiling the rpc-tests.py instead of linking?

Copy link
Member

Choose a reason for hiding this comment

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

Heh, I run them from qa/pull-tester. I had no idea you could run them from the root...

Same here. But running from the root is ok with me.

@luke-jr
Copy link
Member

luke-jr commented Jun 5, 2016

Extensively-tested, with the following results:

I built, make check'd, and confirmed the reported version numbers for:

  1. Before this PR (plus Bugfix: Only use git for build info if the repository is actually the right one #7522), built in a clean git clone: v0.12.99.0-fd89d8e
  2. Before this PR (plus Bugfix: Only use git for build info if the repository is actually the right one #7522), built in a clean dist dir: v0.12.99.0-gfd89d8e
  3. Before this PR (plus Bugfix: Only use git for build info if the repository is actually the right one #7522), built in a clean dist dir under a foreign git checkout: v0.12.99.0-6862d12
  4. With this PR (plus Bugfix: Only use git for build info if the repository is actually the right one #7522), built in a clean git clone: v0.12.99.0-08cb06e
  5. With this PR (plus Bugfix: Only use git for build info if the repository is actually the right one #7522), built in a subdirectory of a clean git clone owned by another user: v0.12.99.0-08cb06e-dirty
  6. With this PR (plus Bugfix: Only use git for build info if the repository is actually the right one #7522), built in a parallel directory of a clean git clone owned by another user, under a foreign git checkout: v0.12.99.0-08cb06e-dirty
  7. With this PR (plus Bugfix: Only use git for build info if the repository is actually the right one #7522), built in a clean dist dir under a foreign git checkout: v0.12.99.0-6862d12
  8. With this PR (plus Bugfix: Only use git for build info if the repository is actually the right one #7522), built in a clean dist dir: v0.12.99.0-g08cb06e
  9. With this PR (plus Bugfix: Only use git for build info if the repository is actually the right one #7522), built in a subdirectory of a clean dist dir owned by another user: v0.12.99.0-g08cb06e
  10. With this PR (plus Bugfix: Only use git for build info if the repository is actually the right one #7522), built in a parallel directory of a clean dist dir owned by another user: v0.12.99.0-g08cb06e

Note that:

Observations:

  1. No change to previously-supported build scenarios.
  2. Dist dir builds within a foreign git repository incorrectly use the foreign git repo's commit hash in the version. This is already a problem (even with Bugfix: Only use git for build info if the repository is actually the right one #7522 apparently!), so not a blocker for this PR.
  3. Dist dir builds prefix the commit hash with 'g', while git builds do not. This is already a problem, so also not a regression in this PR.
  4. Clean git builds using a different build dir incorrectly tag the version as "-dirty". This should probably be fixed in this PR.

@laanwj
Copy link
Member

laanwj commented Jun 6, 2016

BTW seems make translate also needs changes to work out-of-tree. Not necessarily in this pull.

@laanwj
Copy link
Member

laanwj commented Jun 6, 2016

Looks like this is enough:

diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include
index 3b39919..327a3d1 100644
--- a/src/Makefile.qt.include
+++ b/src/Makefile.qt.include
@@ -390,13 +390,13 @@ QT_QM=$(QT_TS:.ts=.qm)

 SECONDARY: $(QT_QM)

-qt/bitcoinstrings.cpp: $(libbitcoin_server_a_SOURCES) $(libbitcoin_wallet_a_SOURCES)
+$(srcdir)/qt/bitcoinstrings.cpp: $(libbitcoin_server_a_SOURCES) $(libbitcoin_wallet_a_SOURCES)
        @test -n $(XGETTEXT) || echo "xgettext is required for updating translations"
        $(AM_V_GEN) cd $(srcdir); XGETTEXT=$(XGETTEXT) PACKAGE_NAME="$(PACKAGE_NAME)" COPYRIGHT_HOLDERS="$(COPYRIGHT_HOLDERS)" COPYRIGHT_HOLDERS_SUBSTITUTION="$(COPYRIGHT_HOLDERS_SUBSTITUTION)" $(PYTHON) ../share/qt/extract_strings_qt.py $^

-translate: qt/bitcoinstrings.cpp $(QT_FORMS_UI) $(QT_FORMS_UI) $(BITCOIN_QT_CPP) $(BITCOIN_QT_H) $(BITCOIN_MM)
+translate: $(srcdir)/qt/bitcoinstrings.cpp $(QT_FORMS_UI) $(QT_FORMS_UI) $(BITCOIN_QT_CPP) $(BITCOIN_QT_H) $(BITCOIN_MM)
        @test -n $(LUPDATE) || echo "lupdate is required for updating translations"
-       $(AM_V_GEN) QT_SELECT=$(QT_SELECT) $(LUPDATE) $^ -locations relative -no-obsolete -ts qt/locale/bitcoin_en.ts
+       $(AM_V_GEN) QT_SELECT=$(QT_SELECT) $(LUPDATE) $^ -locations relative -no-obsolete -ts $(srcdir)/qt/locale/bitcoin_en.ts

 $(QT_QRC_LOCALE_CPP): $(QT_QRC_LOCALE) $(QT_QM)
        @test -f $(RCC)

Updated: bitcoin_en.ts was written to the build directory instead of the source directory, now fixed.

Also available at: https://github.com/laanwj/bitcoin/tree/2016_06_translate_out_of_tree

@theuni
Copy link
Member Author

theuni commented Jun 6, 2016

@luke-jr Whoa, that's great feedback! Thanks for the testing. I'm having a look at the "-dirty" issue.

@laanwj Thanks, I'll add that here.

@laanwj
Copy link
Member

laanwj commented Jun 9, 2016

Let's try to get this merged soon.
I can PR the make translate change separately if that's mroe convenient.

@laanwj laanwj added this to the 0.13.0 milestone Jun 9, 2016
@theuni
Copy link
Member Author

theuni commented Jun 9, 2016

@luke-jr I believe I've found the issue here. When you "chown -R root:root .", you're setting the git index to read-only. That makes "git diff" fail to update the index, which makes the diff-index fail.

For the sake of this PR, I'm ok with that not working correctly, since git is in a pretty bad state.

@laanwj
Copy link
Member

laanwj commented Jun 10, 2016

since git is in a pretty bad state

That sounds ominous. Time to switch to mercurial or bzr? :-)

@laanwj
Copy link
Member

laanwj commented Jun 10, 2016

"works for me" ACK d1a3d57

@laanwj laanwj merged commit d1a3d57 into bitcoin:master Jun 10, 2016
laanwj added a commit that referenced this pull request Jun 10, 2016
d1a3d57 bulid: fix "make translate" when out-of-tree (Cory Fields)
340012d build: add temporary fix for "bad magic number" error in out-of-tree builds (Cory Fields)
142ffc7 travis: use out-of-tree build (Cory Fields)
92e37a3 build: fix out-of-tree 'make deploy' for osx (Cory Fields)
ab95d5d build: a few ugly hacks to get the rpc tests working out-of-tree (Cory Fields)
fc4ad0c build: more out-of-tree fixups (Cory Fields)
0cb0f26 build: out-of-tree fixups (Cory Fields)
@theuni
Copy link
Member Author

theuni commented Jun 10, 2016

Haha. That was a half-complete thought as usual.

Should read: "I'm ok with that not working correctly, since if you're hitting this case, your git repo is already unreliable".

@theuni theuni deleted the out-of-tree-clean branch June 10, 2016 08:43
@jnewbery jnewbery mentioned this pull request Jan 31, 2017
codablock pushed a commit to codablock/dash that referenced this pull request Dec 22, 2017
d1a3d57 bulid: fix "make translate" when out-of-tree (Cory Fields)
340012d build: add temporary fix for "bad magic number" error in out-of-tree builds (Cory Fields)
142ffc7 travis: use out-of-tree build (Cory Fields)
92e37a3 build: fix out-of-tree 'make deploy' for osx (Cory Fields)
ab95d5d build: a few ugly hacks to get the rpc tests working out-of-tree (Cory Fields)
fc4ad0c build: more out-of-tree fixups (Cory Fields)
0cb0f26 build: out-of-tree fixups (Cory Fields)
andvgal pushed a commit to energicryptocurrency/gen2-energi that referenced this pull request Jan 6, 2019
d1a3d57 bulid: fix "make translate" when out-of-tree (Cory Fields)
340012d build: add temporary fix for "bad magic number" error in out-of-tree builds (Cory Fields)
142ffc7 travis: use out-of-tree build (Cory Fields)
92e37a3 build: fix out-of-tree 'make deploy' for osx (Cory Fields)
ab95d5d build: a few ugly hacks to get the rpc tests working out-of-tree (Cory Fields)
fc4ad0c build: more out-of-tree fixups (Cory Fields)
0cb0f26 build: out-of-tree fixups (Cory Fields)
zkbot added a commit to zcash/zcash that referenced this pull request Sep 25, 2020
Update LevelDB to upstream commit f545dfabf

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#7911
- bitcoin/bitcoin#7982
- bitcoin/bitcoin#8133
- bitcoin/bitcoin#8784
  - Only the missing changes.
- bitcoin/bitcoin#8826
- bitcoin/bitcoin#8613
- bitcoin/bitcoin#10544
- bitcoin/bitcoin#10633
  - Only the changes to files and code we have.
- bitcoin/bitcoin#10806
- bitcoin/bitcoin#10958
- bitcoin/bitcoin#12451
- bitcoin/bitcoin#13925
- bitcoin/bitcoin#15270

This upgrades LevelDB in the exact same commit progression as upstream, up to January 2019.
zkbot added a commit to zcash/zcash that referenced this pull request Dec 2, 2020
Backport migration from rpc-tests.sh to rpc-tests.py

Cherry-picked from the following upstream PRs:
- bitcoin/bitcoin#6567
- bitcoin/bitcoin#6523
- bitcoin/bitcoin#6616
- bitcoin/bitcoin#6788
  - Only the commit fixing `rpc-tests.py`
- bitcoin/bitcoin#6791
  - Only the fix to `qa/rpc-tests/README.md`
- bitcoin/bitcoin#6827
- bitcoin/bitcoin#6930
- bitcoin/bitcoin#6804
- bitcoin/bitcoin#7029
- bitcoin/bitcoin#7028
- bitcoin/bitcoin#7027
- bitcoin/bitcoin#7135
- bitcoin/bitcoin#7209
- bitcoin/bitcoin#7635
- bitcoin/bitcoin#7778
- bitcoin/bitcoin#7851
- bitcoin/bitcoin#7814
  - Only the changes to the new .py files in this PR.
- bitcoin/bitcoin#7971
- bitcoin/bitcoin#7972
- bitcoin/bitcoin#8056
  - Only the first commit.
- bitcoin/bitcoin#8098
- bitcoin/bitcoin#8104
- bitcoin/bitcoin#8133
  - Only the `rpc-tests.py` commit.
- bitcoin/bitcoin#8066
- bitcoin/bitcoin#8216
  - Only the last two commits.
- bitcoin/bitcoin#8254
- bitcoin/bitcoin#8400
- bitcoin/bitcoin#8482
  - Excluding the first commit (only affects RPC tests we don't have).
- bitcoin/bitcoin#8551
- bitcoin/bitcoin#8607
  - Only the pull-tester commit, for conflict removal.
- bitcoin/bitcoin#8625
- bitcoin/bitcoin#8713
- bitcoin/bitcoin#8750
- bitcoin/bitcoin#8789
- bitcoin/bitcoin#9098
- bitcoin/bitcoin#9276
  - Excluding the second commit (we don't have the changes it requires).
- bitcoin/bitcoin#9657
- bitcoin/bitcoin#9807
- bitcoin/bitcoin#9766
- bitcoin/bitcoin#9823
zkbot added a commit to zcash/zcash that referenced this pull request Dec 2, 2020
Backport migration from rpc-tests.sh to rpc-tests.py

Cherry-picked from the following upstream PRs:
- bitcoin/bitcoin#6567
- bitcoin/bitcoin#6523
- bitcoin/bitcoin#6616
- bitcoin/bitcoin#6788
  - Only the commit fixing `rpc-tests.py`
- bitcoin/bitcoin#6791
  - Only the fix to `qa/rpc-tests/README.md`
- bitcoin/bitcoin#6827
- bitcoin/bitcoin#6930
- bitcoin/bitcoin#6804
- bitcoin/bitcoin#7029
- bitcoin/bitcoin#7028
- bitcoin/bitcoin#7027
- bitcoin/bitcoin#7135
- bitcoin/bitcoin#7209
- bitcoin/bitcoin#7635
- bitcoin/bitcoin#7778
- bitcoin/bitcoin#7851
- bitcoin/bitcoin#7814
  - Only the changes to the new .py files in this PR.
- bitcoin/bitcoin#7971
- bitcoin/bitcoin#7972
- bitcoin/bitcoin#8056
  - Only the first commit.
- bitcoin/bitcoin#8098
- bitcoin/bitcoin#8104
- bitcoin/bitcoin#8133
  - Only the `rpc-tests.py` commit.
- bitcoin/bitcoin#8066
- bitcoin/bitcoin#8216
  - Only the last two commits.
- bitcoin/bitcoin#8254
- bitcoin/bitcoin#8400
- bitcoin/bitcoin#8482
  - Excluding the first commit (only affects RPC tests we don't have).
- bitcoin/bitcoin#8551
- bitcoin/bitcoin#8607
  - Only the pull-tester commit, for conflict removal.
- bitcoin/bitcoin#8625
- bitcoin/bitcoin#8713
- bitcoin/bitcoin#8750
- bitcoin/bitcoin#8789
- bitcoin/bitcoin#9098
- bitcoin/bitcoin#9276
  - Excluding the second commit (we don't have the changes it requires).
- bitcoin/bitcoin#9657
- bitcoin/bitcoin#9807
- bitcoin/bitcoin#9766
- bitcoin/bitcoin#9823
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants