Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
genotrance committed Mar 8, 2018
2 parents 7adfd7b + 75b7a21 commit e9a8850
Show file tree
Hide file tree
Showing 10 changed files with 178 additions and 57 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ language: c

install:
- |
wget https://nim-lang.org/download/nim-0.17.0.tar.xz
tar -xf nim-0.17.0.tar.xz
cd nim-0.17.0
wget https://nim-lang.org/download/nim-0.17.2.tar.xz
tar -xf nim-0.17.2.tar.xz
cd nim-0.17.2
sh build.sh
cd ..
before_script:
- set -e
- set -x
- export PATH=`pwd`/nim-0.17.0/bin:$PATH
- export PATH=`pwd`/nim-0.17.2/bin:$PATH

script:
- cd tests
Expand Down
32 changes: 32 additions & 0 deletions changelog.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,38 @@

# Nimble changelog

## 0.8.10 - 23/02/2018

The first release of 2018! Another fairly big release containing 40 commits.
This release fixes many
issues, with most being fixed by our brilliant contributors. Thanks a lot
everyone!

One big new feature is the new support for multiple Nimble packages in a single
Git/Hg repository. You can now specify ``?subdir=<dir>`` at the end of your
repo's URL and Nimble will know to look in ``<dir>`` for your package.

* **Implemented support for multi-package repos.** See
[#421](https://github.com/nim-lang/nimble/issues/421) for the relevant issue.
* **Better error message when the user has an outdated stdlib version that confuses Nimble**
* **The validity of a Nimble package can now be checked using the new ``check`` command**
* Nimble no longer silently ignores an erroneous '@' in for example
``nimble install compiler@``.
* Issues with the ``nimble path`` command have been fixed.
* The ``nimble publish`` command has been improved and stabilised.
* Messages for the ``NIM_LIB_PREFIX`` env var have been improved.
* ``before install`` is now called when packages are installed by their name.
See [#280](https://github.com/nim-lang/nimble/issues/280).
* Fixed issue with ``nimble init``. See [#446](https://github.com/nim-lang/nimble/issues/446).
* Nimble now rejects [reserved names on Windows](https://github.com/nim-lang/nimble/commit/74856a87084b73451254555b2c20ad932cf84270).
* The ``NIMBLE_DIR`` environment variable is now supported, in addition to the
command line flag and config setting.
* The ``init`` command has been improved significantly.

----

Full changelog: https://github.com/nim-lang/nimble/compare/v0.8.8...v0.8.10

## 0.8.8 - 03/09/2017

This is a relatively big release containing 57 commits, with multiple new
Expand Down
20 changes: 18 additions & 2 deletions readme.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,17 @@ the current working directory. This can be useful for developers who are testing
locally their ``.nimble`` files before submitting them to the official package
list. See the [Creating Packages](#creating-packages) section for more info on this.

A URL to a repository can also be specified, Nimble will automatically detect
the type of the repository that the url points to and install it.
#### Package URLs

A valid URL to a Git or Merurial repository can also be specified, Nimble will
automatically detect the type of the repository that the url points to and
install it.

For repositories containing the Nimble package in a subdirectory, you can
instruct Nimble about the location of your package using the ``?subdir=<path>``
query parameter. For example:

$ nimble install https://github.com/nimble-test/multi?subdir=alpha

### nimble develop

Expand All @@ -206,6 +215,9 @@ current working directory.
The ``jester`` package will be cloned into ``./jester`` and it will be linked
to your installation directory.

Just as with the ``install`` command, a package URL may also be specified
instead of a name.

### nimble uninstall

The ``uninstall`` command will remove an installed package. Attempting to remove
Expand Down Expand Up @@ -869,6 +881,10 @@ flag to the file ```src/nimble.nim.cfg```.
After that, you can run ```src/nimble install``` and overwrite the existing
installation.

* ``Could not download: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure``

If you are on macOS, you need to set and export the ```DYLD_LIBRARY_PATH``` environment variable to the directory where your OpenSSL libraries are. For example, if you use OpenSSL, you have to set ```export DYLD_LIBRARY_PATH=/usr/local/opt/openssl/lib``` in your ```$HOME/.bashrc``` file.

* ``Error: ambiguous identifier: 'version' --use nimscriptapi.version or system.version``

Make sure that you are running at least version 0.16.0 of Nim (or the latest nightly).
Expand Down
25 changes: 15 additions & 10 deletions src/nimble.nim
Original file line number Diff line number Diff line change
Expand Up @@ -434,13 +434,16 @@ proc installFromDir(dir: string, requestedVer: VersionRange, options: Options,
Success, HighPriority)

proc getDownloadInfo*(pv: PkgTuple, options: Options,
doPrompt: bool): (DownloadMethod, string) =
doPrompt: bool): (DownloadMethod, string,
Table[string, string]) =
if pv.name.isURL:
return (checkUrlType(pv.name), pv.name)
let (url, metadata) = getUrlData(pv.name)
return (checkUrlType(url), url, metadata)
else:
var pkg: Package
if getPackage(pv.name, options, pkg):
return (pkg.downloadMethod.getDownloadMethod(), pkg.url)
let (url, metadata) = getUrlData(pkg.url)
return (pkg.downloadMethod.getDownloadMethod(), url, metadata)
else:
# If package is not found give the user a chance to refresh
# package.json
Expand All @@ -464,9 +467,10 @@ proc install(packages: seq[PkgTuple],
else:
# Install each package.
for pv in packages:
let (meth, url) = getDownloadInfo(pv, options, doPrompt)
let (meth, url, metadata) = getDownloadInfo(pv, options, doPrompt)
let subdir = metadata.getOrDefault("subdir")
let (downloadDir, downloadVersion) =
downloadPkg(url, pv.ver, meth, options)
downloadPkg(url, pv.ver, meth, subdir, options)
try:
# Run pre-install hook in download directory now that package is downloaded
cd downloadDir:
Expand Down Expand Up @@ -625,7 +629,7 @@ proc listPaths(options: Options) =
var installed: seq[VersionAndPath] = @[]
# There may be several, list all available ones and sort by version.
for kind, path in walkDir(options.getPkgsDir):
if kind != pcDir or not path.startsWith(options.getPkgsDir / name):
if kind != pcDir or not path.startsWith(options.getPkgsDir / name & "-"):
continue

var nimbleFile = findNimbleFile(path, false)
Expand All @@ -634,7 +638,7 @@ proc listPaths(options: Options) =
var v: VersionAndPath
v.version = newVersion(pkgInfo.specialVersion)
v.path = pkgInfo.getRealDir()
installed = @[v]
installed.add(v)
else:
display("Warning:", "No .nimble file found for " & path, Warning,
MediumPriority)
Expand Down Expand Up @@ -1005,9 +1009,10 @@ proc develop(options: Options) =
let hint = "Remove the directory, or run this command somewhere else."
raiseNimbleError(msg, hint)

let (meth, url) = getDownloadInfo(pv, options, true)
discard downloadPkg(url, pv.ver, meth, options, downloadDir)
developFromDir(downloadDir, options)
let (meth, url, metadata) = getDownloadInfo(pv, options, true)
let subdir = metadata.getOrDefault("subdir")
discard downloadPkg(url, pv.ver, meth, subdir, options, downloadDir)
developFromDir(downloadDir / subdir, options)

proc test(options: Options) =
## Executes all tests.
Expand Down
2 changes: 1 addition & 1 deletion src/nimblepkg/common.nim
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ when not defined(nimscript):
return (error, hint)

const
nimbleVersion* = "0.8.8"
nimbleVersion* = "0.8.10"
59 changes: 36 additions & 23 deletions src/nimblepkg/download.nim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) Dominik Picheta. All rights reserved.
# BSD License. Look at license.txt for more info.

import parseutils, os, osproc, strutils, tables, pegs
import parseutils, os, osproc, strutils, tables, pegs, uri

import packageinfo, packageparser, version, tools, common, options, cli

Expand Down Expand Up @@ -132,13 +132,24 @@ proc checkUrlType*(url: string): DownloadMethod =
elif doCmdEx("hg identify " & url).exitCode == QuitSuccess:
return DownloadMethod.hg
else:
raise newException(NimbleError, "Unable to identify url.")
raise newException(NimbleError, "Unable to identify url: " & url)

proc getUrlData*(url: string): (string, Table[string, string]) =
var uri = parseUri(url)
# TODO: use uri.parseQuery once it lands... this code is quick and dirty.
var subdir = ""
if uri.query.startsWith("subdir="):
subdir = uri.query[7 .. ^1]

uri.query = ""
return ($uri, {"subdir": subdir}.toTable())

proc isURL*(name: string): bool =
name.startsWith(peg" @'://' ")

proc doDownload*(url: string, downloadDir: string, verRange: VersionRange,
downMethod: DownloadMethod, options: Options): Version =
proc doDownload(url: string, downloadDir: string, verRange: VersionRange,
downMethod: DownloadMethod,
options: Options): Version =
## Downloads the repository specified by ``url`` using the specified download
## method.
##
Expand All @@ -159,16 +170,6 @@ proc doDownload*(url: string, downloadDir: string, verRange: VersionRange,
# Result should already be set to #head here.
assert(not result.isNil)

proc verifyClone() =
## Makes sure that the downloaded package's version satisfies the requested
## version range.
let pkginfo = getPkgInfo(downloadDir, options)
if pkginfo.version.newVersion notin verRange:
raise newException(NimbleError,
"Downloaded package's version does not satisfy requested version " &
"range: wanted $1 got $2." %
[$verRange, $pkginfo.version])

removeDir(downloadDir)
if verRange.kind == verSpecial:
# We want a specific commit/branch/tag here.
Expand Down Expand Up @@ -197,8 +198,6 @@ proc doDownload*(url: string, downloadDir: string, verRange: VersionRange,
else:
# If no commits have been tagged on the repo we just clone HEAD.
doClone(downMethod, url, downloadDir) # Grab HEAD.

verifyClone()
of DownloadMethod.hg:
doClone(downMethod, url, downloadDir)
result = getHeadName(downMethod)
Expand All @@ -210,19 +209,18 @@ proc doDownload*(url: string, downloadDir: string, verRange: VersionRange,
priority = MediumPriority)
doCheckout(downMethod, downloadDir, latest.tag)

verifyClone()

proc downloadPkg*(url: string, verRange: VersionRange,
downMethod: DownloadMethod,
subdir: string,
options: Options,
downloadPath = ""): (string, Version) =
## Downloads the repository as specified by ``url`` and ``verRange`` using
## the download method specified.
##
## If `downloadPath` isn't specified a location in /tmp/ will be used.
##
## Returns the directory where it was downloaded and the concrete version
## which was downloaded.
## Returns the directory where it was downloaded (subdir is appended) and
## the concrete version which was downloaded.
let downloadDir =
if downloadPath == "":
(getNimbleTempDir() / getDownloadDirName(url, verRange))
Expand All @@ -241,13 +239,28 @@ proc downloadPkg*(url: string, verRange: VersionRange,
if modUrl.contains("github.com") and modUrl.endswith("/"):
modUrl = modUrl[0 .. ^2]

display("Downloading", "$1 using $2" % [modUrl, $downMethod],
priority = HighPriority)
if subdir.len > 0:
display("Downloading", "$1 using $2 (subdir is '$3')" %
[modUrl, $downMethod, subdir],
priority = HighPriority)
else:
display("Downloading", "$1 using $2" % [modUrl, $downMethod],
priority = HighPriority)
result = (
downloadDir,
downloadDir / subdir,
doDownload(modUrl, downloadDir, verRange, downMethod, options)
)

if verRange.kind != verSpecial:
## Makes sure that the downloaded package's version satisfies the requested
## version range.
let pkginfo = getPkgInfo(result[0], options)
if pkginfo.version.newVersion notin verRange:
raise newException(NimbleError,
"Downloaded package's version does not satisfy requested version " &
"range: wanted $1 got $2." %
[$verRange, $pkginfo.version])

proc echoPackageVersions*(pkg: Package) =
let downMethod = pkg.downloadMethod.getDownloadMethod()
case downMethod
Expand Down
45 changes: 44 additions & 1 deletion src/nimblepkg/nimscriptsupport.nim
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ from compiler/astalgo import strTableGet
import compiler/options as compiler_options

import common, version, options, packageinfo, cli
import os, strutils, strtabs, tables, times, osproc, sets
import os, strutils, strtabs, tables, times, osproc, sets, pegs

when not declared(resetAllModulesHard):
import compiler/modulegraphs
Expand Down Expand Up @@ -214,6 +214,33 @@ proc getNimPrefixDir(options: Options): string =
# the code responsible for this.
result = ""

proc getLibVersion(lib: string): Version =
## This is quite a hacky procedure, but there is no other way to extract
## this out of the ``system`` module. We could evaluate it, but that would
## cause an error if the stdlib is out of date. The purpose of this
## proc is to give a nice error message to the user instead of a confusing
## Nim compile error.
let systemPath = lib / "system.nim"
if not fileExists(systemPath):
raiseNimbleError("system module not found in stdlib path: " & lib)

let systemFile = readFile(systemPath)
let majorPeg = peg"'NimMajor' @ '=' \s* {\d*}"
let minorPeg = peg"'NimMinor' @ '=' \s* {\d*}"
let patchPeg = peg"'NimPatch' @ '=' \s* {\d*}"

var majorMatches: array[1, string]
let major = find(systemFile, majorPeg, majorMatches)
var minorMatches: array[1, string]
let minor = find(systemFile, minorPeg, minorMatches)
var patchMatches: array[1, string]
let patch = find(systemFile, patchPeg, patchMatches)

if major != -1 and minor != -1 and patch != -1:
return newVersion(majorMatches[0] & "." & minorMatches[0] & "." & patchMatches[0])
else:
return system.NimVersion.newVersion()

when declared(ModuleGraph):
var graph: ModuleGraph

Expand Down Expand Up @@ -249,6 +276,22 @@ proc execScript(scriptName: string, flags: Flags, options: Options): PSym =
"more info."
raiseNimbleError(msg, hint)

# Verify that the stdlib that was found isn't older than the stdlib that Nimble
# was compiled with.
let libVersion = getLibVersion(compiler_options.libpath)
if NimVersion.newVersion() > libVersion:
let msg = ("Nimble cannot use an older stdlib than the one it was compiled " &
"with.\n Stdlib in '$#' has version: $#.\n Nimble needs at least: $#.") %
[compiler_options.libpath, $libVersion, NimVersion]
let hint = "You may be running a newer version of Nimble than you intended " &
"to. Run an older version of Nimble that is compatible with " &
"the stdlib that Nimble is attempting to use or set the environment variable " &
"NIM_LIB_PREFIX to where a different stdlib's `lib` directory is located as " &
"a workaround." &
"See https://github.com/nim-lang/nimble#troubleshooting for " &
"more info."
raiseNimbleError(msg, hint)

let pkgName = scriptName.splitFile.name

# Ensure that "nimblepkg/nimscriptapi" is in the PATH.
Expand Down
Loading

0 comments on commit e9a8850

Please sign in to comment.