Skip to content

Commit b65f3f1

Browse files
committed
Moved the metadata into setup.cfg
Added pyproject.toml Replaced fetching version from a file with fetching a version from version control system tags. Also fixed a bug with incorrect content of `__all__` in `__main__.py`
1 parent 8aee003 commit b65f3f1

File tree

6 files changed

+52
-44
lines changed

6 files changed

+52
-44
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# autogenerated version file
2+
/pylsp_jsonrpc/_version.py
3+
14
# Byte-compiled / optimized / DLL files
25
__pycache__/
36
*.py[cod]

pylsp_jsonrpc/__init__.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
# Copyright 2017-2020 Palantir Technologies, Inc.
22
# Copyright 2021- Python Language Server Contributors.
33

4+
from . import _version
45
from ._version import __version__
56

6-
__all__ = [__version__]
7+
def convertVersionInfo(version: str) -> (int, ..., str):
8+
VERSION_INFO = version.split(".")
9+
for i in range(len(VERSION_INFO)):
10+
try:
11+
VERSION_INFO[i] = int(VERSION_INFO[i])
12+
except ValueError:
13+
VERSION_INFO[i] = VERSION_INFO[i].split("+")[0]
14+
VERSION_INFO = VERSION_INFO[:i + 1]
15+
break
16+
17+
return tuple(VERSION_INFO)
18+
19+
_version.VERSION_INFO = convertVersionInfo(__version__)
20+
21+
__all__ = ("__version__",)

pylsp_jsonrpc/_version.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

pyproject.toml

Lines changed: 7 additions & 0 deletions
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_jsonrpc/_version.py"
7+
write_to_template = "__version__ = \"{version}\"\n" # VERSION_INFO is populated in __main__

setup.cfg

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
[metadata]
2+
name = python-lsp-jsonrpc
3+
author = Python Language Server Contributors
4+
description = JSON RPC 2.0 server library
5+
url = https://github.com/python-lsp/python-lsp-jsonrpc
6+
long_description = file: README.md
7+
long_description_content_type = text/markdown
8+
9+
10+
[options]
11+
packages = find:
12+
setup_requires = setuptools>=44; wheel; setuptools_scm[toml]>=3.4.3
13+
install_requires = ujson>=3.0.0
14+
15+
[options.packages.find]
16+
exclude = contrib; docs; test; test.*
17+
18+
[options.extras_require]
19+
test =
20+
pylint
21+
pycodestyle
22+
pyflakes
23+
pytest
24+
pytest-cov
25+
coverage
126

227
[pycodestyle]
328
ignore = E226, E722, W504

setup.py

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,6 @@
33
# Copyright 2017-2020 Palantir Technologies, Inc.
44
# Copyright 2021- Python Language Server Contributors.
55

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

10-
HERE = os.path.abspath(os.path.dirname(__file__))
11-
12-
13-
def get_version(module='pylsp_jsonrpc'):
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-
29-
setup(
30-
name='python-lsp-jsonrpc',
31-
version=get_version(),
32-
description='JSON RPC 2.0 server library',
33-
long_description=README,
34-
long_description_content_type='text/markdown',
35-
url='https://github.com/python-lsp/python-lsp-jsonrpc',
36-
author='Python Language Server Contributors',
37-
packages=find_packages(exclude=['contrib', 'docs', 'test']),
38-
install_requires=[
39-
'ujson>=3.0.0',
40-
],
41-
extras_require={
42-
'test': ['pylint', 'pycodestyle', 'pyflakes', 'pytest',
43-
'pytest-cov', 'coverage'],
44-
},
45-
)
8+
setup(packages=find_packages(exclude=['contrib', 'docs', 'test']))

0 commit comments

Comments
 (0)