remove "bin/tahoe" and fancy "@" runner support #2735
Labels
No Label
0.2.0
0.3.0
0.4.0
0.5.0
0.5.1
0.6.0
0.6.1
0.7.0
0.8.0
0.9.0
1.0.0
1.1.0
1.10.0
1.10.1
1.10.2
1.10a2
1.11.0
1.12.0
1.12.1
1.13.0
1.14.0
1.15.0
1.15.1
1.2.0
1.3.0
1.4.1
1.5.0
1.6.0
1.6.1
1.7.0
1.7.1
1.7β
1.8.0
1.8.1
1.8.2
1.8.3
1.8β
1.9.0
1.9.0-s3branch
1.9.0a1
1.9.0a2
1.9.0b1
1.9.1
1.9.2
1.9.2a1
LeastAuthority.com automation
blocker
cannot reproduce
cloud-branch
code
code-dirnodes
code-encoding
code-frontend
code-frontend-cli
code-frontend-ftp-sftp
code-frontend-magic-folder
code-frontend-web
code-mutable
code-network
code-nodeadmin
code-peerselection
code-storage
contrib
critical
defect
dev-infrastructure
documentation
duplicate
enhancement
fixed
invalid
major
minor
n/a
normal
operational
packaging
somebody else's problem
supercritical
task
trivial
unknown
was already fixed
website
wontfix
worksforme
No Milestone
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Reference: tahoe-lafs/trac-2024-07-25#2735
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
There And Back Again: Climbing The Complexity Mountain (and Coming Back Down The Other Side)
A long long time ago, one of the first bits of node-management code we added to the Tahoe tree was a launcher script which set PYTHONPATH (to the source tree), then ran
twistd
to load a tahoe node from a .tac file (which daemonized into the background).Later (b75276a in Sep-2007), when we were figuring out dependency management, we ended up writing a bespoke implementation of virtualenv (before virtualenv was a thing). This was a scheme where everything we needed (except tahoe itself) was installed into a
support/
directory, and the launcher script's $PYTHONPATH pointed into bothsupport/
and the source tree'ssrc/
directory (for tahoe). Because thetwistd
binary had to come fromsupport/bin/
, the launcher script had to set $PATH too.This launcher script was installed as
bin/tahoe
at the top of the source tree, so the build process was likepython setup.py build
and thenbin/tahoe --version
. Getting the shbang line right hard, as was making sure the file had a windows ".exe" suffix when appropriate, so ([083795d] in Jan-2009)bin/tahoe
was generated from a template, instead of being checked in like a regular file, which introduced a newmake_executable
command for setup.py.About that same time (b77c89a in Jan-2009), some unit tests appeared, which had complicated checks to make sure that $PATH contained the expected things, and that we weren't executing
tahoe
from anywhere else, etc. The unit tests were made more challenging by the fork-and-exec that occurred insidetwistd
, which also escapes control of the code-coverage tracing function. To allow theexec()
to locate twistd, both $PATH and $PYTHONPATH must be inherited by all child processes, so by this point the command to run the tahoe test suite had blossomed from a simpletrial allmydata
to a complex shell script.The pinnacle of complexity was achieved ([3798d99] in Jan-2011) when the
tahoe
executable itself absorbed responsibility for running the test suite, orcoverage
, orflogtool
, orpython
, or other commands that might need $PATH/$PYTHONPATH set to fully immerse oneself in the Tahoe lifestyle.python bin/tahoe debug repl
was just likepython
but different.python bin/tahoe @python -3 tahoe --version
let you put extra python arguments into your tahoe.python bin/tahoe @coverage run @tahoe debug trial allmydata
became a thing.It's All Downhill From Here
Fortunately, by that time (ac3b26ec in Oct-2010), we had already stopped shelling out to a
twistd
executable: instead, we imported the twistd library and invoked its functionality directly. This retains thefork()
, but removes theexec()
. Still later ([87a6894] in May-2012) we stopped using the contents of .tac files to load the tahoe node.It's time to continue the trend towards simplicity. I believe we no longer need anything which manipulates $PATH or $PYTHONPATH, and can instead rely upon a fully-installed tahoe+dependencies (either installed to the system "for reals", or in a virtualenv). The one entry point shall be a bare "tahoe" installed as a setup.py "entrypoint", and looked up by the shell on $PATH like any other command.
trial allmydata
, perhaps fronted bytox
(or run undercoverage
), shall be the one test-running command.pip install .
(perhaps with--editable
) shall be the one install-from-source-tree command.Simplify! Simplify! Simplify!
To that end, I'd like to delete the following:
bin/tahoe
andsetup.py make_executable
scripts.debug.repl
,trial
,flogtool
, and all the "@" stufftest_runner.BinTahoe
test_runner.RunNode
(although maybe
test_runner.BinTahoe.test_unicode_arguments_and_output
, which makes sure that unicode values in argv get delivered to the tahoe code correctly, should be retained in some form that doesn't require so much complexity in the entrypoint script)We need to keep exercising the
tahoe start
functionality in unit tests. This is tricky becausetwistd
, even as a library, terminates the calling process, so we need afork()
in the test code. But I think we can write a narrow test that doesn't requiretahoe
to be a general-purpose binary launcher.Daira gave me a braindump: #565 explains what
test_unicode_arguments_and_output
is testing. Basically the setuptools entrypoint wrapper .exe (on windows) doesn't handle sys.argv correctly (it irretrievably mangles non-ascii characters), and the tahoe workaround is to make a .pyscript wrapper instead (adding it to the windows registry as an executable file type). The test asserts that this new-and-improved wrapper is able to receive a non-ascii argument (by looking at the "unknown command" error it emits, which should echo the argument that was passed in).The long-term fix for #565 is to get setuptools to use a better wrapper. Then the setuptools-created entry point (venv/bin/tahoe for unix, venv/bin/tahoe.exe for windows) will behave correctly.
So: do we still need this test? Probably yes. This test should still execute the wrapper, but the actual pathname of the wrapper will be unusual on windows while our workaround is in place (
tahoe.pyscript
instead oftahoe
ortahoe.exe
).Is this the only place in the test suite where we want to execute a child process? (testing the launcher requires
os.fork
, but maybe notos.exec
, and I'm hoping we can get rid ofos.exec
calls)In 8d9afdc/trunk:
Some updates:
bin/tahoe
andsetup.py make_executable
in 1.11 ([0f3ce7a] 15-Mar-2016)debug trial
anddebug repl
in [8d9afdc], and that change will appear in 1.12test_runner
still hasBinTahoe
andRunNode
, and I'm not planning on doing anything with them for 1.12Some updates:
allmydata/windows/fixups.py
: receiving such values in argv and writing such values to stdout and stderr. This very directly tests the behavior thatBinTahoe.test_unicode_arguments_and_output
is also meant to test - but without gettingallmydata.scripts.runner
involved.BinTahoe.test_unicode_arguments_and_output
so that it still tests argv/output functionality conferred uponallmydata.scripts.runner
byallmydata.windows.fixups
. I thinkBinTahoe.test_unicode_arguments_and_output
is now pretty fine to keep.RunNode
still exists but it seems to have been cleaned up a lot since this ticket was filed. It still doesn't strike me as uniformly fantastic but neither does it seem like a substantial liability.So we may be zeroing in on being able to consider this ticket resolved.