Skip to content

Commit c24bbfa

Browse files
committed
Moved the metadata from setup.py to setup.cfg
Added pyproject.toml Replaced reading of the version from `_version` file with reading it from Version Control System and writing it into the file. Also fixed a bug with incorrect content of `__all__` in `__main__.py`
1 parent c14a95e commit c24bbfa

File tree

6 files changed

+114
-101
lines changed

6 files changed

+114
-101
lines changed

Diff for: .gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# autogenerated version file
2+
/pylsp/_version.py
3+
14
# Byte-compiled / optimized / DLL files
25
__pycache__/
36
*.py[cod]

Diff for: pylsp/__init__.py

+18-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,29 @@
33

44
import os
55
import pluggy
6+
from . import _version
67
from ._version import __version__
78

9+
10+
def convert_version_info(version: str) -> (int, ..., str):
11+
version_info = version.split(".")
12+
for i, v in enumerate(version_info):
13+
try:
14+
version_info[i] = int(v)
15+
except ValueError:
16+
version_info[i] = v.split("+")[0]
17+
version_info = version_info[: i + 1]
18+
break
19+
20+
return tuple(version_info)
21+
22+
23+
_version.VERSION_INFO = convert_version_info(__version__)
24+
825
PYLSP = 'pylsp'
926
IS_WIN = os.name == 'nt'
1027

1128
hookspec = pluggy.HookspecMarker(PYLSP)
1229
hookimpl = pluggy.HookimplMarker(PYLSP)
1330

14-
__all__ = [__version__]
31+
__all__ = ("__version__",)

Diff for: pylsp/_version.py

-7
This file was deleted.

Diff for: pyproject.toml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[build-system]
2+
requires = ["setuptools>=44", "wheel", "setuptools_scm[toml]>=3.4.3"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[tool.setuptools_scm]
6+
write_to = "pylsp/_version.py"
7+
write_to_template = "__version__ = \"{version}\"\n" # VERSION_INFO is populated in __main__

Diff for: setup.cfg

+79
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,89 @@
1+
[metadata]
2+
name = python-lsp-server
3+
author = Python Language Server Contributors
4+
description = Python Language Server for the Language Server Protocol
5+
url = https://github.com/python-lsp/python-lsp-server
6+
long_description = file: README.md
7+
long_description_content_type = text/markdown
8+
9+
[options]
10+
packages = find:
11+
python_requires = >=3.7
12+
install_requires =
13+
jedi>=0.17.2,<0.19.0
14+
python-lsp-jsonrpc>=1.0.0
15+
pluggy
16+
ujson>=3.0.0
17+
setuptools>=39.0.0
18+
setup_requires = setuptools>=44; wheel; setuptools_scm[toml]>=3.4.3
19+
20+
[options.packages.find]
21+
exclude = contrib; docs; test; test.*; test.plugins; test.plugins.*
22+
23+
[options.extras_require]
24+
all =
25+
autopep8>=1.6.0,<1.7.0
26+
flake8>=4.0.0,<4.1.0
27+
mccabe>=0.6.0,<0.7.0
28+
pycodestyle>=2.8.0,<2.9.0
29+
pydocstyle>=2.0.0
30+
pyflakes>=2.4.0,<2.5.0
31+
pylint>=2.5.0
32+
rope>=0.10.5
33+
yapf
34+
autopep8 = autopep8>=1.6.0,<1.7.0
35+
flake8 = flake8>=4.0.0,<4.1.0
36+
mccabe = mccabe>=0.6.0,<0.7.0
37+
pycodestyle = pycodestyle>=2.8.0,<2.9.0
38+
pydocstyle = pydocstyle>=2.0.0
39+
pyflakes = pyflakes>=2.4.0,<2.5.0
40+
pylint = pylint>=2.5.0,<2.10.0
41+
rope = rope>0.10.5
42+
yapf = yapf
43+
test =
44+
pylint>=2.5.0
45+
pytest
46+
pytest-cov
47+
coverage
48+
numpy
49+
pandas
50+
matplotlib
51+
pyqt5
52+
flaky
53+
54+
[options.entry_points]
55+
console_scripts = pylsp = pylsp.__main__:main
56+
pylsp =
57+
autopep8 = pylsp.plugins.autopep8_format
58+
folding = pylsp.plugins.folding
59+
flake8 = pylsp.plugins.flake8_lint
60+
jedi_completion = pylsp.plugins.jedi_completion
61+
jedi_definition = pylsp.plugins.definition
62+
jedi_hover = pylsp.plugins.hover
63+
jedi_highlight = pylsp.plugins.highlight
64+
jedi_references = pylsp.plugins.references
65+
jedi_rename = pylsp.plugins.jedi_rename
66+
jedi_signature_help = pylsp.plugins.signature
67+
jedi_symbols = pylsp.plugins.symbols
68+
mccabe = pylsp.plugins.mccabe_lint
69+
preload = pylsp.plugins.preload_imports
70+
pycodestyle = pylsp.plugins.pycodestyle_lint
71+
pydocstyle = pylsp.plugins.pydocstyle_lint
72+
pyflakes = pylsp.plugins.pyflakes_lint
73+
pylint = pylsp.plugins.pylint_lint
74+
rope_completion = pylsp.plugins.rope_completion
75+
rope_rename = pylsp.plugins.rope_rename
76+
yapf = pylsp.plugins.yapf_format
77+
178
[pycodestyle]
279
ignore = E226, E722, W504
380
max-line-length = 120
481
exclude = test/plugins/.ropeproject,test/.ropeproject
582

83+
684
[tool:pytest]
785
testpaths = test
886
addopts =
987
--cov-report html --cov-report term --junitxml=pytest.xml
1088
--cov pylsp --cov test
89+

Diff for: setup.py

+7-93
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,12 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
# Copyright 2017-2020 Palantir Technologies, Inc.
44
# Copyright 2021- Python Language Server Contributors.
55

6-
import ast
7-
import os
8-
from setuptools import find_packages, setup
6+
from setuptools import setup, find_packages
97

10-
HERE = os.path.abspath(os.path.dirname(__file__))
11-
12-
13-
def get_version(module='pylsp'):
14-
"""Get version."""
15-
with open(os.path.join(HERE, module, '_version.py'), 'r') as f:
16-
data = f.read()
17-
lines = data.split('\n')
18-
for line in lines:
19-
if line.startswith('VERSION_INFO'):
20-
version_tuple = ast.literal_eval(line.split('=')[-1].strip())
21-
version = '.'.join(map(str, version_tuple))
22-
break
23-
return version
24-
25-
26-
README = open('README.md', 'r').read()
27-
28-
install_requires = [
29-
'jedi>=0.17.2,<0.19.0',
30-
'python-lsp-jsonrpc>=1.0.0',
31-
'pluggy',
32-
'ujson>=3.0.0',
33-
'setuptools>=39.0.0'
34-
]
35-
36-
setup(
37-
name='python-lsp-server',
38-
version=get_version(),
39-
description='Python Language Server for the Language Server Protocol',
40-
long_description=README,
41-
long_description_content_type='text/markdown',
42-
url='https://github.com/python-lsp/python-lsp-server',
43-
author='Python Language Server Contributors',
44-
packages=find_packages(exclude=['contrib', 'docs', 'test', 'test.*']),
45-
install_requires=install_requires,
46-
python_requires='>=3.7',
47-
extras_require={
48-
'all': [
49-
'autopep8>=1.6.0,<1.7.0',
50-
'flake8>=4.0.0,<4.1.0',
51-
'mccabe>=0.6.0,<0.7.0',
52-
'pycodestyle>=2.8.0,<2.9.0',
53-
'pydocstyle>=2.0.0',
54-
'pyflakes>=2.4.0,<2.5.0',
55-
'pylint>=2.5.0',
56-
'rope>=0.10.5',
57-
'yapf',
58-
],
59-
'autopep8': ['autopep8>=1.6.0,<1.7.0'],
60-
'flake8': ['flake8>=4.0.0,<4.1.0'],
61-
'mccabe': ['mccabe>=0.6.0,<0.7.0'],
62-
'pycodestyle': ['pycodestyle>=2.8.0,<2.9.0'],
63-
'pydocstyle': ['pydocstyle>=2.0.0'],
64-
'pyflakes': ['pyflakes>=2.4.0,<2.5.0'],
65-
'pylint': ['pylint>=2.5.0'],
66-
'rope': ['rope>0.10.5'],
67-
'yapf': ['yapf'],
68-
'test': ['pylint>=2.5.0', 'pytest', 'pytest-cov', 'coverage',
69-
'numpy', 'pandas', 'matplotlib', 'pyqt5', 'flaky'],
70-
},
71-
entry_points={
72-
'console_scripts': [
73-
'pylsp = pylsp.__main__:main',
74-
],
75-
'pylsp': [
76-
'autopep8 = pylsp.plugins.autopep8_format',
77-
'folding = pylsp.plugins.folding',
78-
'flake8 = pylsp.plugins.flake8_lint',
79-
'jedi_completion = pylsp.plugins.jedi_completion',
80-
'jedi_definition = pylsp.plugins.definition',
81-
'jedi_hover = pylsp.plugins.hover',
82-
'jedi_highlight = pylsp.plugins.highlight',
83-
'jedi_references = pylsp.plugins.references',
84-
'jedi_rename = pylsp.plugins.jedi_rename',
85-
'jedi_signature_help = pylsp.plugins.signature',
86-
'jedi_symbols = pylsp.plugins.symbols',
87-
'mccabe = pylsp.plugins.mccabe_lint',
88-
'preload = pylsp.plugins.preload_imports',
89-
'pycodestyle = pylsp.plugins.pycodestyle_lint',
90-
'pydocstyle = pylsp.plugins.pydocstyle_lint',
91-
'pyflakes = pylsp.plugins.pyflakes_lint',
92-
'pylint = pylsp.plugins.pylint_lint',
93-
'rope_completion = pylsp.plugins.rope_completion',
94-
'rope_rename = pylsp.plugins.rope_rename',
95-
'yapf = pylsp.plugins.yapf_format'
96-
]
97-
},
98-
)
8+
if __name__ == "__main__":
9+
setup(
10+
name="python-lsp-server", # to allow GitHub dependency tracking work
11+
packages=find_packages(exclude=["contrib", "docs", "test", "test.*"]), # https://github.com/pypa/setuptools/issues/2688
12+
)

0 commit comments

Comments
 (0)