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.
|
||||
var pkgsInPath: StringTableRef = newStringTable(modeCaseSensitive)
|
||||
for p in result:
|
||||
let (name, version) = getNameVersion(p)
|
||||
if pkgsInPath.hasKey(name) and pkgsInPath[name] != version:
|
||||
let pkgInfo = getPkgInfo(p, options)
|
||||
if pkgsInPath.hasKey(pkgInfo.name) and
|
||||
pkgsInPath[pkgInfo.name] != pkgInfo.myVersion:
|
||||
raise newException(NimbleError,
|
||||
"Cannot satisfy the dependency on $1 $2 and $1 $3" %
|
||||
[name, version, pkgsInPath[name]])
|
||||
pkgsInPath[name] = version
|
||||
[pkgInfo.name, pkgInfo.myVersion, pkgsInPath[pkgInfo.name]])
|
||||
pkgsInPath[pkgInfo.name] = pkgInfo.myVersion
|
||||
|
||||
# We add the reverse deps to the JSON file here because we don't want
|
||||
# them added if the above errorenous condition occurs
|
||||
|
|
|
|||
|
|
@ -14,14 +14,17 @@ when not defined(nimscript):
|
|||
BuildFailed* = object of NimbleError
|
||||
|
||||
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
|
||||
isMinimal*: bool
|
||||
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
|
||||
preHooks*: HashSet[string]
|
||||
name*: string
|
||||
version*: string
|
||||
version*: string ## Either `myVersion` or a special version such as #head.
|
||||
author*: string
|
||||
description*: string
|
||||
license*: string
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ type
|
|||
url*: string
|
||||
|
||||
proc initPackageInfo*(path: string): PackageInfo =
|
||||
result.mypath = path
|
||||
result.myPath = path
|
||||
result.myVersion = ""
|
||||
result.preHooks.init()
|
||||
result.postHooks.init()
|
||||
# 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
|
||||
## file.
|
||||
|
||||
assert fileExists(nf)
|
||||
|
||||
# Check the cache.
|
||||
if options.pkgInfoCache.hasKey(nf):
|
||||
return options.pkgInfoCache[nf]
|
||||
|
|
@ -286,6 +288,7 @@ proc readPackageInfo(nf: NimbleFile, options: Options,
|
|||
raise newException(NimbleError, msg)
|
||||
|
||||
# Validate version ahead of time, we will be potentially overwriting it soon.
|
||||
result.myVersion = result.version
|
||||
validateVersion(result.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.
|
||||
validatePackageInfo(result, options)
|
||||
|
||||
proc getPkgInfo*(dir: string, options: Options): PackageInfo =
|
||||
## Find the .nimble file in ``dir`` and parses it, returning a PackageInfo.
|
||||
let nimbleFile = findNimbleFile(dir, true)
|
||||
proc getPkgInfoFromFile*(file: NimbleFile, options: Options): PackageInfo =
|
||||
## Reads the specified .nimble file and returns its data as a PackageInfo
|
||||
## object. Any validation errors are handled and displayed as warnings.
|
||||
try:
|
||||
result = readPackageInfo(nimbleFile, options)
|
||||
result = readPackageInfo(file, options)
|
||||
except ValidationError:
|
||||
let exc = (ref ValidationError)(getCurrentException())
|
||||
if exc.warnAll:
|
||||
|
|
@ -314,6 +317,11 @@ proc getPkgInfo*(dir: string, options: Options): PackageInfo =
|
|||
else:
|
||||
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):
|
||||
seq[tuple[pkginfo: PackageInfo, meta: MetaData]] =
|
||||
## Gets a list of installed packages.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue