Skip to content

Commit

Permalink
Merge pull request #12389 from ccordoba12/pyls-subrepo
Browse files Browse the repository at this point in the history
PR: Add a git subrepo for the python-language-server
  • Loading branch information
ccordoba12 committed Apr 24, 2020
2 parents 1a3ddb5 + 5ca7d6c commit 755acb7
Show file tree
Hide file tree
Showing 94 changed files with 10,659 additions and 21 deletions.
22 changes: 14 additions & 8 deletions .github/scripts/install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/bash -ex

if [ "$OS" = "macos" ]; then
# Adjust PATH in macOS because conda is not at front of it
PATH=/usr/local/miniconda/envs/test/bin:/usr/local/miniconda/condabin:$PATH
fi

# Install dependencies
if [ "$USE_CONDA" = "true" ]; then

Expand All @@ -14,11 +19,9 @@ if [ "$USE_CONDA" = "true" ]; then
# Install test ones
conda install python=$PYTHON_VERSION --file requirements/tests.txt -c spyder-ide -q -y

# Remove spyder-kernels to be sure that we use its subrepo
# Remove packages we have subrepos for
conda remove spyder-kernels --force -q -y

# Install python-language-server from Github with no deps
pip install --no-deps git+https://github.com/palantir/python-language-server -q
conda remove python-language-server --force -q -y
else
# Update pip and setuptools
pip install -U pip setuptools
Expand All @@ -35,13 +38,16 @@ else
# Install qtconsole from Github
pip install git+https://github.com/jupyter/qtconsole.git

# Remove spyder-kernels to be sure that we use its subrepo
# Remove packages we have subrepos for
pip uninstall spyder-kernels -q -y

# Install python-language-server from Github
pip install git+https://github.com/palantir/python-language-server -q
pip uninstall python-language-server -q -y
fi

# Install python-language-server from our subrepo
pushd external-deps/python-language-server
pip install --no-deps -q -e .
popd

# To check our manifest
pip install check-manifest

Expand Down
36 changes: 35 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ For example, backporting `my_branch` from `master` to `4.x`:
$ git rebase --onto 4.x master my_branch
```

### Making contributions that depend on pull requests in spyder-kernels

## Making contributions that depend on pull requests in spyder-kernels

Spyder and spyder-kernels are developed jointly because a lot of communication happens between them in order to run code written in the editor in the IPython console. The way the branches on their respective repos are linked appears in the table below:

Expand Down Expand Up @@ -187,6 +188,39 @@ As an example, let's assume that (i) your Github user name is `myuser`; (ii) you
where `<branch>` needs to be `1.x` if your `fix_in_spyder` branch was done against Spyder's `4.x` branch; and `master`, if you did it against our `master` branch here.


## Making contributions that depend on pull requests in python-language-server

As with spyder-kernels, Spyder is tightly integrated with the [python-language-server](https://github.com/palantir/python-language-server) to provide code completion, linting and folding on its editor.

Due to that, a clone of that project is placed in the `external-deps` directory, which is managed with the `git subrepo` project. If you want to make a pull request in python-language-server that affects functionality in Spyder, please read carefully the instructions in the previous section because they are very similar for this case. A summary of those instructions applied to this project is the following:

* First you need to create a pull request in python-language-server with the changes you want to make there. Let's assume the branch from which that pull request is created is called `fix_in_pyls`.

* Then you need to create a branch in Spyder (let's call it `fix_in_spyder`) with the fixes that require that pull request and update the python-language-server subrepo. For that you need to execute the following commands:

```
$ git checkout -b fix_in_spyder
$ git subrepo clone https://github.com/myuser/python-language-server.git external-deps/python-language-server -b fix_in_pyls -f
```

and then commit the changes you need to make in Spyder.

* If you need to add more commits to `fix_in_pyls`, you need to update `fix_in_spyder` with these commands:

```
$ git checkout fix_in_spyder
$ git subrepo pull external-deps/python-language-server
$ git push origin fix_in_spyder
```

* After `fix_in_pyls` is merged, you need to update the python-language-server subrepo in your `fix_in_spyder` branch with

```
$ git checkout fix_in_spyder
$ git subrepo clone https://github.com/palantir/python-language-server.git external-deps/python-language-server -b develop -f
```


## Adding Third-Party Content

All files or groups of files, including source code, images, icons, and other assets, that originate from projects outside of the Spyder organization (regardless of the license), must be first approved by the Spyder team. Always check with us (on Github, Gitter, Google Group, etc) before attempting to add content from an external project, and only do so when necessary.
Expand Down
94 changes: 82 additions & 12 deletions bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,20 @@
# pylint: disable=C0412
# pylint: disable=C0413

import time
time_start = time.time()

# Standard library imports
import argparse
import os
import os.path as osp
import sys
import argparse
import shutil
import subprocess
import sys
import time

# Third-party imports
import pkg_resources


time_start = time.time()


# --- Parse command line
Expand Down Expand Up @@ -121,7 +127,7 @@

# Add this path to the front of sys.path
sys.path.insert(0, DEVPATH)
print("01. Patched sys.path with %s" % DEVPATH)
print("*. Patched sys.path with %s" % DEVPATH)

# Add external dependencies subrepo paths to be the next entries
# (1, 2, etc) of sys.path
Expand All @@ -130,27 +136,91 @@
for path in os.listdir(DEPS_PATH):
external_dep_path = osp.join(DEPS_PATH, path)
sys.path.insert(i, external_dep_path)
print("01-%d. Patched sys.path with %s" % (i, external_dep_path))
print("*. Patched sys.path with %s" % external_dep_path)
i += 1

# Install our PyLS subrepo in development mode. Else the server is unable
# to load its plugins with setuptools.
install_pyls_subrepo = False
try:
pkg = pkg_resources.get_distribution('python-language-server')

# Remove the PyLS stable version first (in case it's present)
if 'dirty' not in pkg.egg_name():
print("*. Removing stable version of the PyLS.")
uninstall_with_pip = False
is_conda = osp.exists(osp.join(sys.prefix, 'conda-meta'))

if is_conda:
output = subprocess.check_output(
['conda',
'list',
'python-language-server',
'--json'],
shell=True if os.name == 'nt' else False
)

# Remove with conda if the package was installed by conda
if b'pypi' not in output:
subprocess.check_output(
['conda',
'remove',
'-q',
'-y',
'--force',
'python-language-server'],
shell=True if os.name == 'nt' else False
)
else:
uninstall_with_pip = True
else:
uninstall_with_pip = True

if uninstall_with_pip:
subprocess.check_output(
['pip',
'uninstall',
'-q',
'-y',
'python-language-server']
)
install_pyls_subrepo = True
except pkg_resources.DistributionNotFound:
# This could only happen if the PyLS was not previously installed
install_pyls_subrepo = True

if install_pyls_subrepo:
print("*. Installing the PyLS in development mode")
PYLS_PATH = osp.join(DEPS_PATH, 'python-language-server')
subprocess.check_output(
[sys.executable,
'-m',
'pip',
'install',
'--no-deps',
'-e',
'.'],
cwd=PYLS_PATH
)

# Selecting the GUI toolkit: PyQt5 if installed
if args.gui is None:
try:
import PyQt5 # analysis:ignore
print("02. PyQt5 is detected, selecting")
print("*. PyQt5 is detected, selecting")
os.environ['QT_API'] = 'pyqt5'
except ImportError:
sys.exit("ERROR: No PyQt5 detected!")
else:
print ("02. Skipping GUI toolkit detection")
print ("*. Skipping GUI toolkit detection")
os.environ['QT_API'] = args.gui


# Checking versions (among other things, this has the effect of setting the
# QT_API environment variable if this has not yet been done just above)
from spyder import get_versions
versions = get_versions(reporev=True)
print("03. Imported Spyder %s - Revision %s, Branch: %s" %
print("*. Imported Spyder %s - Revision %s, Branch: %s" %
(versions['spyder'], versions['revision'], versions['branch']))
print(" [Python %s %dbits, Qt %s, %s %s on %s]" %
(versions['python'], versions['bitness'], versions['qt'],
Expand All @@ -172,7 +242,7 @@
"is to show the console, use --hide-console if you want to hide it")

if args.hide_console and os.name == 'nt':
print("0x. Hiding parent console (Windows only)")
print("*. Hiding parent console (Windows only)")
sys.argv.append("--hide-console") # Windows only: show parent console

# Reset temporary config directory if starting in --safe-mode
Expand All @@ -182,7 +252,7 @@
if osp.isdir(conf_dir):
shutil.rmtree(conf_dir)

print("04. Running Spyder")
print("*. Running Spyder")
from spyder.app import start # analysis:ignore

time_lapse = time.time() - time_start
Expand Down
60 changes: 60 additions & 0 deletions external-deps/python-language-server/.circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
version: 2

jobs:
python2-test:
docker:
- image: "python:2.7-stretch"
steps:
- checkout
- run: pip install -e .[all] .[test]
- run: py.test -v test/
- run: pylint pyls test
- run: pycodestyle pyls test
- run: pyflakes pyls test

python3-test:
docker:
- image: "python:3.5-stretch"
steps:
- checkout
# To test Jedi environments
- run: python3 -m venv /tmp/pyenv
- run: /tmp/pyenv/bin/python -m pip install loghub
- run: pip install -e .[all] .[test]
- run: py.test -v test/

lint:
docker:
- image: "python:2.7-stretch"
steps:
- checkout
- run: pip install -e .[all] .[test]
- run: pylint pyls test
- run: pycodestyle pyls test
- run: pyflakes pyls test

publish:
docker:
- image: "python:3.5-stretch"
steps:
- checkout
- run: ./scripts/circle/pypi.sh


workflows:
version: 2
build:
jobs:
- python2-test:
filters: { tags: { only: /.*/ } }
- python3-test:
filters: { tags: { only: /.*/ } }
- publish:
filters:
tags:
only: /[0-9]+(\.[0-9]+)+((-(beta|rc)[0-9]{1,2})(\.[0-9])?)?/
branches:
ignore: /.*/
requires:
- python2-test
- python3-test
2 changes: 2 additions & 0 deletions external-deps/python-language-server/.coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
omit = pyls/_version.py
1 change: 1 addition & 0 deletions external-deps/python-language-server/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pyls/_version.py export-subst
Loading

0 comments on commit 755acb7

Please sign in to comment.