Merge branch 'master' into araq-compiler-api2

This commit is contained in:
Araq 2016-11-01 00:21:51 +01:00
commit 9c81e28343
15 changed files with 141 additions and 119 deletions

View file

@ -1,5 +1,27 @@
[comment]: # (Before releasing, make sure to follow the steps in https://github.com/nim-lang/nimble/wiki/Releasing-a-new-version)
# Nimble changelog # Nimble changelog
## 0.7.10 - 09/10/2016
This release includes multiple bug fixes.
* Reverted patch that breaks binary stubs in Git Bash on Windows.
* The ``nimscriptapi.nim`` file is now statically compiled into the binary.
This should fix the "could not find nimscriptapi.nim" errors. The file can
still be overriden by placing a file named ``nimscriptapi.nim`` inside a
``nimblepkg`` directory that is placed alongside the Nimble binary, or
by a ``nimscriptapi.nim`` file inside ``~/.nimble/pkgs/nimble-ver/nimblepkg/``.
For more information see the
[code that looks for this file](https://github.com/nim-lang/nimble/blob/v0.7.10/src/nimblepkg/nimscriptsupport.nim#L176).
* Nim files can now be imported in .nimble nimscript files. (Issue [#186](https://github.com/nim-lang/nimble/issues/186))
* Requiring a specific git commit hash no longer fails. (Issue [#129](https://github.com/nim-lang/nimble/issues/129))
----
Full changelog: https://github.com/nim-lang/nimble/compare/v0.7.8...v0.7.10
## 0.7.8 - 28/09/2016 ## 0.7.8 - 28/09/2016
This is a hotfix release which fixes crashes when Nimble (or Nim) is installed This is a hotfix release which fixes crashes when Nimble (or Nim) is installed

View file

@ -1,6 +1,13 @@
when dirExists("src"):
# In the git repository the Nimble sources are in a ``src`` directory.
import src/nimblepkg/common
else:
# When the package is installed, the ``src`` directory disappears.
import nimblepkg/common
# Package # Package
version = "0.7.8" version = nimbleVersion
author = "Dominik Picheta" author = "Dominik Picheta"
description = "Nim package manager." description = "Nim package manager."
license = "BSD" license = "BSD"

View file

@ -8,11 +8,8 @@ Interested in learning **how to create a package**? Skip directly to that sectio
## Contents ## Contents
- [Requirements](#requirements)
- [Installation](#installation) - [Installation](#installation)
- [Unix](#unix)
- [Windows](#windows)
- [Using the pre-built archives](#using-the-pre-built-archives)
- [From source](#from-source)
- [Nimble's folder structure and packages](#nimbles-folder-structure-and-packages) - [Nimble's folder structure and packages](#nimbles-folder-structure-and-packages)
- [Nimble usage](#nimble-usage) - [Nimble usage](#nimble-usage)
- [nimble refresh](#nimble-refresh) - [nimble refresh](#nimble-refresh)
@ -47,15 +44,7 @@ Interested in learning **how to create a package**? Skip directly to that sectio
- [Contribution](#contribution) - [Contribution](#contribution)
- [About](#about) - [About](#about)
## Installation ## Requirements
The latest version of Nimble (in the master branch) is primarily tested with
the latest version of the Nim compiler (in the devel branch). You can be sure
that Nimble will compile with that version of the compiler (a green travis
build status is also a good sign that this is the case).
The latest version of Nimble (0.7.4) requires a version of Nim greater than
or equal to 0.13.0. That being said, the latest version of Nim is recommended.
Nimble has some runtime dependencies on external tools, these tools are Nimble has some runtime dependencies on external tools, these tools are
used to download Nimble packages. used to download Nimble packages.
@ -71,51 +60,46 @@ If the version is less recent than 1.9.0 then Nimble may have trouble using it.
See [this issue](https://github.com/nim-lang/nimble/issues/105) for more See [this issue](https://github.com/nim-lang/nimble/issues/105) for more
info. info.
The following sections give platform-specific instructions on how to ## Installation
compile and install Nimble.
### Source based installation Nimble is now bundled with [Nim](http://nim-lang.org)
(since Nim version 0.15.0).
This means that you should have Nimble installed already, as long as you have
the latest version of Nim installed as well. Because of this **you likely do
not need to install Nimble manually**.
Run this command in your **Nim** directory:: But in case you still want to install Nimble manually, you can follow the
following instructions.
nim e install_nimble.nims There are two ways to install Nimble manually. The first is using the
``install_nimble.nims`` script included in the Nim distribution and
[repository](https://github.com/nim-lang/Nim/blob/devel/install_nimble.nims).
Simply execute this to install Nimble.
This assumes that you also used the source based installation and added ```
``$nim/bin`` to your ``PATH``. If you create a symlink to ``nim`` instead, nim e install_nimble.nims
you also need to create a symlink for ``nimble``. ```
### Windows This will clone the Nimble repository, compile Nimble and copy it into
Nim's bin directory.
You can install Nimble via a pre-built installation archive which is The second approach is to install Nimble as a Nimble package. You can do this
available on the [releases](https://github.com/nim-lang/nimble/releases) page. by compiling Nimble, then running ``nimble install`` in Nimble's directory.
Alternatively, you can also install Nimble from source.
#### Using the pre-built archives ```
git clone https://github.com/nim-lang/nimble.git
cd nimble
nim c src/nimble
src/nimble install
```
Download the latest release archive from the **Note for Windows users**: You will need to rename ``nimble.exe`` after
[releases](https://github.com/nim-lang/nimble/releases) page. These archives compilation to something else like ``nimble1.exe``, then run
will have a filename of the form ``nimble-x_win32`` where ``x`` is the ``src\nimble1.exe install``.
current version.
Once you download that archive unzip it and execute the ``install.bat`` file. This will install Nimble to the default Nimble packages location:
One important thing to note is that this installation requires you have ``~/.nimble/pkgs``. The binary will be installed to ``~/.nimble/bin``, so you
the Nim compiler in your PATH. Once the installation completes you should will need to add this directory to your PATH.
add ``C:\Users\YourName\.nimble\bin`` to your PATH.
#### From source
On Windows installing Nimble from source is slightly more complex:
git clone https://github.com/nim-lang/nimble.git
cd nimble
nim -d:release c src/nimble
cp src/nimble.exe src/nimble1.exe
src/nimble1.exe install
This is required because Windows will lock the process which is being run, but
during installation Nimble recompiles itself causing an error.
Once the installation completes you should
add ``C:\Users\YourName\.nimble\bin`` to your PATH.
## Nimble's folder structure and packages ## Nimble's folder structure and packages

View file

@ -7,7 +7,7 @@ import httpclient, parseopt, os, strutils, osproc, pegs, tables, parseutils,
from sequtils import toSeq from sequtils import toSeq
import nimblepkg/packageinfo, nimblepkg/version, nimblepkg/tools, import nimblepkg/packageinfo, nimblepkg/version, nimblepkg/tools,
nimblepkg/download, nimblepkg/config, nimblepkg/nimbletypes, nimblepkg/download, nimblepkg/config, nimblepkg/common,
nimblepkg/publish, nimblepkg/options, nimblepkg/packageparser nimblepkg/publish, nimblepkg/options, nimblepkg/packageparser
import nimblepkg/nimscriptsupport import nimblepkg/nimscriptsupport
@ -30,9 +30,6 @@ else:
proc GetVersionExA*(VersionInformation: var OSVERSIONINFO): WINBOOL{.stdcall, proc GetVersionExA*(VersionInformation: var OSVERSIONINFO): WINBOOL{.stdcall,
dynlib: "kernel32", importc: "GetVersionExA".} dynlib: "kernel32", importc: "GetVersionExA".}
const
nimbleVersion = "0.7.8"
proc writeVersion() = proc writeVersion() =
echo("nimble v$# compiled at $# $#" % echo("nimble v$# compiled at $# $#" %
[nimbleVersion, CompileDate, CompileTime]) [nimbleVersion, CompileDate, CompileTime])
@ -258,6 +255,7 @@ proc processDeps(pkginfo: PackageInfo, options: Options): seq[string] =
## ##
## Returns the list of paths to pass to the compiler during build phase. ## Returns the list of paths to pass to the compiler during build phase.
result = @[] result = @[]
assert(not pkginfo.isMinimal, "processDeps needs pkginfo.requires")
let pkglist = getInstalledPkgs(options.getPkgsDir(), options) let pkglist = getInstalledPkgs(options.getPkgsDir(), options)
var reverseDeps: seq[tuple[name, version: string]] = @[] var reverseDeps: seq[tuple[name, version: string]] = @[]
for dep in pkginfo.requires: for dep in pkginfo.requires:
@ -471,7 +469,7 @@ proc installFromDir(dir: string, latest: bool, options: Options,
# For bash on Windows (Cygwin/Git bash). # For bash on Windows (Cygwin/Git bash).
let bashDest = dest.changeFileExt("") let bashDest = dest.changeFileExt("")
echo("Creating Cygwin stub: ", pkgDestDir / bin, " -> ", bashDest) echo("Creating Cygwin stub: ", pkgDestDir / bin, " -> ", bashDest)
writeFile(bashDest, "\"$(cygpath '" & pkgDestDir / bin & "')\" \"$@\"\l") writeFile(bashDest, "\"" & pkgDestDir / bin & "\" \"$@\"\n")
else: else:
{.error: "Sorry, your platform is not supported.".} {.error: "Sorry, your platform is not supported.".}
else: else:

40
src/nimblepkg/common.nim Normal file
View file

@ -0,0 +1,40 @@
# BSD License. Look at license.txt for more info.
#
# Various miscellaneous common types reside here, to avoid problems with
# recursive imports
when not defined(nimscript):
import sets
import version
export version.NimbleError
type
BuildFailed* = object of NimbleError
PackageInfo* = object
mypath*: string ## The path of this .nimble file
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
author*: string
description*: string
license*: string
skipDirs*: seq[string]
skipFiles*: seq[string]
skipExt*: seq[string]
installDirs*: seq[string]
installFiles*: seq[string]
installExt*: seq[string]
requires*: seq[PkgTuple]
bin*: seq[string]
binDir*: string
srcDir*: string
backend*: string
const
nimbleVersion* = "0.7.10"

View file

@ -2,7 +2,7 @@
# BSD License. Look at license.txt for more info. # BSD License. Look at license.txt for more info.
import parsecfg, streams, strutils, os, tables, Uri import parsecfg, streams, strutils, os, tables, Uri
import tools, version, nimbletypes import tools, version, common
type type
Config* = object Config* = object

View file

@ -3,7 +3,7 @@
import parseutils, os, osproc, strutils, tables, pegs import parseutils, os, osproc, strutils, tables, pegs
import packageinfo, packageparser, version, tools, nimbletypes, options import packageinfo, packageparser, version, tools, common, options
type type
DownloadMethod* {.pure.} = enum DownloadMethod* {.pure.} = enum
@ -174,12 +174,9 @@ proc doDownload*(url: string, downloadDir: string, verRange: VersionRange,
if verRange.spe == newSpecial(getHeadName(downMethod)): if verRange.spe == newSpecial(getHeadName(downMethod)):
doClone(downMethod, url, downloadDir) # Grab HEAD. doClone(downMethod, url, downloadDir) # Grab HEAD.
else: else:
# Mercurial requies a clone and checkout. The git clone operation is # Grab the full repo.
# already fragmented into multiple steps so we just call doClone().
if downMethod == DownloadMethod.git:
doClone(downMethod, url, downloadDir, $verRange.spe)
else:
doClone(downMethod, url, downloadDir, tip = false) doClone(downMethod, url, downloadDir, tip = false)
# Then perform a checkout operation to get the specified branch/commit.
doCheckout(downMethod, downloadDir, $verRange.spe) doCheckout(downMethod, downloadDir, $verRange.spe)
result = verRange result = verRange
else: else:

View file

@ -1,36 +0,0 @@
# BSD License. Look at license.txt for more info.
#
# Various miscellaneous common types reside here, to avoid problems with
# recursive imports
import sets
import version
export version.NimbleError
type
BuildFailed* = object of NimbleError
PackageInfo* = object
mypath*: string ## The path of this .nimble file
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
author*: string
description*: string
license*: string
skipDirs*: seq[string]
skipFiles*: seq[string]
skipExt*: seq[string]
installDirs*: seq[string]
installFiles*: seq[string]
installExt*: seq[string]
requires*: seq[PkgTuple]
bin*: seq[string]
binDir*: string
srcDir*: string
backend*: string

View file

@ -8,13 +8,14 @@ import
compiler/ast, compiler/modules, compiler/passes, compiler/passaux, compiler/ast, compiler/modules, compiler/passes, compiler/passaux,
compiler/condsyms, compiler/sem, compiler/semdata, compiler/condsyms, compiler/sem, compiler/semdata,
compiler/llstream, compiler/vm, compiler/vmdef, compiler/commands, compiler/llstream, compiler/vm, compiler/vmdef, compiler/commands,
compiler/msgs, compiler/magicsys, compiler/lists, compiler/idents compiler/msgs, compiler/magicsys, compiler/lists, compiler/idents,
compiler/nimconf
from compiler/scriptconfig import setupVM from compiler/scriptconfig import setupVM
from compiler/astalgo import strTableGet from compiler/astalgo import strTableGet
import compiler/options as compiler_options import compiler/options as compiler_options
import nimbletypes, version, options, packageinfo import common, version, options, packageinfo
import os, strutils, strtabs, times, osproc, sets import os, strutils, strtabs, times, osproc, sets
type type
@ -27,6 +28,7 @@ type
const const
internalCmd = "NimbleInternal" internalCmd = "NimbleInternal"
nimscriptApi = staticRead("nimscriptapi.nim")
proc raiseVariableError(ident, typ: string) {.noinline.} = proc raiseVariableError(ident, typ: string) {.noinline.} =
raise newException(NimbleError, raise newException(NimbleError,
@ -178,24 +180,20 @@ proc setupVM(module: PSym; scriptName: string,
flags[a.getString 0] = a.getString 1 flags[a.getString 0] = a.getString 1
proc findNimscriptApi(options: Options): string = proc findNimscriptApi(options: Options): string =
## Returns the directory containing ``nimscriptapi.nim`` ## Returns the directory containing ``nimscriptapi.nim`` or an empty string
var inPath = false ## if it cannot be found.
result = ""
# Try finding it in exe's path # Try finding it in exe's path
if fileExists(getAppDir() / "nimblepkg" / "nimscriptapi.nim"): if fileExists(getAppDir() / "nimblepkg" / "nimscriptapi.nim"):
result = getAppDir() result = getAppDir()
inPath = true
if not inPath: if result.len == 0:
let pkgs = getInstalledPkgsMin(options.getPkgsDir(), options) let pkgs = getInstalledPkgsMin(options.getPkgsDir(), options)
var pkg: PackageInfo var pkg: PackageInfo
if pkgs.findPkg(("nimble", newVRAny()), pkg): if pkgs.findPkg(("nimble", newVRAny()), pkg):
let pkgDir = pkg.getRealDir() let pkgDir = pkg.getRealDir()
if fileExists(pkgDir / "nimblepkg" / "nimscriptapi.nim"): if fileExists(pkgDir / "nimblepkg" / "nimscriptapi.nim"):
result = pkgDir result = pkgDir
inPath = true
if not inPath:
raise newException(NimbleError, "Cannot find nimscriptapi.nim")
proc getNimPrefixDir(): string = splitPath(findExe("nim")).head.parentDir proc getNimPrefixDir(): string = splitPath(findExe("nim")).head.parentDir
@ -213,12 +211,20 @@ proc execScript(scriptName: string, flags: StringTableRef, options: Options) =
# Ensure that "nimblepkg/nimscriptapi" is in the PATH. # Ensure that "nimblepkg/nimscriptapi" is in the PATH.
let nimscriptApiPath = findNimscriptApi(options) let nimscriptApiPath = findNimscriptApi(options)
if nimscriptApiPath.len > 0:
# TODO: Once better output is implemented show a message here.
appendStr(searchPaths, nimscriptApiPath) appendStr(searchPaths, nimscriptApiPath)
else:
let tmpNimscriptApiPath = getTempDir() / "nimblepkg" / "nimscriptapi.nim"
createDir(tmpNimscriptApiPath.splitFile.dir)
if not existsFile(tmpNimscriptApiPath):
writeFile(tmpNimscriptApiPath, nimscriptApi)
appendStr(searchPaths, getTempDir())
setDefaultLibpath() initDefines()
loadConfigs(DefaultConfig)
passes.gIncludeFile = includeModule passes.gIncludeFile = includeModule
passes.gImportModule = importModule passes.gImportModule = importModule
initDefines()
defineSymbol("nimscript") defineSymbol("nimscript")
defineSymbol("nimconfig") defineSymbol("nimconfig")

View file

@ -4,7 +4,7 @@
import json, strutils, os, parseopt, strtabs, uri, tables import json, strutils, os, parseopt, strtabs, uri, tables
from httpclient import Proxy, newProxy from httpclient import Proxy, newProxy
import config, version, tools, nimbletypes import config, version, tools, common
type type
Options* = object Options* = object

View file

@ -1,7 +1,7 @@
# Copyright (C) Dominik Picheta. All rights reserved. # Copyright (C) Dominik Picheta. All rights reserved.
# BSD License. Look at license.txt for more info. # BSD License. Look at license.txt for more info.
import parsecfg, json, streams, strutils, parseutils, os, sets, tables import parsecfg, json, streams, strutils, parseutils, os, sets, tables
import version, tools, nimbletypes, options import version, tools, common, options
type type
Package* = object Package* = object

View file

@ -1,7 +1,7 @@
# Copyright (C) Dominik Picheta. All rights reserved. # Copyright (C) Dominik Picheta. All rights reserved.
# BSD License. Look at license.txt for more info. # BSD License. Look at license.txt for more info.
import parsecfg, json, streams, strutils, parseutils, os, tables import parsecfg, json, streams, strutils, parseutils, os, tables
import version, tools, nimbletypes, nimscriptsupport, options, packageinfo import version, tools, common, nimscriptsupport, options, packageinfo
## Contains procedures for parsing .nimble files. Moved here from ``packageinfo`` ## Contains procedures for parsing .nimble files. Moved here from ``packageinfo``
## because it depends on ``nimscriptsupport`` (``nimscriptsupport`` also ## because it depends on ``nimscriptsupport`` (``nimscriptsupport`` also
@ -250,7 +250,7 @@ proc getInstalledPkgs*(libsDir: string, options: Options):
if nimbleFile != "": if nimbleFile != "":
let meta = readMetaData(path) let meta = readMetaData(path)
try: try:
var pkg = readPackageInfo(nimbleFile, options, true) var pkg = readPackageInfo(nimbleFile, options, onlyMinimalInfo=false)
pkg.isInstalled = true pkg.isInstalled = true
result.add((pkg, meta)) result.add((pkg, meta))
except ValidationError: except ValidationError:

View file

@ -5,7 +5,7 @@
## nim-lang/packages automatically. ## nim-lang/packages automatically.
import httpclient, base64, strutils, rdstdin, json, os, browsers, times, uri import httpclient, base64, strutils, rdstdin, json, os, browsers, times, uri
import tools, nimbletypes import tools, common
type type
Auth = object Auth = object

View file

@ -3,7 +3,7 @@
# #
# Various miscellaneous utility functions reside here. # Various miscellaneous utility functions reside here.
import osproc, pegs, strutils, os, uri, sets, json, parseutils import osproc, pegs, strutils, os, uri, sets, json, parseutils
import version, packageinfo, nimbletypes import version, packageinfo, common
proc extractBin(cmd: string): string = proc extractBin(cmd: string): string =
if cmd[0] == '"': if cmd[0] == '"':

View file

@ -22,6 +22,10 @@ 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 "issue 129 (installing commit hash)":
check execCmdEx(path & " install -y \"https://github.com/nimble-test/packagea.git@#1f9cb289c89\"").
exitCode == QuitSuccess
test "issue 113 (uninstallation problems)": test "issue 113 (uninstallation problems)":
cd "issue113/c": cd "issue113/c":
check execCmdEx("../../" & path & " install -y").exitCode == QuitSuccess check execCmdEx("../../" & path & " install -y").exitCode == QuitSuccess