lol
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #324004 from codedownio/julia-withpackages-override-fix

julia.withPackages: fix for overrides not in a registry

authored by

Nick Cao and committed by
GitHub
c99ceeab 6fa3ecdc

+59 -23
+14 -1
pkgs/development/julia-modules/package-closure.nix
··· 42 42 43 43 resolveCode1_8 = '' 44 44 import Pkg.API: handle_package_input! 45 - import Pkg.Types: PRESERVE_NONE, project_deps_resolve!, registry_resolve!, stdlib_resolve!, ensure_resolved 45 + import Pkg.Types: PRESERVE_NONE, UUID, VersionSpec, project_deps_resolve!, registry_resolve!, stdlib_resolve!, ensure_resolved 46 46 import Pkg.Operations: _resolve, assert_can_add, update_package_add 47 + import TOML 47 48 48 49 foreach(handle_package_input!, pkgs) 49 50 ··· 54 55 for pkg in pkgs 55 56 if pkg.name in keys(overrides) 56 57 pkg.path = overrides[pkg.name] 58 + 59 + # Try to read the UUID from $(pkg.path)/Project.toml. If successful, put the package into ctx.env.project.deps. 60 + # This is necessary for the ensure_resolved call below to succeed, and will allow us to use an override even 61 + # if it does not appear in the registry. 62 + # See https://github.com/NixOS/nixpkgs/issues/279853 63 + project_toml = joinpath(pkg.path, "Project.toml") 64 + if isfile(project_toml) 65 + toml_data = TOML.parsefile(project_toml) 66 + if haskey(toml_data, "uuid") 67 + ctx.env.project.deps[pkg.name] = UUID(toml_data["uuid"]) 68 + end 69 + end 57 70 end 58 71 end 59 72
+2 -1
pkgs/development/julia-modules/python/minimal_registry.py
··· 56 56 # Write nothing in Compat.toml, because we've already resolved everything 57 57 with open(out_path / path / Path("Deps.toml"), "w") as f: 58 58 f.write('["%s"]\n' % info["version"]) 59 - toml.dump(project["deps"], f) 59 + if "deps" in project: 60 + toml.dump(project["deps"], f) 60 61 with open(out_path / path / Path("Versions.toml"), "w") as f: 61 62 f.write('["%s"]\n' % info["version"]) 62 63 f.write('git-tree-sha1 = "%s"\n' % info["treehash"])
+43 -21
pkgs/development/julia-modules/tests/julia-top-n/app/Main.hs
··· 5 5 {-# LANGUAGE LambdaCase #-} 6 6 {-# LANGUAGE OverloadedStrings #-} 7 7 {-# LANGUAGE QuasiQuotes #-} 8 + {-# LANGUAGE RankNTypes #-} 8 9 {-# LANGUAGE RecordWildCards #-} 9 10 {-# LANGUAGE ScopedTypeVariables #-} 10 11 {-# LANGUAGE ViewPatterns #-} ··· 19 20 import qualified Data.ByteString.Lazy.Char8 as BL8 20 21 import qualified Data.List as L 21 22 import Data.String.Interpolate 22 - import Data.Text as T 23 + import Data.Text as T hiding (count) 23 24 import qualified Data.Vector as V 24 25 import qualified Data.Yaml as Yaml 25 26 import GHC.Generics ··· 60 61 main :: IO () 61 62 main = do 62 63 clo <- parseCommandLineArgs argsParser (return ()) 63 - let Args {..} = optUserOptions clo 64 + let args@(Args {..}) = optUserOptions clo 64 65 65 66 namesAndCounts :: [NameAndCount] <- Yaml.decodeFileEither countFilePath >>= \case 66 67 Left err -> throwIO $ userError ("Couldn't decode names and counts YAML file: " <> show err) 67 68 Right x -> pure x 68 69 69 - runSandwichWithCommandLineArgs' defaultOptions argsParser $ 70 + runSandwichWithCommandLineArgs' defaultOptions argsParser $ do 71 + miscTests args 72 + 70 73 describe ("Building environments for top " <> show topN <> " Julia packages") $ 71 74 parallelN parallelism $ 72 75 forM_ (L.take topN namesAndCounts) $ \(NameAndCount {..}) -> 73 - introduce' (defaultNodeOptions { nodeOptionsVisibilityThreshold = 0 }) (T.unpack name) julia (newMVar Nothing) (const $ return ()) $ do 74 - it "Builds" $ do 75 - let cp = proc "nix" ["build", "--impure", "--no-link", "--json", "--expr" 76 - , [i|with import ../../../../. {}; #{juliaAttr}.withPackages ["#{name}"]|] 77 - ] 78 - output <- readCreateProcessWithLogging cp "" 79 - juliaPath <- case A.eitherDecode (BL8.pack output) of 80 - Right (A.Array ((V.!? 0) -> Just (A.Object (aesonLookup "outputs" -> Just (A.Object (aesonLookup "out" -> Just (A.String t))))))) -> pure (JuliaPath ((T.unpack t) </> "bin" </> "julia")) 81 - x -> expectationFailure ("Couldn't parse output: " <> show x) 76 + testExpr args name [i|#{juliaAttr}.withPackages ["#{name}"]|] 82 77 83 - getContext julia >>= flip modifyMVar_ (const $ return (Just juliaPath)) 78 + miscTests :: Args -> SpecFree ctx IO () 79 + miscTests args@(Args {..}) = describe "Misc tests" $ do 80 + describe "works for a package outside the General registry" $ do 81 + testExpr args "HelloWorld" [iii|(#{juliaAttr}.withPackages.override { 82 + packageOverrides = { 83 + "HelloWorld" = pkgs.fetchFromGitHub { 84 + owner = "codedownio"; 85 + repo = "HelloWorld.jl"; 86 + rev = "9b41c55df76eb87830dd3bd0b5601ee2582a37c6"; 87 + sha256 = "sha256-G+xpMRb0RopW/xWA8KCFF/S8wuHTQbpj0qwm9CihfSc="; 88 + }; 89 + }; 90 + }) [ "HelloWorld" ]|] 84 91 85 - it "Uses" $ do 86 - getContext julia >>= readMVar >>= \case 87 - Nothing -> expectationFailure "Build step failed." 88 - Just (JuliaPath juliaPath) -> do 89 - let cp = proc juliaPath ["-e", "using " <> T.unpack name] 90 - createProcessWithLogging cp >>= waitForProcess >>= (`shouldBe` ExitSuccess) 92 + -- * Low-level 91 93 92 - aesonLookup :: Text -> HM.KeyMap v -> Maybe v 93 - aesonLookup = HM.lookup . A.fromText 94 + testExpr :: Args -> Text -> String -> SpecFree ctx IO () 95 + testExpr _args name expr = do 96 + introduce' (defaultNodeOptions { nodeOptionsVisibilityThreshold = 0 }) (T.unpack name) julia (newMVar Nothing) (const $ return ()) $ do 97 + it "Builds" $ do 98 + let cp = proc "nix" ["build", "--impure", "--no-link", "--json", "--expr", [i|with import ../../../../. {}; #{expr}|]] 99 + output <- readCreateProcessWithLogging cp "" 100 + juliaPath <- case A.eitherDecode (BL8.pack output) of 101 + Right (A.Array ((V.!? 0) -> Just (A.Object (aesonLookup "outputs" -> Just (A.Object (aesonLookup "out" -> Just (A.String t))))))) -> pure (JuliaPath ((T.unpack t) </> "bin" </> "julia")) 102 + x -> expectationFailure ("Couldn't parse output: " <> show x) 103 + 104 + getContext julia >>= flip modifyMVar_ (const $ return (Just juliaPath)) 105 + 106 + it "Uses" $ do 107 + getContext julia >>= readMVar >>= \case 108 + Nothing -> expectationFailure "Build step failed." 109 + Just (JuliaPath juliaPath) -> do 110 + let cp = proc juliaPath ["-e", "using " <> T.unpack name] 111 + createProcessWithLogging cp >>= waitForProcess >>= (`shouldBe` ExitSuccess) 112 + 113 + where 114 + aesonLookup :: Text -> HM.KeyMap v -> Maybe v 115 + aesonLookup = HM.lookup . A.fromText