Skip to content
This repository was archived by the owner on Apr 21, 2024. It is now read-only.

Commit f6edf2e

Browse files
authored
Merge pull request #61 from cgay/dev
Change default package install directory
2 parents 53e47ff + 000c3c5 commit f6edf2e

File tree

9 files changed

+59
-48
lines changed

9 files changed

+59
-48
lines changed

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ remove-dylan-tool-artifacts:
7373

7474
clean: remove-dylan-tool-artifacts
7575
rm -rf _build
76+
rm -rf _test
7677

7778
distclean: clean
7879
rm -rf $(install_dir)

documentation/source/index.rst

+29-22
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@ workspace
3333
means a workspace is where the :file:`_build` and :file:`registry`
3434
directories are generated. In most cases, a workspace is the directory
3535
containing the :file:`dylan-package.json` file, but the ultimate arbiter is
36-
the workspace.json file, if it exists. See `workspaces`_ for details.
36+
the :file:`workspace.json` file, if it exists. See `workspaces`_ for details.
3737

3838
active package
3939
A package checked out into the top-level of a workspace. In most cases a
4040
workspace is the same as a package directory so there is only one active
41-
package. See `Workspaces`_ for discussion of multi-package
42-
workspaces. Example: the `dylan update`_ subcommand scans active packages
43-
when creating the registry.
41+
package. See `Workspaces`_ for discussion of multi-package workspaces.
42+
43+
The `dylan update`_ subcommand scans active packages when creating the
44+
registry.
4445

4546
release
4647
A specific version of a package. A release has a `Semantic Version`_ associated
@@ -50,24 +51,28 @@ release
5051
Requirements
5152
============
5253

53-
To find and install packages on the local file system many of the
54-
:program:`dylan` subcommands use the :envvar:`DYLAN` environment variable. If
55-
:envvar:`DYLAN` is not set, ``$HOME/dylan`` is used instead. (Much of this
56-
documentation is written to assume that :envvar:`DYLAN` is set, but it is not
57-
required.)
58-
5954
Make sure :program:`git` is on your :envvar:`PATH` so it can be found by the
6055
package manager, which currently exec's ``git clone`` to install
6156
packages. (This dependency will be removed in a future release.)
6257

63-
The :program:`dylan` tool installs packages, including the `pacman-catalog`_
64-
package (which describes where to find other packages), under ``$DYLAN/pkg/``.
6558

66-
.. warning::
59+
Where are Packages Installed?
60+
=============================
61+
62+
The :program:`dylan` tool installs package dependencies locally in the
63+
workspace directory by default. However, you may choose to install them
64+
globally with :command:`dylan update --global`. Also, the package manager
65+
caches `its catalog <https://github.com/dylan-lang/pacman-catalog>`_ into a
66+
global location per user. This location is chosen based on environment
67+
variables, in this order:
68+
69+
1. ``${DYLAN}/_packages`` if :envvar:`DYLAN` is set.
70+
71+
2. ``${XDG_STATE_HOME}/dylan/_packages`` (Unix) if :envvar:`XDG_STATE_HOME` is
72+
set, or ``${CSIDL_LOCAL_APPDATA}/dylan/_packages`` (Windows) if
73+
:envvar:`CSIDL_LOCAL_APPDATA` is set.
6774

68-
Don't put files you want to keep in the ``$DYLAN/pkg/`` directory. The
69-
expectation should be that anything in this directory may be deleted at any
70-
time by the package manager.
75+
3. ``${HOME}/.local/state/dylan/_packages`` otherwise.
7176

7277

7378
Building From Source
@@ -85,8 +90,8 @@ version, follow these steps to build and install.
8590

8691
#. Read the `Requirements`_ section, above.
8792

88-
#. Make sure you have :program:`git`, :program:`make`, and Open Dylan
89-
installed.
93+
#. Make sure you have :program:`git`, :program:`make`, and
94+
:program:`dylan-compiler` installed.
9095

9196
#. Clone and build the "dylan-tool" project::
9297

@@ -97,7 +102,8 @@ version, follow these steps to build and install.
97102
$ make install
98103

99104
#. Make sure that ``$DYLAN/bin`` is on your ``$PATH``. If you prefer not to
100-
set ``$DYLAN``, make sure that ``$HOME/dylan/bin`` is on your ``$PATH``.
105+
set ``$DYLAN``, make sure that ``$HOME/dylan/bin`` is on your ``$PATH``, as
106+
that is where the Makefile installs the executable.
101107

102108
You should now be able to run `dylan help`_ and go through the Hello World
103109
example below.
@@ -462,13 +468,14 @@ Options:
462468
dylan install
463469
-------------
464470

465-
Install a package into the package cache, ``${DYLAN}/pkg``.
471+
Install packages.
466472

467473
Synopsis: ``dylan install <package> [<package> ...]``
468474

469475
This command is primarily useful if you want to browse the source code in a
470-
package locally without having to worry about where to clone it from. The
471-
packages are installed into ``${DYLAN}/pkg/<package-name>/<version>/src/``.
476+
package locally without having to worry about where to clone it from. If you
477+
are in a workspace directory the packages are installed in the workspace's
478+
"_packages" subdirectory. Otherwise, see `Where are Packages Installed?`_.
472479

473480

474481
.. index::

ext/testworks

sources/commands/simple-commands.dylan

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ define constant $update-subcommand
153153
= make(<update-subcommand>,
154154
options: list(make(<flag-option>,
155155
names: #("global"),
156-
help: "Install packages in ${DYLAN}/pkg instead of in the"
157-
" workspace.")));
156+
help: "Install packages globally instead of in the"
157+
" workspace. [%default%]")));
158158

159159
define method execute-subcommand
160160
(parser :: <command-line-parser>, subcmd :: <update-subcommand>)

sources/library.dylan

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ define module pacman
4848
export
4949
<catalog-error>,
5050
catalog,
51-
dylan-directory, // $DYLAN or $HOME/dylan or /opt/dylan
51+
dylan-directory,
5252
package-manager-directory,
5353
*package-manager-directory*,
54+
$package-directory-name,
5455

5556
<catalog>,
5657
catalog-directory,

sources/pacman/install-test.dylan

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ define test test-install ()
1919
assert-false(installed?(release));
2020
install(release);
2121
assert-true(installed?(release));
22-
let file = as(<file-locator>, "pkg/json/1.0.0/src/json.lid");
22+
let file = as(<file-locator>,
23+
format-to-string("%s/json/1.0.0/src/json.lid",
24+
$package-directory-name));
2325
let lid-path = merge-locators(file, dir);
2426
assert-true(file-exists?(lid-path));
2527
let versions = installed-versions(release.package-name);

sources/pacman/utils.dylan

+18-19
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Module: %pacman
44
define function string-parser (s :: <string>) => (s :: <string>) s end;
55

66
// Name of the subdirectory in which packages are to be installed.
7-
define constant $package-directory-name = "pkg";
7+
define constant $package-directory-name = "_packages";
88

99
// This provides a way for dylan-tool commands to override the default package
1010
// installation directory without threading it through the entire call chain,
@@ -20,29 +20,28 @@ define function package-manager-directory
2020
| subdirectory-locator(dylan-directory(), $package-directory-name)
2121
end function;
2222

23-
// TODO: Windows
24-
define constant $default-dylan-directory = "/opt/dylan";
25-
define constant $dylan-dir-name = "dylan";
2623
define constant $dylan-env-var = "DYLAN";
2724

28-
// The base directory for all things Dylan for a given user.
29-
// 1. ${DYLAN}
30-
// 2. ${HOME}/dylan or %APPDATA%\dylan
31-
// 3. /opt/dylan or ??? on Windows
32-
// TODO: Dylan implementations should export this.
3325
define function dylan-directory
3426
() => (dir :: <directory-locator>)
27+
let basevar = select (os/$os-name)
28+
#"win32" => "CSIDL_LOCAL_APPDATA";
29+
otherwise => "XDG_STATE_HOME";
30+
end;
31+
let base = os/environment-variable(basevar);
32+
let home = os/environment-variable("HOME");
3533
let dylan = os/environment-variable($dylan-env-var);
36-
if (dylan)
37-
as(<directory-locator>, dylan)
38-
else
39-
// TODO: use %APPDATA% on Windows
40-
let home = os/environment-variable("HOME");
41-
if (home)
42-
subdirectory-locator(as(<directory-locator>, home), $dylan-dir-name)
43-
else
44-
as(<directory-locator>, $default-dylan-directory)
45-
end
34+
case
35+
dylan =>
36+
as(<directory-locator>, dylan);
37+
base =>
38+
subdirectory-locator(as(<directory-locator>, base), "dylan");
39+
home =>
40+
subdirectory-locator(as(<directory-locator>, home), ".local", "state", "dylan");
41+
otherwise =>
42+
package-error("Couldn't determine Dylan global package directory."
43+
" Set the %s, %s, or HOME environment variable.",
44+
$dylan-env-var, basevar);
4645
end
4746
end function;
4847

sources/workspaces/workspaces.dylan

+2-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ define function update
7777
= if (global?)
7878
*package-manager-directory*
7979
else
80-
subdirectory-locator(workspace-directory(ws), "_packages")
80+
subdirectory-locator(workspace-directory(ws),
81+
pm/$package-directory-name)
8182
end)
8283
let (releases, actives) = update-deps(ws, cat);
8384
let registry = update-registry(ws, cat, releases, actives);

0 commit comments

Comments
 (0)