Installation

cosymlib is available in both the GitHub and PyPI repositories (https://pypi.org/project/cosymlib/). Installation via PyPI is simpler and it is recommended for most users. Follow the instructions below to install cosymlib in your computer.

Installing cosymlib from PyPI

This installation requires pip (https://pip.pypa.io/en/stable/installing/) to be installed in your system. We strongly recommend the use of python environments, for more details on this, refer to https://docs.python.org/3/library/venv.html.For most users the basic installation should proceed as follows:

  1. Install one of the following python versions:

    3.6, 3.7, 3.8, 3.9, 3.10.
    
  2. Create a virtual environment at path <venv>

    $ python3 -m venv <venv>
    
  3. Activate this virtual environment

    # on MAC / Linux
    $ source <venv>/bin/activate
    
    # on windows (powershell) [see note below]
    C:\> <venv>\Scripts\Activate.ps1
    
  4. Install cosymlib

    $ pip install numpy==1.22
    $ pip install scipy==1.10.1
    $ pip install matplotlib==3.4.2
    $ pip install cosymlib
    
  5. Deactivate the virtual environment

    $ deactivate
    

To use cosymlib you will need to activate the virtual environment every time that you open a new shell. On Linux/MAC all the scripts contained in cosymlib will be accessible in this environment:

$ source <venv>/bin/activate
$ <script_name> <script_options>
$ deactivate

On Windows, to execute the scripts you should type python followed by the full path of the script name:

C:\> python <venv>\Scripts\<script_name> <script_options>

Note

On Windows it may be necessary to add user execution permissions to activate the environment. To do this, open a poweshell as administrator and type:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

You should do this only once in order to gain execution permissions.

Installing cosymlib from source code

Alternatively, you can download the latest version of cosymlib from github using git (https://git-scm.com) and install it manually through the setup.py file using setuptools (https://setuptools.readthedocs.io/).

cosymlib contains libraries written in Fortran that require a compiler to build them. Before installing cosymlib make sure you have a working Fortran compiler installed in your system. For UNIX based systems you can install the GNU Fortran Compiler from package repositories by opening a terminal and typing the following commands:

  • Linux

    On YUM-based systems (Fedora/RedHat/CentOS)

    sudo yum install yum-utils
    

    On APT-based systems (Debian/Ubuntu)

    sudo apt-get build-dep
    
  • Mac

  1. Install command-line tools:

    xcode-select --install
    
  2. Get Homebrew following the instructions at https://brew.sh, and install GCC formula by:

    brew install gcc
    
  • Windows

  1. Install the Windows development environment Visual Studio (https://developer.microsoft.com/en-us/windows/downloads/)

  2. Install C/Fortran compiler for Windows. We have tested and recommend mingw (https://www.mingw-w64.org)

To install cosymlib, download the source code using git in your computer by typing:

git clone https://github.com/GrupEstructuraElectronicaSimetria/cosymlib.git

This creates a copy of the repository in your computer. You can keep it updated by synchronizing it with the GitHub repository by using the command:

git pull

Once this is done, move to the repository root directory (where setup.py is found) and type the following command to install cosymlib :

python setup.py install --user

Note

The requirements.txt file located at the repository root directory contains a list of all dependency python modules needed for cosymlib to run. If any of them are missing in your system you will need to install them before running cosymlib.

In both cases (PyPI & Github installations) the code will be installed as a python module. To check that it is properly installed you can run the python interpreter and execute:

import cosymlib

If the execution does not show any errors, then cosymlib has been installed successfully.

Note

For users with Apple M1, the scipy library might not properly install when following the instructions above. To solve this, install it manually:

brew install openblas
brew install lapack
brew install python
pip install cython pybind11 pythran numpy
OPENBLAS=$(brew --prefix openblas) CFLAGS="-falign-functions=8 ${CFLAGS}" pip install --no-use-pep517 scipy==1.7.0

Note

When using an IDE, remember to select the python interpreter in the hombrew path. To find it:

which python3
>> /opt/homebrew/bin/python3