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

python-lsp-server: new port #11601

Merged
merged 4 commits into from
Jul 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions python/py-language-server/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ PortSystem 1.0
PortGroup github 1.0
PortGroup python 1.0
PortGroup select 1.0
PortGroup deprecated 1.0

# palantir/python-language-server is unmaintained and has been forked
# to python-lsp/python-lsp-server
deprecated.upstream_support no

name py-language-server
github.setup palantir python-language-server 0.36.2
Expand Down Expand Up @@ -90,11 +95,13 @@ if {${subport} ne ${name}} {
select.file ${filespath}/py${python.version}-pyls

notes "
To make the Python ${python.branch} version of python language server the one \
that is run when you execute the commands without a version suffix, e.g. \
To make the Python ${python.branch} version of python language server the one\
that is run when you execute the commands without a version suffix, e.g.\
'pyls', run:

port select --set ${select.group} [file tail ${select.file}]

This port is deprecated. Please consider using py${python.version}-python-lsp-server instead.
"

livecheck.type none
Expand Down
4 changes: 4 additions & 0 deletions python/py-python-jsonrpc-server/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

PortSystem 1.0
PortGroup python 1.0
PortGroup deprecated 1.0

# Deprecated in favor of python-lsp-jsonrpc
deprecated.upstream_support no

name py-python-jsonrpc-server
version 0.4.0
Expand Down
50 changes: 50 additions & 0 deletions python/py-python-lsp-jsonrpc/Portfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem 1.0
PortGroup python 1.0

name py-python-lsp-jsonrpc
version 1.0.0
revision 0

platforms darwin
supported_archs noarch
license MIT
maintainers {reneeotten @reneeotten} openmaintainer

description A Python server implementation of the JSON RPC 2.0 protocol
long_description Fork of the python-jsonrpc-server project, maintained by the Spyder \
IDE team and the community.

homepage https://github.com/python-lsp/python-lsp-jsonrpc

checksums rmd160 290706b2d58803c9d12c27207118271286c498d0 \
sha256 7bec170733db628d3506ea3a5288ff76aa33c70215ed223abdb0d95e957660bd \
size 10011

python.versions 36 37 38 39

if {${name} ne ${subport}} {
depends_build-append \
port:py${python.version}-setuptools

depends_lib-append port:py${python.version}-ujson

depends_test-append port:py${python.version}-pytest \
port:py${python.version}-mock

test.run yes
test.cmd py.test-${python.branch}
test.args -o addopts=''
test.target
test.env PYTHONPATH=${worksrcpath}/build/lib

post-destroot {
set docdir ${prefix}/share/doc/${subport}
xinstall -d ${destroot}${docdir}
xinstall -m 0644 -W ${worksrcpath} README.md \
LICENSE ${destroot}${docdir}
}

livecheck.type none
}
88 changes: 88 additions & 0 deletions python/py-python-lsp-server/Portfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem 1.0
PortGroup github 1.0
PortGroup python 1.0
PortGroup select 1.0

name py-python-lsp-server
github.setup python-lsp python-lsp-server 1.1.0 v
github.tarball_from archive
revision 0

categories-append devel
platforms darwin
supported_archs noarch
license MIT
maintainers {reneeotten @reneeotten} openmaintainer

description A Python implementation of the Language Server Protocol
long_description Fork of the python-language-server project, maintained by the Spyder \
IDE team and the community.

checksums rmd160 ed800ce49f963cd61cc239f3d1ecb8169af298ee \
sha256 987eb87073fca65bd1b0d32e408935f2146a98d33ae06d716d00969fc8c935b3 \
size 57851

python.versions 36 37 38 39

if {${subport} ne ${name}} {
depends_lib-append \
port:py${python.version}-autopep8 \
port:py${python.version}-codestyle \
port:py${python.version}-docstyle \
port:py${python.version}-flake8 \
port:py${python.version}-flake8-mccabe \
port:py${python.version}-jedi \
port:py${python.version}-pluggy \
port:py${python.version}-pyflakes \
port:py${python.version}-pylint \
port:py${python.version}-python-lsp-jsonrpc \
port:py${python.version}-rope \
port:py${python.version}-setuptools \
port:py${python.version}-ujson \
port:py${python.version}-yapf

patchfiles-append patch-pylsp_plugins_flake8_lint.py.diff \
patch-test_plugins_flake8_lint.py.diff

post-patch {
reinplace "s|@@FLAKE8_BIN@@|flake8-${python.branch}|g" ${worksrcpath}/pylsp/plugins/flake8_lint.py
reinplace "s|@@FLAKE8_BIN@@|flake8-${python.branch}|g" ${worksrcpath}/test/plugins/test_flake8_lint.py
reinplace "s|@@PYTHON_BIN@@|${python.bin}|g" ${worksrcpath}/pylsp/plugins/flake8_lint.py
}

depends_test-append \
port:py${python.version}-pytest \
port:py${python.version}-mock \
port:py${python.version}-flaky

test.run yes
test.cmd py.test-${python.branch}
test.args -o addopts=''
test.target
test.env PYTHONPATH=${worksrcpath}/build/lib

post-destroot {
set docdir ${prefix}/share/doc/${subport}
xinstall -d ${destroot}${docdir}
xinstall -m 0644 -W ${worksrcpath} README.md LICENSE \
${destroot}${docdir}
}

depends_run-append \
port:python-lsp-server_select

select.group python-lsp-server
select.file ${filespath}/py${python.version}-pylsp

notes "
To make the Python ${python.branch} version of python-lsp-server the one\
that is run when you execute the commands without a version suffix, e.g.\
'pylsp', run:

port select --set ${select.group} [file tail ${select.file}]
"

livecheck.type none
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- pylsp/plugins/flake8_lint.py
+++ pylsp/plugins/flake8_lint.py
@@ -54,7 +54,7 @@ def pylsp_lint(workspace, document):
log.debug("using flake8 with config: %s", opts['config'])

# Call the flake8 utility then parse diagnostics from stdout
- flake8_executable = settings.get('executable', 'flake8')
+ flake8_executable = settings.get('executable', '@@FLAKE8_BIN@@')

args = build_args(opts)
output = run_flake8(flake8_executable, args, document)
@@ -82,7 +82,7 @@ def run_flake8(flake8_executable, args, document):
p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) # pylint: disable=consider-using-with
except IOError:
log.debug("Can't execute %s. Trying with 'python -m flake8'", flake8_executable)
- cmd = ['python', '-m', 'flake8']
+ cmd = ['@@PYTHON_BIN@@', '-m', 'flake8']
cmd.extend(args)
p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) # pylint: disable=consider-using-with
(stdout, stderr) = p.communicate(document.source.encode())
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- test/plugins/test_flake8_lint.py
+++ test/plugins/test_flake8_lint.py
@@ -68,7 +68,7 @@ def test_flake8_config_param(workspace):
_name, doc = temp_document(DOC, workspace)
flake8_lint.pylsp_lint(workspace, doc)
(call_args,) = popen_mock.call_args[0]
- assert 'flake8' in call_args
+ assert '@@FLAKE8_BIN@@' in call_args
assert '--config={}'.format(flake8_conf) in call_args


@@ -126,7 +126,7 @@ exclude =
flake8_lint.pylsp_lint(workspace, doc)

call_args = popen_mock.call_args[0][0]
- assert call_args == ["flake8", "-", "--exclude=blah/,file_2.py"]
+ assert call_args == ["@@FLAKE8_BIN@@", "-", "--exclude=blah/,file_2.py"]

os.unlink(os.path.join(workspace.root_path, "setup.cfg"))

1 change: 1 addition & 0 deletions python/py-python-lsp-server/files/py36-pylsp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${frameworks_dir}/Python.framework/Versions/3.6/bin/pylsp
1 change: 1 addition & 0 deletions python/py-python-lsp-server/files/py37-pylsp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${frameworks_dir}/Python.framework/Versions/3.7/bin/pylsp
1 change: 1 addition & 0 deletions python/py-python-lsp-server/files/py38-pylsp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${frameworks_dir}/Python.framework/Versions/3.8/bin/pylsp
1 change: 1 addition & 0 deletions python/py-python-lsp-server/files/py39-pylsp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${frameworks_dir}/Python.framework/Versions/3.9/bin/pylsp
33 changes: 33 additions & 0 deletions python/python-lsp-server_select/Portfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem 1.0
PortGroup select 1.0

name python-lsp-server_select
version 0.1
revision 0
categories python
license BSD

maintainers nomaintainer

description common files for selecting default pylsp version
long_description \
This port installs files that allow 'port select' to be used to \
create links to the preferred default version of pylsp.

platforms darwin
supported_archs noarch

homepage https://www.macports.org/

distfiles

use_configure no
build {}
destroot {
select::install python-lsp-server ${filespath}/base
select::install python-lsp-server ${filespath}/none
}

livecheck.type none
1 change: 1 addition & 0 deletions python/python-lsp-server_select/files/base
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin/pylsp
1 change: 1 addition & 0 deletions python/python-lsp-server_select/files/none
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-