Browse Source

Added Comonicon and Prepare v1.0 Release (#2)

* Started migrating CLI to us Comonicon

* Added back support for multiple environments

* updated build for comonicon executable

* Updated comonicon

* Added comonicon compat entry

* Added documentation and prepare for v1.0 release

* Added documentation badge
master v1.0.0
Micah Halter 1 year ago
committed by GitHub
parent
commit
0b41fb0fb4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      .github/workflows/docs.yml
  2. 6
      Project.toml
  3. 58
      README.md
  4. 2
      deps/build.jl
  5. 3
      docs/Project.toml
  6. 26
      docs/make.jl
  7. 5
      docs/src/api.md
  8. 11
      docs/src/assets/analytics.js
  9. 89
      docs/src/index.md
  10. 57
      src/VirtualEnv.jl

17
.github/workflows/docs.yml

@ -0,0 +1,17 @@
name: Documentation
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@latest
with:
version: '1.5'
- run: julia --project=docs -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate();'
- name: "Build and deploy docs"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: julia --project=docs docs/make.jl

6
Project.toml

@ -1,7 +1,11 @@
name = "VirtualEnv"
uuid = "f8ef4a19-0666-4e54-aa90-5d6169a53550"
authors = ["Micah Halter <micah@mehalter.com>"]
version = "0.1.0"
version = "1.0.0"
[deps]
Comonicon = "863f3e99-da2a-4334-8734-de3dacbe5542"
[compat]
Comonicon = "^0.6"
julia = "1.0"

58
README.md

@ -1,6 +1,12 @@
# VirtualEnv.jl
Self contained virtual environments for Julia.
[![Documentation](https://github.com/mehalter/VirtualEnv.jl/workflows/Documentation/badge.svg)](https://mehalter.github.io/VirtualEnv.jl/stable)
VirtualEnv.jl provides support for creating lightweight “virtual environments”
with their own site directories, isolated from system site directories. Each
virtual environment has its own Julia binary (which matches the version of the
binary that was used to create this environment) and can have its own
independent set of installed Julia packages in its site directories.
## Supported Shells
@ -16,38 +22,56 @@ Self contained virtual environments for Julia.
# Installation
`~$ julia -e 'using Pkg; Pkg.add("VirtualEnv")'`
```
~$ julia -e 'using Pkg; Pkg.add("VirtualEnv")'
```
add `~/.julia/bin` to your `PATH`, or you can install paths automatically with
```julia
using VirtualEnv; VirtualEnv.comonicon_install_path()
```
# Usage
```
usage: venv(ENV_DIR, [ENV_DIR, ...]; [clear=(true|false)], [upgrade=(true|false)],
[prompt=PROMPT], [help=(true|false)])
venv
Creates virtual Julia environments in one or more target directories.
positional arguments:
ENV_DIR A directory to create the environment in.
Usage
venv [options] [flags] <env_dirs>
Args
<env_dirs> One or more directories to create environments in.
Options
-p, --prompt <prompt> Provides an alternative prompt prefix for this
environment.(Default: ENV_DIR)
Flags
-c, --clear Delete the contents of the environment directory if it
alreadyexists. (Default: false)
-u, --upgrade Upgrade the environment directory to use this version
ofJulia. (Default: false)
optional arguments:
help=(true|false) show this help message and exit
clear=(true|false) Delete the contents of the environment directory if it
already exists, before environment creation. (Default: false)
upgrade=(true|false) Upgrade the environment directory to use this version
of Julia, assuming Julia has been upgraded in-place. (Default: false)
prompt=PROMPT Provides an alternative prompt prefix for this environment. (Default: ENV_DIR)
-h, --help print this help message
Once an environment has been created, you may wish to activate it,
e.g. by sourcing an activate script in its bin directory.
-V, --version print version information
```
Print help dialogue:
`~$ julia -e 'using VirtualEnv; venv(help=true)'`
`~$ venv -h`
Creating a virtual environment:
`~$ julia -e 'using VirtualEnv; venv("env")'`
`~$ venv env`
Activating the virtual environment:

2
deps/build.jl

@ -0,0 +1,2 @@
using Comonicon, VirtualEnv
Comonicon.install(VirtualEnv; name="venv", optimize=0, compile="min", completion=true)

3
docs/Project.toml

@ -0,0 +1,3 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
VirtualEnv = "f8ef4a19-0666-4e54-aa90-5d6169a53550"

26
docs/make.jl

@ -0,0 +1,26 @@
using Documenter
@info "Loading VirtualEnv"
using VirtualEnv
@info "Building Documenter.jl docs"
makedocs(
modules = [VirtualEnv],
format = Documenter.HTML(
assets = ["assets/analytics.js"],
),
sitename = "VirtualEnv.jl",
doctest = false,
checkdocs = :none,
pages = Any[
"VirtualEnv.jl" => "index.md",
"Library Reference" => "api.md",
]
)
@info "Deploying docs"
deploydocs(
target = "build",
repo = "github.com/mehalter/VirtualEnv.jl.git",
branch = "gh-pages"
)

5
docs/src/api.md

@ -0,0 +1,5 @@
# Library Reference
```@autodocs
Modules = [VirtualEnv]
```

11
docs/src/assets/analytics.js

@ -0,0 +1,11 @@
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://matomo.mehalter.com/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '5']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();

89
docs/src/index.md

@ -0,0 +1,89 @@
# VirtualEnv.jl
```@meta
CurrentModule = VirtualEnv
```
VirtualEnv.jl provides support for creating lightweight “virtual environments”
with their own site directories, isolated from system site directories. Each
virtual environment has its own Julia binary (which matches the version of the
binary that was used to create this environment) and can have its own
independent set of installed Julia packages in its site directories.
## Installation
VirtualEnv is a Julia Language package. To install VirtualEnv, please open Julia's interactive session (known as REPL) and press `]` key in the REPL to use the package mode, then type the following command
For stable release
```
pkg> add VirtualEnv
```
For current master
```
pkg> add VirtualEnv#master
```
## Usage
Creation of virtual environments is done by executing the command `venv`:
```
julia -e 'using VirtualEnv; venv("/path/to/new/virtual/environment")'
```
An executable is also created in your `.julia` folder in `.julia/bin` (The
default location of this folder is `~/.julia`) which can be used for easier
execution:
```
venv /path/to/new/virtual/environment
```
The help text can easily be displayed in the Julia REPL with `?venv` or by
executing the command `venv -h`. This shows the available options when
creating new environments or upgrading existing environments.
```
venv
Creates virtual Julia environments in one or more target directories.
Usage
venv [options] [flags] <env_dirs>
Args
<env_dirs> One or more directories to create environments in.
Options
-p, --prompt <prompt> Provides an alternative prompt prefix for this
environment.(Default: ENV_DIR)
Flags
-c, --clear Delete the contents of the environment directory if it
alreadyexists. (Default: false)
-u, --upgrade Upgrade the environment directory to use this version
ofJulia. (Default: false)
-h, --help print this help message
-V, --version print version information
```
## Global Installation
It is recommended to add this `.julia/bin` folder to your `PATH` so that the
executable is available everywhere. To easily add the appropriate locations to
your path, you can run the following:
```
julia> using VirtualEnv
julia> VirtualEnv.comonicon_install_path()
```

57
src/VirtualEnv.jl

@ -5,6 +5,8 @@ Module to provide the ability to create self-contained julia virtual environment
"""
module VirtualEnv
using Comonicon
export venv
include("Utilities.jl")
@ -37,34 +39,6 @@ function context(install_dir::String, depot_dir::String)
)
end
"""
usage()
Print usage of the venv function
"""
function usage()
print("""
usage: venv(ENV_DIR, [ENV_DIR, ...]; [clear=(true|false)], [upgrade=(true|false)],
[prompt=PROMPT], [help=(true|false)])
Creates virtual Julia environments in one or more target directories.
positional arguments:
ENV_DIR A directory to create the environment in.
optional arguments:
help=(true|false) show this help message and exit
clear=(true|false) Delete the contents of the environment directory if it
already exists, before environment creation. (Default: false)
upgrade=(true|false) Upgrade the environment directory to use this version
of Julia, assuming Julia has been upgraded in-place. (Default: false)
prompt=PROMPT Provides an alternative prompt prefix for this environment. (Default: ENV_DIR)
Once an environment has been created, you may wish to activate it,
e.g. by sourcing an activate script in its bin directory.
""")
end
"""
create(env_dir::String, clear::Bool, upgrade::Bool, prompt::String)
@ -144,19 +118,24 @@ function create(env_dir::String, clear::Bool, upgrade::Bool, prompt::String)
end
"""
venv(env_dirs::String...; clear::Bool=false, upgrade::Bool=false, prompt::String=nothing)
Creates virtual Julia environments in one or more target directories.
# Arguments
- `env_dirs`: One or more directories to create environments in.
# Options
Create the listed environment directories.
- `-p, --prompt <prompt>`: Provides an alternative prompt prefix for this environment. (Default: ENV_DIR)
# Flags
- `-c, --clear`: Delete the contents of the environment directory if it already exists. (Default: false)
- `-u, --upgrade`: Upgrade the environment directory to use this version of Julia. (Default: false)
"""
function venv(env_dirs::String...; clear::Bool=false, upgrade::Bool=false, help::Bool=false, prompt::String="")
# Print usage if no environment directories given
if help || isempty(env_dirs)
usage()
# Create each environment directory provided if directories provided
else
for env_dir in env_dirs
create(env_dir, clear, upgrade, prompt)
end
@main function venv(env_dirs::String...; clear::Bool=false, upgrade::Bool=false, prompt::String="")
for env_dir in env_dirs
create(env_dir, clear, upgrade, prompt)
end
end

Loading…
Cancel
Save