Skip to content

Commit

Permalink
Merge pull request #44 from gnikit/feature/modernise-setup
Browse files Browse the repository at this point in the history
Feature/modernise setup
  • Loading branch information
gnikit authored Feb 5, 2022
2 parents 0057f62 + dc59da7 commit 6306f43
Show file tree
Hide file tree
Showing 24 changed files with 139 additions and 141 deletions.
4 changes: 3 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[run]
dynamic_context = test_function
omit = fortls/__init__.py
omit =
fortls/__init__.py
fortls/version.py

[report]
exclude_lines =
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: ammaraskar/sphinx-action@master
- uses: actions/checkout@v2
- uses: sphinx-toolbox/sphinx-action@master
with:
pre-build-command: "pip install .[docs]"
docs-folder: "docs/"
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
architecture: x64

- name: Setup
run: pip install -r test_requirements.txt
run: pip install .[dev]

- name: Unittests
run: pytest -v
Expand All @@ -41,7 +41,7 @@ jobs:

- name: Coverage report
run: |
pip install -r test_requirements.txt
pip install .[dev]
pytest --cov=fortls --cov-report=xml
- name: Upload coverage to Codecov
Expand Down
43 changes: 0 additions & 43 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,6 @@ jobs:

steps:
- uses: actions/checkout@v2

# # This is a temporary workaround until GitHub Actions start natively
# # supporting signed commits like they should
# - name: Import GPG key
# id: import_gpg
# uses: crazy-max/ghaction-import-gpg@v4
# with:
# gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
# passphrase: ${{ secrets.PASSPHRASE }}
# git_user_signingkey: true
# git_commit_gpgsign: true

- name: Set up Python
uses: actions/setup-python@v2
with:
Expand All @@ -40,37 +28,6 @@ jobs:
python -m pip install --upgrade pip
pip install build
# see: https://github.community/t/how-to-get-just-the-tag-name/16241/7
- name: Get the version
id: get_version
shell: bash
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}

- name: Set global variables
shell: bash
run: |
echo "VERSION=${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_ENV
- name: Set __version__
shell: bash
run: sed -i "s@\".*\"@\"${VERSION}\"@g" "fortls/_version.py"

# Disabled the workflow because it messes up with the Releases on GitHub
# releases that use tags through force-push are marked as drafts
# will have to manually update the versions in _version.py
# - name: Commit the new version to dev
# shell: bash
# run: |
# git config --global user.name 'gnikit'
# git config --global user.email '[email protected]'
# git fetch origin
# git switch dev
# git commit -S fortls/_version.py -m "Auto-Update version" -v
# git push
# git tag -f "${VERSION}"
# git push --delete origin "${VERSION}"
# git push origin "${VERSION}"

- name: Build package
run: python -m build

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
.vscode
*.egg-info
dist/
build/
docs/_build/
docs/fortls_changes.md
fortls/_version.py

.idea

Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# CHANGELONG

## 2.2.0

### Added

- Added semantic versioning with `setuptools_scm`
([gnikit/fortls#34](https://github.com/gnikit/fortls/issues/34))

### Changed

- Changes from `setup.py` to `setup.toml` and `pyproject.toml`
([gnikit/fortls#33](https://github.com/gnikit/fortls/issues/33))
- Changed documentation CI to up to date action
- Formatted Python imports with `isort`

## 2.1.2

### Fixed
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ potentially subject to change.
pip install fortls
```

>**Warning**: it is not recommended having `fortls` and `fortran-language-server`
>simultaneously installed, since they use the same binary name. If you are having trouble
>getting `fortls` to work try uninstalling `fortran-language-server` and reinstalling `fortls`.
>
>```sh
>pip uninstall fortran-language-server
>pip install fortls --upgrade
>```
## Settings
`fortls` can be configured through both the command line e.g.
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

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

from fortls._version import __version__ # noqa: E402
from fortls import __version__ # noqa: E402

# Generate the agglomerated changes (from the CHANGELOG) between fortls
# and the fortran-language-server project
Expand Down
8 changes: 8 additions & 0 deletions docs/fortls.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ fortls.regex\_patterns module
:undoc-members:
:show-inheritance:

fortls.version module
---------------------

.. automodule:: fortls.version
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
fortls
fortls -- Fortran Language Server
==================================

.. toctree::
Expand Down
7 changes: 0 additions & 7 deletions docs/requirements.txt

This file was deleted.

8 changes: 5 additions & 3 deletions fortls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
import sys
from multiprocessing import freeze_support

from ._version import __version__
from .helper_functions import resolve_globs, only_dirs
from .helper_functions import only_dirs, resolve_globs
from .interface import commandline_args
from .jsonrpc import JSONRPC2Connection, ReadWriter, path_from_uri
from .langserver import LangServer
from .parse_fortran import fortran_file, process_file
from .interface import commandline_args
from .version import __version__

__all__ = ["__version__"]


def error_exit(error_str: str):
Expand Down
1 change: 0 additions & 1 deletion fortls/_version.py

This file was deleted.

2 changes: 1 addition & 1 deletion fortls/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
import logging
import sys

PY3K = sys.version_info >= (3, 0)

Expand Down
2 changes: 1 addition & 1 deletion fortls/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import json
import sys

from ._version import __version__
from fortls.version import __version__


class SetAction(argparse.Action):
Expand Down
2 changes: 1 addition & 1 deletion fortls/langserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from typing import Pattern

# Local modules
from fortls._version import __version__
from fortls.constants import (
CLASS_TYPE_ID,
FORTRAN_LITERAL,
Expand Down Expand Up @@ -56,6 +55,7 @@
SQ_STRING_REGEX,
src_file_exts,
)
from fortls.version import __version__

# Global regexes
# TODO: I think this can be replaced by fortls.regex_patterns type & class
Expand Down
2 changes: 1 addition & 1 deletion fortls/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import copy
import os
import re
from typing import Dict, NamedTuple, List, Set, Pattern
from dataclasses import dataclass
from typing import Dict, List, NamedTuple, Pattern, Set

from fortls.constants import (
ASSOC_TYPE_ID,
Expand Down
10 changes: 10 additions & 0 deletions fortls/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
try:
from importlib.metadata import PackageNotFoundError, version
except ModuleNotFoundError:
from importlib_metadata import PackageNotFoundError, version
try:
__version__ = version(__package__)
except PackageNotFoundError:
from setuptools_scm import get_version

__version__ = get_version(root="..", relative_to=__file__)
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[build-system]
requires = [
"setuptools >= 45",
"wheel",
"setuptools_scm[toml] >= 6.2",
"setuptools_scm_git_archive",
]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "fortls/_version.py"
58 changes: 57 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,59 @@
[metadata]
name = fortls
url = https://github.com/gnikit/fortls
author = Giannis Nikiteas
author_email = [email protected]
description = fortls - Fortran Language Server
long_description = file: README.md
long_description_content_type = text/markdown
license = MIT
classifiers =
Development Status :: 4 - Beta
Intended Audience :: Developers
Intended Audience :: Science/Research
License :: OSI Approved :: MIT License
Natural Language :: English
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Fortran
Operating System :: Microsoft :: Windows
Operating System :: POSIX
Operating System :: Unix
Operating System :: MacOS
project_urls =
Source = https://github.com/gnikit/fortls
Tracker = https://github.com/gnikit/fortls/issues

[options]
packages = find:
python_requires = >= 3.7
install_requires =
importlib-metadata; python_version < "3.8"

[options.package_data]
fortls = *.json

[options.entry_points]
console_scripts =
fortls = fortls.__init__:main

[options.extras_require]
dev =
pytest >= 5.4.3
pytest-cov >= 2.12.1
black
isort
docs =
sphinx ~= 4.0.0
sphinx_rtd_theme
sphinx-argparse
sphinx-autodoc-typehints
myst-parser

[flake8]
max-line-length = 88
extend-ignore = E203,E722
extend-ignore = E203, E722
Loading

0 comments on commit 6306f43

Please sign in to comment.