Fixes version conflicts when building between special&non-special.
Refs #289. Aporia still cannot be installed. In addition, the myVersion vs. version should be refactored into version vs. specialVersion.
This commit is contained in:
parent
8453a4e2de
commit
d192de6511
7 changed files with 47 additions and 11 deletions
|
|
@ -296,12 +296,13 @@ proc processDeps(pkginfo: PackageInfo, options: Options): seq[string] =
|
||||||
# in the path.
|
# in the path.
|
||||||
var pkgsInPath: StringTableRef = newStringTable(modeCaseSensitive)
|
var pkgsInPath: StringTableRef = newStringTable(modeCaseSensitive)
|
||||||
for p in result:
|
for p in result:
|
||||||
let (name, version) = getNameVersion(p)
|
let pkgInfo = getPkgInfo(p, options)
|
||||||
if pkgsInPath.hasKey(name) and pkgsInPath[name] != version:
|
if pkgsInPath.hasKey(pkgInfo.name) and
|
||||||
|
pkgsInPath[pkgInfo.name] != pkgInfo.myVersion:
|
||||||
raise newException(NimbleError,
|
raise newException(NimbleError,
|
||||||
"Cannot satisfy the dependency on $1 $2 and $1 $3" %
|
"Cannot satisfy the dependency on $1 $2 and $1 $3" %
|
||||||
[name, version, pkgsInPath[name]])
|
[pkgInfo.name, pkgInfo.myVersion, pkgsInPath[pkgInfo.name]])
|
||||||
pkgsInPath[name] = version
|
pkgsInPath[pkgInfo.name] = pkgInfo.myVersion
|
||||||
|
|
||||||
# We add the reverse deps to the JSON file here because we don't want
|
# We add the reverse deps to the JSON file here because we don't want
|
||||||
# them added if the above errorenous condition occurs
|
# them added if the above errorenous condition occurs
|
||||||
|
|
|
||||||
|
|
@ -14,14 +14,17 @@ when not defined(nimscript):
|
||||||
BuildFailed* = object of NimbleError
|
BuildFailed* = object of NimbleError
|
||||||
|
|
||||||
PackageInfo* = object
|
PackageInfo* = object
|
||||||
mypath*: string ## The path of this .nimble file
|
myPath*: string ## The path of this .nimble file
|
||||||
|
## The version specified in the .nimble file.Assuming info is non-minimal,
|
||||||
|
## it will always be a non-special version such as '0.1.4'
|
||||||
|
myVersion*: string
|
||||||
isNimScript*: bool ## Determines if this pkg info was read from a nims file
|
isNimScript*: bool ## Determines if this pkg info was read from a nims file
|
||||||
isMinimal*: bool
|
isMinimal*: bool
|
||||||
isInstalled*: bool ## Determines if the pkg this info belongs to is installed
|
isInstalled*: bool ## Determines if the pkg this info belongs to is installed
|
||||||
postHooks*: HashSet[string] ## Useful to know so that Nimble doesn't execHook unnecessarily
|
postHooks*: HashSet[string] ## Useful to know so that Nimble doesn't execHook unnecessarily
|
||||||
preHooks*: HashSet[string]
|
preHooks*: HashSet[string]
|
||||||
name*: string
|
name*: string
|
||||||
version*: string
|
version*: string ## Either `myVersion` or a special version such as #head.
|
||||||
author*: string
|
author*: string
|
||||||
description*: string
|
description*: string
|
||||||
license*: string
|
license*: string
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,8 @@ type
|
||||||
url*: string
|
url*: string
|
||||||
|
|
||||||
proc initPackageInfo*(path: string): PackageInfo =
|
proc initPackageInfo*(path: string): PackageInfo =
|
||||||
result.mypath = path
|
result.myPath = path
|
||||||
|
result.myVersion = ""
|
||||||
result.preHooks.init()
|
result.preHooks.init()
|
||||||
result.postHooks.init()
|
result.postHooks.init()
|
||||||
# reasonable default:
|
# reasonable default:
|
||||||
|
|
|
||||||
|
|
@ -248,6 +248,8 @@ proc readPackageInfo(nf: NimbleFile, options: Options,
|
||||||
## times on the same ``nf`` shouldn't require re-evaluation of the Nimble
|
## times on the same ``nf`` shouldn't require re-evaluation of the Nimble
|
||||||
## file.
|
## file.
|
||||||
|
|
||||||
|
assert fileExists(nf)
|
||||||
|
|
||||||
# Check the cache.
|
# Check the cache.
|
||||||
if options.pkgInfoCache.hasKey(nf):
|
if options.pkgInfoCache.hasKey(nf):
|
||||||
return options.pkgInfoCache[nf]
|
return options.pkgInfoCache[nf]
|
||||||
|
|
@ -286,6 +288,7 @@ proc readPackageInfo(nf: NimbleFile, options: Options,
|
||||||
raise newException(NimbleError, msg)
|
raise newException(NimbleError, msg)
|
||||||
|
|
||||||
# Validate version ahead of time, we will be potentially overwriting it soon.
|
# Validate version ahead of time, we will be potentially overwriting it soon.
|
||||||
|
result.myVersion = result.version
|
||||||
validateVersion(result.version)
|
validateVersion(result.version)
|
||||||
|
|
||||||
# The package directory name may include a "special" version
|
# The package directory name may include a "special" version
|
||||||
|
|
@ -301,11 +304,11 @@ proc readPackageInfo(nf: NimbleFile, options: Options,
|
||||||
# Validate the rest of the package info last.
|
# Validate the rest of the package info last.
|
||||||
validatePackageInfo(result, options)
|
validatePackageInfo(result, options)
|
||||||
|
|
||||||
proc getPkgInfo*(dir: string, options: Options): PackageInfo =
|
proc getPkgInfoFromFile*(file: NimbleFile, options: Options): PackageInfo =
|
||||||
## Find the .nimble file in ``dir`` and parses it, returning a PackageInfo.
|
## Reads the specified .nimble file and returns its data as a PackageInfo
|
||||||
let nimbleFile = findNimbleFile(dir, true)
|
## object. Any validation errors are handled and displayed as warnings.
|
||||||
try:
|
try:
|
||||||
result = readPackageInfo(nimbleFile, options)
|
result = readPackageInfo(file, options)
|
||||||
except ValidationError:
|
except ValidationError:
|
||||||
let exc = (ref ValidationError)(getCurrentException())
|
let exc = (ref ValidationError)(getCurrentException())
|
||||||
if exc.warnAll:
|
if exc.warnAll:
|
||||||
|
|
@ -314,6 +317,11 @@ proc getPkgInfo*(dir: string, options: Options): PackageInfo =
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
proc getPkgInfo*(dir: string, options: Options): PackageInfo =
|
||||||
|
## Find the .nimble file in ``dir`` and parses it, returning a PackageInfo.
|
||||||
|
let nimbleFile = findNimbleFile(dir, true)
|
||||||
|
getPkgInfoFromFile(nimbleFile, options)
|
||||||
|
|
||||||
proc getInstalledPkgs*(libsDir: string, options: Options):
|
proc getInstalledPkgs*(libsDir: string, options: Options):
|
||||||
seq[tuple[pkginfo: PackageInfo, meta: MetaData]] =
|
seq[tuple[pkginfo: PackageInfo, meta: MetaData]] =
|
||||||
## Gets a list of installed packages.
|
## Gets a list of installed packages.
|
||||||
|
|
|
||||||
1
tests/issue289/issue289.nim
Normal file
1
tests/issue289/issue289.nim
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
echo 42
|
||||||
14
tests/issue289/issue289.nimble
Normal file
14
tests/issue289/issue289.nimble
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
# Package
|
||||||
|
|
||||||
|
version = "0.1.0"
|
||||||
|
author = "Dominik Picheta"
|
||||||
|
description = "Package reproducing issues depending on #head and concrete version of the same package."
|
||||||
|
license = "MIT"
|
||||||
|
|
||||||
|
bin = @["issue289"]
|
||||||
|
|
||||||
|
# Dependencies
|
||||||
|
|
||||||
|
requires "nim >= 0.15.3", "https://github.com/nimble-test/packagea.git 0.6.0"
|
||||||
|
requires "https://github.com/nimble-test/packagea.git#head"
|
||||||
|
|
||||||
|
|
@ -41,6 +41,14 @@ proc inLines(lines: seq[string], line: string): bool =
|
||||||
for i in lines:
|
for i in lines:
|
||||||
if line.normalize in i.normalize: return true
|
if line.normalize in i.normalize: return true
|
||||||
|
|
||||||
|
test "can build with #head and versioned package (#289)":
|
||||||
|
# Clear nimble dir.
|
||||||
|
removeDir(installDir)
|
||||||
|
createDir(installDir)
|
||||||
|
|
||||||
|
cd "issue289":
|
||||||
|
check execNimble(["install", "-y"]).exitCode == QuitSuccess
|
||||||
|
|
||||||
test "can validate package structure (#144)":
|
test "can validate package structure (#144)":
|
||||||
# Clear nimble dir.
|
# Clear nimble dir.
|
||||||
removeDir(installDir)
|
removeDir(installDir)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue