Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revive this Repository #3

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9f1755c
* revive project
Mar 29, 2020
5db1add
* remove superfluous code in create_app.py
Mar 29, 2020
6a1514c
* include packages for end user
Mar 29, 2020
f12a265
* use dmgbuild package to build dmg disk image
Mar 30, 2020
0cc55f3
* update readme file with new build instructions
Mar 30, 2020
291cdea
* split requirements file for more flexible environment creation
Apr 1, 2020
aa379fa
* copy repos instead of symlink so that py2app alias mode works. Note…
Apr 2, 2020
347f158
* solved linting and code-folding issue: requires kluge for pkg_resou…
Apr 3, 2020
6fd2b23
* required to populate EXCLUDES for proper 'lite' version
Apr 4, 2020
7ef7d8a
* update build instructions
Apr 7, 2020
f0830d4
* fix issue where class and function selector were not working
Apr 6, 2020
a2bcfa4
* include more packages that cannot be zipped
Apr 7, 2020
8e7578b
* indicate 'lite' build in dmg name
Apr 13, 2020
8ba6f95
* flake8 requires pyflakes<2.2.0
Apr 16, 2020
981a552
* install spyder-kernels and python-language-server from spyder subrepo
May 7, 2020
0e9284b
* Update dependency versions
Jun 8, 2020
5366343
* clean up PACKAGES option
Jun 22, 2020
279be1e
* use shell script to create build environment
Jun 22, 2020
c44b128
* Use argparse for better arg parsing and commandline help
Jun 23, 2020
cb67bf0
* make spyder a subrepo
Jun 23, 2020
98b4078
* change subrepo directory
Jul 14, 2020
cbbc6ae
* move spyder dependent installation to create-build-env.sh script
Aug 21, 2020
20ac988
* do not install spyder-kernels from subrepo
Aug 28, 2020
3eed640
only rebuild environment if -a flag given
Aug 28, 2020
e1ee19f
* revise shell scripts
Aug 29, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
*.dmg
\.DS_Store
build/
dist/
spyder/
spyder_kernels/
Spyder.py
166 changes: 0 additions & 166 deletions How to build the app.md

This file was deleted.

80 changes: 75 additions & 5 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,75 @@
This repository contains detailed instructions and scripts to build
the native Spyder MacOS X application, using Homebrew and py2app.

To use them please clone the repo and follow the step by step guide
written in **How to build the app.md**

## How to build the Spyder MacOS X application

**Important note**: These instructions have only been tested on MacOS X 10.14.6

To build the Spyder standalone Mac application you need:
* Python 3.x installed, *not* from Anaconda
* A local clone of the [spyder](https://github.com/spyder-ide/spyder) repository
* A local clone of the [spyder-kernels](https://github.com/spyder-ide/spyder-kernels) repository
* A local clone of this repository

Once you have the above requirements, you will create a virtual environment from which to build the application.

### Python 3.x installation

In principle, it doesn't matter where your Python installation comes from except that it cannot come from Anaconda.
I do not know exactly why an Anaconda installation does not work except that it has something to do with hardlinks.

I recommend using [Homebrew](http://brew.sh/) to install pyenv and pyenv-virtualenv (if you plan to use these for virtual environment management).
If you plan to use pyenv, you don't even need to install Python from Homebrew, since pyenv will install whatever python version you request.
If you don't plan to use pyenv, then you will need to install Python from Homebrew or elsewhere.

After installing Homebrew, run:
```
$ brew install pyenv, pyenv-virtualenv, xz
```
`xz` is a package that provides compression algorithms that Python should be built with to satisfy some packages, namely `pandas`.

The Python frameworks must be copied to the stand-alone application, so if you use pyenv you must enable frameworks in any Python installation that you plan to use to build the Spyder app.
```
$ PYTHON_CONFIGURE_OPTS=--enable-framework pyenv install <python version>
```

### Create Virtual Environment

First, change your current working directory to your local clone of this repository.
If you currently have any conda environment(s) activated, then deactivate them completely, i.e. you should not be in any conda environment, not even base.

Next, create the virtual environment and populate it with the necessary package requirements.
If you are using pyenv with pyenv-virtualenv, it will look like this:
```
$ pyenv virtualenv <python version> env-spy-dev
$ pyenv local env-spy-dev
(env-spy-dev) $ pip install -r req-base.txt -r req-build.txt -r req-user.txt
```
If you are using venv, it will look like this:
```
$ python -m venv --clear --copies env-spy-dev
$ source env-spy-dev/bin/activate
(env-spy-dev) $ pip install -r req-base.txt -r req-build.txt -r req-user.txt
```

`req-base.txt` contains the minimum required packages for Spyder to run.
`req-build.txt` contains only those packages required to build the stand-alone application.
`req-user.txt` contains optional packages to include, if desired, for use in iPython consoles launched from the "Same as Spyder" environment.
If you use external environments, such as conda, for your iPython consoles, you don't need `req-user.txt`.
The build command also provides an option to exclude these packages, so you may include them and still build the application without them, if you choose.

### Create the Standalone Application

For the build to work properly, your local clones of both `spyder` and `spyder-kernels` must be at the same directory level as your local clone of this repository.
To create the standalone application and package it in a dmg disk image run:
```
(env-spy-dev) $ python setup.py py2app
```

After a whole lot of screen dump, and if everything went well, you should now have two files in the `dist` folder of this repository:
* Spyder.app
* Spyder-\<Spyder version\> Py-\<Python version\>.dmg

The following commandline optional arguments are available:
* `py2app`: this causes the bundled app to be produced. Omitting this argument will run `setup.py` without building the app.
* `-A`: This causes py2app to build the application in "alias" mode; basically a quicker way to build the app for debugging, but is not very reliable.
* `--lite`: This will cause py2app to exclude the optional user packages from the application bundle (approximately 250MB).
* `--no-dmg`: This will prevent the dmg disk-image from being created.
64 changes: 64 additions & 0 deletions create-build-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash
set -e

help()
{
echo ""
echo "create-build-env.sh [-h] [-v PYVER] ENV"
echo "Create fresh pyenv environment ENV with Python version PYVER and install spyder"
echo "dependents. Dependents are determined from the current spyder subrepo and"
echo "python-language-server is installed from the subsubrepo"
echo ""
echo "Required:"
echo " ENV Environment name"
echo ""
echo "Options:"
echo " -h Display this help"
echo " -v PYVER Specify the Python version. Default is 3.8.2"
echo ""
}

PYVER=3.8.2
SUBREPO=./subrepos/spyder
PYLS=${SUBREPO}/external-deps/python-language-server
SPYK=${SUBREPO}/external-deps/spyder-kernels

while getopts "hv:" option; do
case $option in
h)
help
exit;;
v)
PYVER=$OPTARG;;
esac
done
shift $(($OPTIND - 1))

ENV=$1

if [[ -z $ENV ]]; then
echo "Please specify environment name."
exit
fi
if [[ -n $CONDA_DEFAULT_ENV ]]; then
echo "Please deactivate $CONDA_DEFAULT_ENV"
exit
fi
if [[ -n $PYENV_VERSION && $PYENV_VERSION==$ENV ]]; then
echo "Please deactivate $PYENV_VERSION"
exit
fi

echo "Removing $ENV environment..."
pyenv uninstall -f $ENV

echo "Building $ENV environment..."
pyenv virtualenv $PYVER $ENV
export PYENV_VERSION=$ENV

pip install -U pip

echo "Installing spyder dependants..."
pip install -r req-build.txt -r req-extras.txt -c req-const.txt \
-e ${PYLS} -e ${SPYK} -e ${SUBREPO}
pip uninstall -q -y spyder