Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

Instructions for setting up a development environment on Windows(PowerShell, winget)

Satoshi Terasaki edited this page Sep 20, 2024 · 3 revisions

How to Configure a Development Environment on Windows

Introduction

This guide provides step-by-step instructions on how to set up a development environment on Windows. The image attached displays the output of the winver command in PowerShell, indicating the current version of my (@terasakisatoshi) Windows machine.

image

What You Will Learn

You will learn how to install various commands like git, julia, make, and code using winget. The winget command enables easy installation of command-line tools, bypassing the need for a graphical user interface.

O.K. let's get started.

Using Windows PowerShell

We use Windows PowerShell to execute a variety of commands for running programs like git, julia, make, code and more. To open Windows PowerShell, press the Windows key and type Windows PowerShell. Refer to the image provided below for guidance.

For a simple exercise, type echo Hello. The output will be Hello.

PS C:\Users\teras> echo Hello
Hello
PS C:\Users\teras>

date shows the current date and time.

PS C:\Users\teras> date

Friday, July 19, 2024 9:29:57 PM


PS C:\Users\teras>

Here, PS> serves as a prompt indicating that your input is expected. In subsequent references, we will omit C:\Users\teras and simply use PS> to avoid redundancy.

Great! Go on to the next section.

Using winget to install packages

We use winget command to install programs like git,julia,make, and more. Here WinGet is the package manager for windows. On Windows 11, it should be installed by default.

Install Julia

We follow this instruction to download Julia. Run the following command in Windows PowerShell.

PS> winget install julia -s msstore

Screenshot 2024-08-01 213504

Press Y as necessary. Then you can use julia command right now!!! If your machine does not julia command, try re-open Powershell again and run julia command. One may want to run:

PS> juliaup add release

As of July 19, 2024, 1.10.4 is the latest stable version of Julia. Let's type versioninfo() to print information about the version of Julia in use.

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.10.4 (2024-06-04)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> versioninfo()
Julia Version 1.10.4
Commit 48d4fd4843 (2024-06-04 10:41 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 8 × Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, icelake-client)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)

For a simple exercise, type println("Hello World"). The output will be Hello World!.

julia> println("Hello World!")
Hello World!

To exit Julia REPL session, just type exit().

julia> exit()
PS > # Back to Windows PowerShell

See The Julia REPL in the official Julia documentation to learn more.

Install Git

Git is a distributed version control system. We follow this instruction to download git command using winget.

PS> winget install --id Git.Git -e --source winget

image

The installer will request to run as administrator, expect a prompt.

To use the git command, it is necessary to close the current session of Windows PowerShell and reopen it. Let's type git --version to confirm that Git is installed properly.

PS> git --version
git version 2.45.2.windows.1
PS>

Clone T4AJuliaTutorials

Let's clone our repository

PS C:\Users\teras> git clone https://github.com/tensor4all/T4AJuliaTutorials.git

If you are not familiar with Git, you can think of "clone" as "download". When you clone a Git repository, you’re essentially downloading a copy of the entire project, including all the code, history, and branches, onto your local machine. This allows you to work on the project locally, make changes, and then push those changes back to the repository.

Next, we navigate to the directory using the cd command, The cd command which stands for “change directory”, is used in the command line to switch between file directories. Here’s how you might use it:

PS C:\Users\teras> cd .\T4AJuliaTutorials\

The ls command displays a list of all files and directories in the current directory. The output should match the contents of the GitHub repository at tensor4all/T4AJuliaTutorials. Below is a screenshot from my machine.

image

Finally, to display the path of the current directory, run pwd command:

PS C:\Users\teras\T4AJuliaTutorials> pwd

Path
----
C:\Users\teras\T4AJuliaTutorials

Install GNU Make

The make command is utilized as a task runner to convert *.jl files to *.ipynb and build our project using jupyter book locally. The EZWinPorts project offers numerous valuable ports of the latest versions of GNU and Unix software. GNU Make can be installed using the following command:

PS> winget install --id ezwinports.make -e --source winget

To use the make command, it is necessary to close the current session of Windows PowerShell and reopen it.

image

Install Visual Studio Code

PS> winget install -e --id Microsoft.VisualStudioCode

image

To launch Visual Studio Code using the code command, we must close the current Windows PowerShell session and reopen it. Typically, entering code <path/to/directory> will open Visual Studio Code and set <path/to/directory> as the project's root directory.

PS C:\Users\teras> cd .\T4AJuliaTutorials\
PS C:\Users\teras\T4AJuliaTutorials> pwd

Path
----
C:\Users\teras\T4AJuliaTutorials


PS C:\Users\teras\T4AJuliaTutorials> code .
PS C:\Users\teras\T4AJuliaTutorials>

If you get a warning related to Do you trust the authors of the files in this folder?, click Yes, I trust the authors.

image

Build T4AJuliaTutorials locally

Caution: Building projects that depend on JupyterBook in Windows might encounter issues. It is recommended to use WSL2 for a smoother experience. For more information, refer to the JupyterBook documentation on Windows.

Running make command

Just run make. You will get the following output:

PS> make
julia --project scripts/jupyter_book.jl
    CondaPkg Found dependencies: C:\Users\teras\work\tensor4all\T4AJuliaTutorials\CondaPkg.toml
    CondaPkg Found dependencies: C:\Users\teras\.julia\packages\PythonCall\S5MOg\CondaPkg.toml
    CondaPkg Found dependencies: C:\Users\teras\.julia\packages\PythonPlot\f591M\CondaPkg.toml
    CondaPkg Dependencies already up to date
Running Jupyter-Book v1.0.2
Source Folder: C:\Users\teras\work\tensor4all\T4AJuliaTutorials
Config Path: C:\Users\teras\work\tensor4all\T4AJuliaTutorials\_config.yml
Output Path: C:\Users\teras\work\tensor4all\T4AJuliaTutorials\_build\html
Running Sphinx v7.4.6
loading translations [en]... done
[etoc] Changing master_doc to 'ipynbs/index'
loading pickled environment... done

...
...
...

Finished generating HTML for book.
Your book's HTML pages are here:
    _build\html\
You can look at your book by opening this file in a browser:
    _build\html\index.html
Or paste this line directly into your browser bar:
    file://C:\Users\teras\work\tensor4all\T4AJuliaTutorials\_build\html\index.html

===============================================================================

As indicated in the output above, you can open HTML files created by the make command as follows:

PS> .\_build\html\index.html

This will launch the index page of T4AJuliaTutorials!

Set up a WSL development environment

See https://learn.microsoft.com/en-us/windows/wsl/setup/environment#set-up-your-linux-username-and-password This is a step-by-step guide to the best practices for setting up a WSL development environment.