Skip to content

Commit 199dccd

Browse files
ZedThreegnikit
authored andcommitted
Use declarative setup.cfg; use setuptools_scm to set version
1 parent 0057f62 commit 199dccd

File tree

13 files changed

+90
-98
lines changed

13 files changed

+90
-98
lines changed

.github/workflows/docs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ jobs:
88
- uses: actions/checkout@v1
99
- uses: ammaraskar/sphinx-action@master
1010
with:
11+
pre-build-command: "pip install .[docs]"
1112
docs-folder: "docs/"
1213
- name: Deploy
1314
uses: peaceiris/actions-gh-pages@v3

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
architecture: x64
2323

2424
- name: Setup
25-
run: pip install -r test_requirements.txt
25+
run: pip install .[tests]
2626

2727
- name: Unittests
2828
run: pytest -v
@@ -41,7 +41,7 @@ jobs:
4141

4242
- name: Coverage report
4343
run: |
44-
pip install -r test_requirements.txt
44+
pip install .[tests]
4545
pytest --cov=fortls --cov-report=xml
4646
4747
- name: Upload coverage to Codecov

.github/workflows/python-publish.yml

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -40,37 +40,6 @@ jobs:
4040
python -m pip install --upgrade pip
4141
pip install build
4242
43-
# see: https://github.community/t/how-to-get-just-the-tag-name/16241/7
44-
- name: Get the version
45-
id: get_version
46-
shell: bash
47-
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
48-
49-
- name: Set global variables
50-
shell: bash
51-
run: |
52-
echo "VERSION=${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_ENV
53-
54-
- name: Set __version__
55-
shell: bash
56-
run: sed -i "s@\".*\"@\"${VERSION}\"@g" "fortls/_version.py"
57-
58-
# Disabled the workflow because it messes up with the Releases on GitHub
59-
# releases that use tags through force-push are marked as drafts
60-
# will have to manually update the versions in _version.py
61-
# - name: Commit the new version to dev
62-
# shell: bash
63-
# run: |
64-
# git config --global user.name 'gnikit'
65-
# git config --global user.email '[email protected]'
66-
# git fetch origin
67-
# git switch dev
68-
# git commit -S fortls/_version.py -m "Auto-Update version" -v
69-
# git push
70-
# git tag -f "${VERSION}"
71-
# git push --delete origin "${VERSION}"
72-
# git push origin "${VERSION}"
73-
7443
- name: Build package
7544
run: python -m build
7645

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
dist/
55
docs/_build/
66
docs/fortls_changes.md
7+
fortls/_version.py
78

89
.idea
910

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
sys.path.insert(0, os.path.abspath(".."))
1717

18-
from fortls._version import __version__ # noqa: E402
18+
from fortls import __version__ # noqa: E402
1919

2020
# Generate the agglomerated changes (from the CHANGELOG) between fortls
2121
# and the fortran-language-server project

fortls/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@
66
import sys
77
from multiprocessing import freeze_support
88

9-
from ._version import __version__
109
from .helper_functions import resolve_globs, only_dirs
1110
from .jsonrpc import JSONRPC2Connection, ReadWriter, path_from_uri
1211
from .langserver import LangServer
1312
from .parse_fortran import fortran_file, process_file
1413
from .interface import commandline_args
1514

15+
from .version import __version__
16+
17+
__all__ = ["__version__"]
18+
1619

1720
def error_exit(error_str: str):
1821
print(f"ERROR: {error_str}")

fortls/_version.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

fortls/interface.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import json
55
import sys
66

7-
from ._version import __version__
7+
from fortls.version import __version__
88

99

1010
class SetAction(argparse.Action):

fortls/langserver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from typing import Pattern
1212

1313
# Local modules
14-
from fortls._version import __version__
14+
from fortls.version import __version__
1515
from fortls.constants import (
1616
CLASS_TYPE_ID,
1717
FORTRAN_LITERAL,

fortls/version.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
try:
2+
from importlib.metadata import version, PackageNotFoundError
3+
except ModuleNotFoundError:
4+
from importlib_metadata import version, PackageNotFoundError
5+
try:
6+
__version__ = version(__package__)
7+
except PackageNotFoundError:
8+
from setuptools_scm import get_version
9+
10+
__version__ = get_version(root="..", relative_to=__file__)

0 commit comments

Comments
 (0)