From 836b436d1742de73cbe0ab692ae393e294db892c Mon Sep 17 00:00:00 2001 From: jmgomez Date: Mon, 28 Oct 2024 09:27:07 +0000 Subject: [PATCH 1/5] Tagged versions (i.e. #head) behaves like `any` except when matched against another tag --- src/nimblepkg/version.nim | 4 ++-- tests/tsat.nim | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/nimblepkg/version.nim b/src/nimblepkg/version.nim index 921a3c51..aa025b8e 100644 --- a/src/nimblepkg/version.nim +++ b/src/nimblepkg/version.nim @@ -141,8 +141,8 @@ proc withinRange*(ver: Version, ran: VersionRange): bool = return ver <= ran.ver of verEq: return ver == ran.ver - of verSpecial: - return ver == ran.spe + of verSpecial: # special version is always within range + return ver.isSpecial and ver == ran.spe or not ver.isSpecial of verIntersect, verTilde, verCaret: return withinRange(ver, ran.verILeft) and withinRange(ver, ran.verIRight) of verAny: diff --git a/tests/tsat.nim b/tests/tsat.nim index 13b8ec5a..2f13307d 100644 --- a/tests/tsat.nim +++ b/tests/tsat.nim @@ -237,4 +237,38 @@ suite "SAT solver": check pkgC.pkgName == "c" and pkgC.version == newVersion "0.1.0" check "random" in pkgVersionTable - removeDir(options.pkgCachePath) \ No newline at end of file + removeDir(options.pkgCachePath) + + test "should treat #head and tags as any version": + let pkgVersionTable = { + "a": PackageVersions(pkgName: "a", versions: @[ + PackageMinimalInfo(name: "a", version: newVersion "3.0", requires: @[ + (name:"b", ver: parseVersionRange "#head") + ], isRoot:true), + ]), + "b": PackageVersions(pkgName: "b", versions: @[ + PackageMinimalInfo(name: "b", version: newVersion "0.1.0") + ]) + }.toTable() + var graph = pkgVersionTable.toDepGraph() + let form = toFormular(graph) + var packages = initTable[string, Version]() + var output = "" + check solve(graph, form, packages, output) + + test "should not match other tags": + let pkgVersionTable = { + "a": PackageVersions(pkgName: "a", versions: @[ + PackageMinimalInfo(name: "a", version: newVersion "3.0", requires: @[ + (name:"b", ver: parseVersionRange "#head") + ], isRoot:true), + ]), + "b": PackageVersions(pkgName: "b", versions: @[ + PackageMinimalInfo(name: "b", version: newVersion "#someOtherTag") + ]) + }.toTable() + var graph = pkgVersionTable.toDepGraph() + let form = toFormular(graph) + var packages = initTable[string, Version]() + var output = "" + check not solve(graph, form, packages, output) \ No newline at end of file From 26f9c8609846a75331c84191ea364a0dce632542 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20M=20G=C3=B3mez?= Date: Mon, 28 Oct 2024 09:06:20 +0000 Subject: [PATCH 2/5] Updates changelog (#1276) * Updates changelog * Apply suggestions from code review --------- Co-authored-by: Andreas Rumpf --- changelog.markdown | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/changelog.markdown b/changelog.markdown index 6e9d7077..a4817caf 100644 --- a/changelog.markdown +++ b/changelog.markdown @@ -3,6 +3,26 @@ # Nimble changelog +## 0.16.2 + + - Adds a `requires` flag which allows to add extra packages to the dependency resolution. + - Zero to hero: nimble is able to function without `nim` in the path. + - The SAT solver is now the default solver. + +## 0.16.1 + + - Improves `nimDir`'s `nim` selection heuristic. + - Fixes a bug where the SAT cache downloaded packages in the wrong directory. + - Other fixes and improvements. + +## 0.16.0 + +- Implemented a new experimental SAT solver for dependency resolution. +- Implemented support for self-bootstrapping when no Nim is present. +- Added support for package entry points. +- Improved Nim version management. +- Other fixes and improvements. + ## 0.14.0 This is a major release containing four new features: From 91c6c16fe549d112bf3cc1f51d15a52d77bec9d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20M=20G=C3=B3mez?= Date: Mon, 28 Oct 2024 11:23:33 +0000 Subject: [PATCH 3/5] bumps `setup-nim-action` (#1280) * bumps `setup-nim-action` * moves to stable (devel is not supported by `setup-nim-action@v2`) --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8b25df3d..fcf442c9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,15 +15,15 @@ jobs: - macos-latest - ubuntu-latest nimversion: - - devel - # - stable + # - devel + - stable name: ${{ matrix.os }} - ${{ matrix.nimversion }} runs-on: ${{ matrix.os }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v4 - - uses: jiro4989/setup-nim-action@v1 + - uses: jiro4989/setup-nim-action@v2 with: nim-version: ${{ matrix.nimversion }} - run: nim --version From e1739b36851fa05f6955cc591f6e714f4187bb99 Mon Sep 17 00:00:00 2001 From: jmgomez Date: Mon, 28 Oct 2024 11:52:34 +0000 Subject: [PATCH 4/5] adds `displayUsingUnderspecifiedVersionWarning` --- src/nimble.nim | 11 +++++++++++ src/nimblepkg/version.nim | 3 +++ tests/tsat.nim | 1 + 3 files changed, 15 insertions(+) diff --git a/src/nimble.nim b/src/nimble.nim index 1b654497..cda5927e 100644 --- a/src/nimble.nim +++ b/src/nimble.nim @@ -61,6 +61,16 @@ proc displaySatisfiedMsg(solvedPkgs: seq[SolvedPackage], pkgToInstall: seq[(stri for req in pkg.requirements: displayInfo(pkgDepsAlreadySatisfiedMsg(req)) +proc displayUsingSpecialVersionWarning(solvedPkgs: seq[SolvedPackage], options: Options) = + var messages = newSeq[string]() + for pkg in solvedPkgs: + for req in pkg.requirements: + if req.ver.isSpecial: + messages.addUnique(&"Package {pkg.pkgName} lists an underspecified version of {req.name} ({req.ver})") + + for msg in messages: + displayWarning(msg) + proc addReverseDeps(solvedPkgs: seq[SolvedPackage], allPkgsInfo: seq[PackageInfo], options: Options) = for pkg in solvedPkgs: let solvedPkg = getPackageInfo(pkg.pkgName, allPkgsInfo, some pkg.version) @@ -116,6 +126,7 @@ proc processFreeDependenciesSAT(rootPkgInfo: PackageInfo, options: Options): Has var output = "" result = solvePackages(rootPkgInfo, pkgList, pkgsToInstall, options, output, solvedPkgs) displaySatisfiedMsg(solvedPkgs, pkgsToInstall, options) + displayUsingSpecialVersionWarning(solvedPkgs, options) var solved = solvedPkgs.len > 0 #A pgk can be solved and still dont return a set of PackageInfo for (name, ver) in pkgsToInstall: var versionRange = ver.toVersionRange diff --git a/src/nimblepkg/version.nim b/src/nimblepkg/version.nim index aa025b8e..d286daa5 100644 --- a/src/nimblepkg/version.nim +++ b/src/nimblepkg/version.nim @@ -65,6 +65,9 @@ proc initFromJson*(dst: var Version, jsonNode: JsonNode, jsonPath: var string) = proc isSpecial*(ver: Version): bool = return ($ver).len > 0 and ($ver)[0] == '#' +proc isSpecial*(verRange: VersionRange): bool = + return verRange.kind == verSpecial + proc `<`*(ver: Version, ver2: Version): bool = # Handling for special versions such as "#head" or "#branch". if ver.isSpecial or ver2.isSpecial: diff --git a/tests/tsat.nim b/tests/tsat.nim index 2f13307d..8f0323a9 100644 --- a/tests/tsat.nim +++ b/tests/tsat.nim @@ -255,6 +255,7 @@ suite "SAT solver": var packages = initTable[string, Version]() var output = "" check solve(graph, form, packages, output) + check packages.len == 2 test "should not match other tags": let pkgVersionTable = { From b03781748da157a046ac6755c45bc98397cab16a Mon Sep 17 00:00:00 2001 From: jmgomez Date: Mon, 28 Oct 2024 12:02:40 +0000 Subject: [PATCH 5/5] fixes ci compile error --- src/nimble.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nimble.nim b/src/nimble.nim index cda5927e..14b85727 100644 --- a/src/nimble.nim +++ b/src/nimble.nim @@ -66,7 +66,7 @@ proc displayUsingSpecialVersionWarning(solvedPkgs: seq[SolvedPackage], options: for pkg in solvedPkgs: for req in pkg.requirements: if req.ver.isSpecial: - messages.addUnique(&"Package {pkg.pkgName} lists an underspecified version of {req.name} ({req.ver})") + nimblesat.addUnique(messages, &"Package {pkg.pkgName} lists an underspecified version of {req.name} ({req.ver})") for msg in messages: displayWarning(msg)