Skip to content

Use declarative setup.cfg; use setuptools_scm to set version #32

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

Closed
wants to merge 18 commits into from
Closed
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
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 .[tests]

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

- name: Coverage report
run: |
pip install -r test_requirements.txt
pip install .[tests]
pytest --cov=fortls --cov-report=xml

- name: Upload coverage to Codecov
Expand Down
31 changes: 0 additions & 31 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,37 +40,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 'giannis.nikiteas@gmail.com'
# 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
dist/
docs/_build/
docs/fortls_changes.md
fortls/_version.py

.idea

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
5 changes: 4 additions & 1 deletion fortls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
import sys
from multiprocessing import freeze_support

from ._version import __version__
from .helper_functions import resolve_globs, only_dirs
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):
print(f"ERROR: {error_str}")
Expand Down
1 change: 0 additions & 1 deletion fortls/_version.py

This file was deleted.

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,7 @@
from typing import Pattern

# Local modules
from fortls._version import __version__
from fortls.version import __version__
from fortls.constants import (
CLASS_TYPE_ID,
FORTRAN_LITERAL,
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 version, PackageNotFoundError
except ModuleNotFoundError:
from importlib_metadata import version, PackageNotFoundError
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"
57 changes: 56 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,58 @@
[metadata]
name = fortls
url = https://github.com/gnikit/fortls
author = Giannis Nikiteas
author_email = giannis.nikiteas@gmail.com
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]
tests =
pytest >= 5.4.3
pytest-cov >= 2.12.1
black
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
61 changes: 2 additions & 59 deletions setup.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,6 @@

"""Builds the Fortran Language Server - dev
"""
import pathlib
import setuptools

from setuptools import find_packages, setup

from fortls import __version__

# The directory containing this file
HERE = pathlib.Path(__file__).resolve().parent

# The text of the README file is used as a description
README = (HERE / "README.md").read_text()

NAME = "fortls"

setup(
name=NAME,
version=__version__,
url="https://github.com/gnikit/fortran-language-server",
author="Giannis Nikiteas",
author_email="giannis.nikiteas@gmail.com",
description="fortls - Fortran Language Server",
long_description=README,
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",
],
# You can just specify the packages manually here if your project is
# simple. Or you can use find_packages().
packages=find_packages(exclude=["contrib", "docs", "test"]),
package_data={"fortls": ["*.json"]},
# https://packaging.python.org/en/latest/discussions/install-requires-vs-requirements/
install_requires=[
'future; python_version < "3"',
'argparse; python_version < "2.7" or python_version in "3.0, 3.1"',
],
# To provide executable scripts, use entry points in preference to the
# "scripts" keyword. Entry points provide cross-platform support and allow
# pip to create the appropriate form of executable for the target platform.
entry_points={
"console_scripts": [
"fortls = fortls.__init__:main",
]
},
)
setuptools.setup()