3
Package Manager Functions
4
-------------------------
6
All Package manager functions are defined in the ``Pkg`` module; note that none of the ``Pkg`` module's functions are exported;
7
to use them, you'll need to prefix each function call with an explicit ``Pkg.``, e.g. ``Pkg.status()`` or ``Pkg.dir()``.
9
.. function:: dir() -> String
11
Returns the absolute path of the package directory.
12
This defaults to ``joinpath(homedir(),".julia")`` on all platforms (i.e. ``~/.julia`` in UNIX shell syntax).
13
If the ``JULIA_PKGDIR`` environment variable is set, that path is used instead.
14
If ``JULIA_PKGDIR`` is a relative path, it is interpreted relative to whatever the current working directory is.
16
.. function:: dir(names...) -> String
18
Equivalent to ``normpath(Pkg.dir(),names...)`` – i.e. it appends path components to the package directory and normalizes the resulting path.
19
In particular, ``Pkg.dir(pkg)`` returns the path to the package ``pkg``.
23
Initialize ``Pkg.dir()`` as a package directory.
24
This will be done automatically when the ``JULIA_PKGDIR`` is not set and ``Pkg.dir()`` uses its default value.
26
.. function:: resolve()
28
Determines an optimal, consistent set of package versions to install or upgrade to.
29
The optimal set of package versions is based on the contents of ``Pkg.dir("REQUIRE")`` and the state of installed packages in ``Pkg.dir()``,
30
Packages that are no longer required are moved into ``Pkg.dir(".trash")``.
34
Opens ``Pkg.dir("REQUIRE")`` in the editor specified by the ``VISUAL`` or ``EDITOR`` environment variables;
35
when the editor command returns, it runs ``Pkg.resolve()`` to determine and install a new optimal set of installed package versions.
37
.. function:: add(pkg, vers...)
39
Add a requirement entry for ``pkg`` to ``Pkg.dir("REQUIRE")`` and call ``Pkg.resolve()``.
40
If ``vers`` are given, they must be ``VersionNumber`` objects and they specify acceptable version intervals for ``pkg``.
44
Remove all requirement entries for ``pkg`` from ``Pkg.dir("REQUIRE")`` and call ``Pkg.resolve()``.
46
.. function:: clone(url, [pkg])
48
Clone a package directly from the git URL ``url``.
49
The package does not need to be a registered in ``Pkg.dir("METADATA")``.
50
The package repo is cloned by the name ``pkg`` if provided;
51
if not provided, ``pkg`` is determined automatically from ``url``.
53
.. function:: clone(pkg)
55
If ``pkg`` has a URL registered in ``Pkg.dir("METADATA")``, clone it from that URL on the default branch.
56
The package does not need to have any registered versions.
58
.. function:: available() -> Vector{ASCIIString}
60
Returns the names of available packages.
62
.. function:: available(pkg) -> Vector{VersionNumber}
64
Returns the version numbers available for package ``pkg``.
66
.. function:: installed() -> Dict{ASCIIString,VersionNumber}
68
Returns a dictionary mapping installed package names to the installed version number of each package.
70
.. function:: installed(pkg) -> Nothing | VersionNumber
72
If ``pkg`` is installed, return the installed version number, otherwise return ``nothing``.
74
.. function:: status()
76
Prints out a summary of what packages are installed and what version and state they're in.
78
.. function:: update()
80
Update package the metadata repo – kept in ``Pkg.dir("METADATA")`` – then update any fixed packages that can safely be pulled from their origin;
81
then call ``Pkg.resolve()`` to determine a new optimal set of packages versions.
83
.. function:: checkout(pkg, [branch="master"])
85
Checkout the ``Pkg.dir(pkg)`` repo to the branch ``branch``.
86
Defaults to checking out the "master" branch.
88
.. function:: pin(pkg)
90
Pin ``pkg`` at the current version.
92
.. function:: pin(pkg, version)
94
Pin ``pkg`` at registered version ``version``.
96
.. function:: free(pkg)
98
Free the package ``pkg`` to be managed by the package manager again.
99
It calls ``Pkg.resolve()`` to determine optimal package versions after.
100
This is an inverse for both ``Pkg.checkout`` and ``Pkg.pin``.
102
.. function:: build()
104
Run the build scripts for all installed packages in depth-first recursive order.
106
.. function:: build(pkgs...)
108
Run the build scripts for each package in ``pkgs`` and all of their dependencies in depth-first recursive order.
109
This is called automatically by ``Pkg.resolve()`` on all installed or updated packages.
111
.. function:: generate(pkg,license)
113
Generate a new package named ``pkg`` with one of these license keys: ``"MIT"`` or ``"BSD"``.
114
If you want to make a package with a different license, you can edit it afterwards.
115
Generate creates a git repo at ``Pkg.dir(pkg)`` for the package and inside it ``LICENSE.md``, ``README.md``, the julia entrypoint ``$pkg/src/$pkg.jl``, and a travis test file, ``.travis.yml``.
117
.. function:: register(pkg, [url])
119
Register ``pkg`` at the git URL ``url``, defaulting to the configured origin URL of the git repo ``Pkg.dir(pkg)``.
121
.. function:: tag(pkg, [ver, [commit]])
123
Tag ``commit`` as version ``ver`` of package ``pkg`` and create a version entry in ``METADATA``.
124
If not provided, ``commit`` defaults to the current commit of the ``pkg`` repo.
125
If ``ver`` is one of the symbols ``:patch``, ``:minor``, ``:major`` the next patch, minor or major version is used.
126
If ``ver`` is not provided, it defaults to ``:patch``.
128
.. function:: publish()
130
For each new package version tagged in ``METADATA`` not already published, make sure that the tagged package commits have been pushed to the repo at the registered URL for the package and if they all have, push ``METADATA``.