Skip to content

Make it possible to build on WSL #28549

@tobiasdiez

Description

@tobiasdiez

This ticket is to inform you about how to build sage with the Windows Subsystem for Linux and to provide the necessary changes to make this work. Since this is my first contribution to sage, please let me know if I've overseen something obvious and please be lenient in case I broke some written or unwritten rules.

Steps to build sage on WSL

including set-up git infrastructure since this is partly different on Windows as well.

Prerequisites

Git (run everything in git bash)

  • Clone repository

  • Correct line endings (necessary if global core.autocrlf is set to true):

    git config --local core.autocrlf false 
    git rm --cached -r .
    git reset --hard
    
* Setup remote trac (nessary if you want to contribute)
  
  Follow the instructions to set-up the ssh key https://help.github.com/en/articles/working-with-ssh-key-passphrases and then follow http://doc.sagemath.org/html/en/developer/trac.html#trac-authentication-through-ssh and http://doc.sagemath.org/html/en/developer/manual_git.html#chapter-manual-git

git remote add trac git://trac.sagemath.org/sage.git -t master
git remote set-url --push trac git@trac.sagemath.org:sage.git

* Switch to development branch

git checkout develop


## Build sage (run everything from Ubuntu bash)
* Install prerequisites 
  This is a slightly extended version of the [corresponding script for Linux](http://doc.sagemath.org/html/en/installation/source.html#linux-recommended-installation).

sudo apt-get update

sudo apt-get install binutils pixz gcc g++ gfortran make m4 perl tar git patch openssl libssl-dev libz-dev bc libbz2-dev liblzma-dev libgmp-dev libffi-dev libgf2x-dev libcurl4-openssl-dev curl yasm
sudo apt-get install gettext libgettextpo-dev
sudo apt-get install automake pkgconf

* Change into sage folder
* Set how many cores you want to use for building (important, otherwise it will take ages)

export MAKE="make -j4"


* Build (there will be errors on the way, so ignore them using the `-k` switch)

make -k

* Test sage

./sage
2+2



# Changes necessary to make this work
In order to make the above procedure work, I had to change a few things on the way. I have pushed these changes to the branch `public/wls`.
* Linux symlinks do not work under Windows. Thus, if you clone the repository the symlinks are replaced by ordinary text files containing the target path of the symlink. To fix this, I replaced the symlinks in `build/pgks/gfortran/` by the respective files in `build/pgks/gcc` and similarily in `build/pgks/python2/` by the respective files in `build/pgks/python3/`. (There is probably a more elegant way to do this)
* Error

spgk-install should not be marked executable in the build/pkgs directory

   was fixed by changing `build/bin/sage-spkg`. This is a quick hack and probably needs to be fixed properly. The trick used for cygwin does not work since `uname = Linux` when run from WSL.
* Error 

OSError: [Errno 22] Invalid argument: './src/doc/pari/Programming_in_GP:_other_specific_functions.html'
open sage/upstream/giac-X.tar.bz2

   was fixed by changes in `tar_file.py`. This is also a quick hack and needs a better fix, e.g. rename the file to a valid name?
* Error

The headers or library files could not be found for zlib,
a required dependency when compiling Pillow from source.

Please see the install instructions at:
https://pillow.readthedocs.io/en/latest/installation.html

   was fixed by deactivating `zlib` in `pillow/spkg-install`. Note sure if this has any negative side effects.

# Remaining issues
With the above changes, the `make` build works in principle. There are a few small issues that needs further improvement.
* Creating the documentation during `make` or by `./sage --docbuild all html` fails with the errors of the form

OSError: WARNING: Unable to fetch /mnt/c/sage/local/share/doc/sage/doctrees/en/reference/algebras/environment.pickle
There is a syntax error in your configuration file: invalid syntax (conf.py, line 1)
Build finished. The built documents can be found in /mnt/c/sage/local/share/doc/sage/inventory/en/reference/algebras

   I guess, the problem is that `conf.py` in `src\doc\en\reference\algebras` is a symbolic link.
* At startup of sage, you get the warning

/mnt/c/sage/local/lib/python2.7/site-packages/psutil/_pslinux.py:519: RuntimeWarning: 'sin' and 'sout' swap memory stats couldn't be determined and were set to 0 ([Errno 2] No such file or directory: '/proc/vmstat')
warnings.warn(msg, RuntimeWarning)

  Probably, there is nothing we can do, since this is a known limitation of WSL: https://github.com/microsoft/WSL/issues/1071

CC:  @embray @slel @dimpase @soehms @pfasante

Component: **build**

Keywords: **windows, wsl, make**

Branch/Commit: **[public/wls](https://github.com/sagemath/sagetrac-mirror/tree/public/wls) @ [`cd8116e`](https://github.com/sagemath/sagetrac-mirror/commit/cd8116ead3b66e949c414bce76e154eddf69e47c)**

Reviewer: **Tobias Diez**

_Issue created by migration from https://trac.sagemath.org/ticket/28549_

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions