install_for_dev.rst 2.01 KB

Installing GuitAstro for development

Prerequisite: You have ever downloaded Guitastro and installed Python.

1. Recommanded use of virtual environment

We are going to create and use the virtual environment named (guitastro).

conda create -n guitastro python=3.8 spyder
conda activate guitastro

2. Python requirements

As Guitastro uses many Python libraries, they must be installed before using Guitastro. To do that we use the file requirements.txt containing all the required library names and version. The file requirements.txt is placed in the install folder where Guitastro was downloaded.

For Linux users:

cd ~/Documents/guitastro/install
pip3 install pip-tools
python3 -m piptools compile requirements.in
python3 -m pip install -r requirements.txt

For Windows users, open a Powershell as administrator. A quick way to open Powershell as administrator is Win+R (execute commands) and put:

powershell Start-Process powershell -Verb runAs

Then, in the Powershell terminal:

cd C:\Users\xxx\Documents\guitastro\install
pip install pip-tools
python3 -m piptools compile requirements.in
python -m pip install -r requirements.txt

3. Import guitastro from everywhere

We considered to have installed guitastro in the xxx/Documents/guitastro directory of the computer. If you want to import guitastro with the simple line "import guitastro" you must have your calling program in the directory Documents which is not easy to manage. To avoid this constraint, just before the import line you must add the guitastro installation directory in the list of the variable sys.path of Python:

import sys
path = r"C:\Users\xxx\Documents\guitastro\src"
if path not in sys.path:
        sys.path.insert(0,path)
import guitastro