mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-21 10:01:54 +00:00
change the strategy for building the test environment
it's not clear to me if this is conceptually better or worse than what it replaces but it is about 25% faster
This commit is contained in:
parent
f5de5fc127
commit
e4505cd7b8
@ -13,9 +13,12 @@ in
|
||||
, pythonVersion ? "python37" # a string chosing the python derivation from
|
||||
# nixpkgs to target
|
||||
|
||||
, extras ? [] # a list of strings identifying tahoe-lafs extras, the
|
||||
# dependencies of which the resulting package will also depend
|
||||
# on
|
||||
, extras ? [ "tor" "i2p" ] # a list of strings identifying tahoe-lafs extras,
|
||||
# the dependencies of which the resulting package
|
||||
# will also depend on. Include all of the runtime
|
||||
# extras by default because the incremental cost of
|
||||
# including them is a lot smaller than the cost of
|
||||
# re-building the whole thing to add them.
|
||||
|
||||
, mach-nix ? import sources.mach-nix { # the mach-nix package to use to build
|
||||
# the tahoe-lafs package
|
||||
|
61
tests.nix
61
tests.nix
@ -12,17 +12,62 @@ in
|
||||
}
|
||||
}@args:
|
||||
let
|
||||
# Get the package with all of its test requirements.
|
||||
tahoe-lafs = import ./. (args // { extras = [ "test" ]; });
|
||||
# We would like to know the test requirements but mach-nix does not directly
|
||||
# expose this information to us. However, it is perfectly capable of
|
||||
# determining it if we ask right... This is probably not meant to be a
|
||||
# public mach-nix API but we pinned mach-nix so we can deal with mach-nix
|
||||
# upgrade breakage in our own time.
|
||||
mach-lib = import "${sources.mach-nix}/mach_nix/nix/lib.nix" {
|
||||
inherit pkgs;
|
||||
lib = pkgs.lib;
|
||||
};
|
||||
tests_require = (mach-lib.extract "python37" ./. "extras_require" ).extras_require.test;
|
||||
|
||||
# Put it into a Python environment.
|
||||
# Get the Tahoe-LAFS package itself. This does not include test
|
||||
# requirements and we don't ask for test requirements so that we can just
|
||||
# re-use the normal package if it is already built.
|
||||
tahoe-lafs = import ./. args;
|
||||
|
||||
# If we want to get tahoe-lafs into a Python environment with a bunch of
|
||||
# *other* Python modules and let them interact in the usual way then we have
|
||||
# to ask mach-nix for tahoe-lafs and those other Python modules in the same
|
||||
# way - i.e., using `requirements`. The other tempting mechanism,
|
||||
# `packagesExtra`, inserts an extra layer of Python environment and prevents
|
||||
# normal interaction between Python modules (as well as usually producing
|
||||
# file collisions in the packages that are both runtime and test
|
||||
# dependencies). To get the tahoe-lafs we just built into the environment,
|
||||
# put it into nixpkgs using an overlay and tell mach-nix to get tahoe-lafs
|
||||
# from nixpkgs.
|
||||
overridesPre = [(self: super: { inherit tahoe-lafs; })];
|
||||
providers = tahoe-lafs.meta.mach-nix.providers // { tahoe-lafs = "nixpkgs"; };
|
||||
|
||||
# Make the Python environment in which we can run the tests.
|
||||
python-env = mach-nix.mkPython {
|
||||
inherit (tahoe-lafs.meta.mach-nix) providers _;
|
||||
packagesExtra = [ tahoe-lafs ];
|
||||
# Get the packaging fixes we already know we need from putting together
|
||||
# the runtime package.
|
||||
inherit (tahoe-lafs.meta.mach-nix) _;
|
||||
# Share the runtime package's provider configuration - combined with our
|
||||
# own that causes the right tahoe-lafs to be picked up.
|
||||
inherit providers overridesPre;
|
||||
requirements = ''
|
||||
# txi2p-tahoe is another dependency with an environment marker that
|
||||
# mach-nix doesn't automatically pick up.
|
||||
txi2p-tahoe
|
||||
# Here we pull in the Tahoe-LAFS package itself.
|
||||
tahoe-lafs
|
||||
|
||||
# Unfortunately mach-nix misses all of the Python dependencies of the
|
||||
# tahoe-lafs satisfied from nixpkgs. Drag them in here. This gives a
|
||||
# bit of a pyrrhic flavor to the whole endeavor but maybe mach-nix will
|
||||
# fix this soon.
|
||||
#
|
||||
# https://github.com/DavHau/mach-nix/issues/123
|
||||
# https://github.com/DavHau/mach-nix/pull/386
|
||||
${tahoe-lafs.requirements}
|
||||
|
||||
# And then all of the test-only dependencies.
|
||||
${builtins.concatStringsSep "\n" tests_require}
|
||||
|
||||
# txi2p-tahoe is another dependency with an environment marker that
|
||||
# mach-nix doesn't automatically pick up.
|
||||
txi2p-tahoe
|
||||
'';
|
||||
};
|
||||
in
|
||||
|
Loading…
x
Reference in New Issue
Block a user