Project Environments
In modules and packages, we focused on creating from scratch the project folders. In this lesson, we will focus on downloading packages and creating environments from scripts.
Ensure that the languages used in this course are installed and available in the system terminal. For JS, we need the runtime environment Node.
Go and TS states
Let's first set the current states of the different languages to be at per.
For Go and TS ~ node project, we preserve the state from modules and packages lesson and TS configuration respectively.
Dart module
For Dart, you can use the one in modules and packages too but the recommended way is using dart create fourier.
sh
cd ~/Projects/Dart|
            [Dart]$ dart create fourier
Creating fourier using template console...

.gitignore
analysis_options.yaml
CHANGELOG.md
pubspec.yaml
README.md
bin/fourier.dart
lib/fourier.dart
test/fourier_test.dart

Running pub get...                     3.7s
Resolving dependencies...
Downloading test 1.24.1...
Downloading test_core 0.5.1...
Downloading test_api 0.5.1...
Changed 46 dependencies!

Created project fourier in fourier! In order to get started, run the following 
commands:

cd fourier
dart run

[Dart]$
          
Python venv
For Python, we'll use the package venv
python
cd ~/Projects/Python|
            [Python]$ pwd
/Users/siliconSavanna/Projects/Python/
[Python]$ which python3
/usr/bin/python3
[Python]$ python3 --version
Python 3.8.9
[Python]$ mkdir CustomVenvs
[Python]$ cd CustomVenvs
[CustomVenvs]$ python3 -m venv fourier
[CustomVenvs]$ cd fourier
[fourier]$ ls
bin             include         lib             pyvenv.cfg
[fourier]$ source bin/activate
(fourier) [fourier]$ python --version
Python 3.8.9
(fourier) [fourier]$ which python
/Users/siliconSavanna/Projects/Python/CustomVenvs/fourier/bin/python
(fourier) [fourier]$ deactivate
[fourier]$
          
In the above terminal output, we check first the global Python environment to distinguish it from the custom environment we'll create to isolate modules and packages.
Next, we create a folder that will host our custom environments for the different projects we need to build. This it the CustomVenvs folder.
Then, the line python3 -m venv fourier creates an environment fourier. This environment is activated with the source bin/activate whilst in its root directory.
Now, if we check the python version and executable location, its source is from the environment we've created.
You can change location to anywhere from within the terminal but as long the environment you created is activated, the python executable and any packages installed will reside in that environment.
You can deactivate the environment with deactivate command from the terminal.
Python Conda
I'll also introduce conda for managing Python environments.
First, ensure you have Anaconda or Miniconda installed. Check that it is recognized in the system terminal.
            [fourier]$ conda --version
conda 4.12.0
[fourier]$
          
Listing the environments in Conda, we will only find one, if newly installed the tool, base.
We can use the command below:
conda env list|
            [fourier]$ conda env list
# conda environments:
#
base                  *  /Users/siliconSavanna/miniforge3
          
To activate and deactivate an environment, for instance, the base environment, we use the below scripts:
            [fourier]$ conda activate base
(base) [fourier]$ conda deactivate
[fourier]$
          
To create a new custom environment, for instance, the fourier environment, we use the below script:
conda create -n fourier python=3.11|
Note: The Python version must be provided when you're creating the environment
To check all the supported Python versions, you can use the script below. This also applies to when you want to download a package and need to search for available versions.
            (base) [fourier]$ conda search python
Loading channels: done                                                             
# Name                       Version           Build  Channel                      
python                         3.8.5 h05baefb_8_cpython  conda-forge               
python                         3.8.6 h12cc5a1_1_cpython  conda-forge               
python                         3.8.6 h12cc5a1_2_cpython  conda-forge               
python                         3.8.6 h12cc5a1_3_cpython  conda-forge
....
....
....
python                        3.11.1 h1456518_0_cpython  conda-forge         
python                        3.11.2 h1456518_0_cpython  conda-forge
          
From the terminal ouput below, you notice that the base environment has Python version 3.9.*, and the environment created has Python version 3.11.*
            (base) [fourier]$ python --version
Python 3.9.10
(base) [fourier]$ conda activate fourier
(fourier) [fourier]$ python --version
Python 3.11.2
(fourier) [fourier]$ conda deactivate
(base) [fourier]$
          
Now, to delete an environment created, you use the script below:
            conda env remove --name fourier
          
Julia Activate
For Julia, we'll use the script activate .
After installing Julia, you can create a folder, fourier.
Julia REPL
using generate
            [fourier]$ julia
            _
_       _ _(_)_     |  Documentation: https://docs.julialang.org
(_)     | (_) (_)    |
_ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` |  |
| | |_| | | | (_| |  |  Version 1.7.2 (2022-02-06)
_/ |\__'_|_|_|\__'_|  |  HEAD/bf53498635 (fork: 461 commits, 664 days)
|__/                   |

# In Julia REPL
# press ; to enter shell REPL
julia>;

shell> mkdir fourier

shell> cd fourier/
/Users/siliconSavanna/Projects/Julia/fourier

# In shell REPL, press backspace/delete to enter Julia REPL
# Then press ] to enter Pkg REPL
(@v1.7) pkg> activate .
Activating new project at `~/Projects/Julia/fourier`

# now environment is fourier from @v1.7
(fourier) pkg> st
    Status `~/Projects/Julia/fourier/Project.toml` (empty project)

(fourier) pkg>
          
Note: When you create an environment, it is empty. So if you don't download any package and exit the REPL, the environment will be deleted. It will imply you download at least a package in the environment to generate the .toml files and hence retain the environment folder.
Note: To exit the Julia REPL, we can type exit() in the REPL.
Managing third-party packages
Now that we have already walked through the modules, packages and now environments, we now move onto downloading, listing, updating and removing third-party packages.

Currently, our fourier modules, packages and environments are in this state
go
js
dart
python
julia
            [fourier]$ pwd
/Users/siliconSavanna/Projects/Golang/fourier
[fourier]$ ls -R *
go.mod  main.go

hello:
go.mod          hello.go
[fourier]$
          
So in Go, JS, Dart,, we are in the project folders, fourier, in Python we have activated the fourier venv and are in the project folder, fourier, and for Julia, we have started REPL in the project folder and are on standby.
Installing Package
Let's install a package:
go
js
dart
python
julia
            [fourier]$ go get -u rsc.io/quote                   
go: added golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c
go: added rsc.io/quote v1.5.2
go: added rsc.io/sampler v1.3.0      
[fourier]$
          
Now on using the packages installed in the core codebase of the languages, the resulting code and terminal output of the executable is as below:
go
js
dart
python
julia
package main

import (
    "fmt"
    "example.com/fourier/hello"
    "rsc.io/quote"
)

func main () {
    fmt.Println("Hello world")
    arch := hello.SayArch()
    fmt.Println(arch)
    fmt.Println(quote.Go())
}
'use strict';

const { SayArch } = require('./hello/hello.ts')

console.log("Hello World")
let arch = SayArch("OS Info ==> ")
console.log(arch)

const quotes = require("quotesy")
console.log(quotes.random());
import 'package:fourier/hello/hello.dart';
import 'package:quoter/quoter.dart';

void main() {
    print("Hello World");
    print(SayArch());
    Quoter quoter = Quoter();
    Quote randomQuote = quoter.getRandomQuote();
    print(randomQuote.quotation);
    print(randomQuote.quotee);
}
from hello.hello import SayArch
from quoters import Quote

# OR
#from hello import hello
# arch = hello.SayArch() 

print("Hello World")
arch = SayArch()
print(arch)
print(Quote.print())
print(Quote.print_programming_quote())
module Fourier

include("hello/hello.jl")
using Example 
println(Hello.SayArch())
println(Example.hello("Knights"))

end
go
js
dart
python
julia
            [fourier]$ go run .
Hello world
Architecture: darwin
Don't communicate by sharing memory, share memory by communicating.
[fourier]$
          
Listing and updating packages
Now, onto listing available inbuilt and installed packages, and updating them to specific versions of the packages that is compatible aligned.
go
js
dart
python
julia
            # to list standard libraries use 
$ go list std
[fourier]$ go list std                                    
archive/tar                                                                     
archive/zip
...
...
vendor/golang.org/x/text/unicode/bidi
vendor/golang.org/x/text/unicode/norm
# to list installed / locally imported modules
[fourier]$ go list -m all
example.com/fourier
golang.org/x/text v0.3.7
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e
rsc.io/quote v1.5.2
rsc.io/sampler v1.3.0
[fourier]$
          
Now that we've listed all installed packages, to list package versions that are installable:
go
js
            [fourier]$ go list -m -versions rsc.io/quote
rsc.io/quote v0.9.9-pre1 v1.0.0 v1.1.0 v1.2.0 v1.2.1 v1.3.0 v1.4.0 v1.5.0 v1.5.1 v1.5.2 v1.5.3-pre1
[fourier]$
          
While version searching is present in the two languages above, it is recommended to look through the official websites for the language installable packages to see which versions exist and the compatibility issues.
LanguagePackages platform
Golangpkg.go.dev
JSnpm
Dartpub.dev
Pythonpypi.org
JuliaJuliaHub
Install specific version
To install a specific version of a package, use the script below:
go
js
dart
python
julia
go mod edit -require rsc.io/quote@v1.3.0|
Checking outdated packages
Before upgrading packages, this is the way to check outdated packages:
go
js
dart
python
go list -u -m all|
Updating packages
Now, onto updating already installed packages to the latest stable versions:
go
js
dart
python
julia
# there are 2 options|
Removing packages
Lastly, let us tackle remove a package from our module, package or environment
go
js
dart
python
julia
# after removing package import from files|