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

Conversation

ZedThree
Copy link

This does two related things:

  1. switch to using the more modern declarative setup.cfg over setup.py
  2. use setuptools_scm to set the version automatically

setup.py is slowly getting phased out in favour of setup.cfg. The main benefit is there's much less need for any kind of code, which means there's no chicken-and-egg problem with building the package -- this actually isn't a problem with fortls because it has no third-party dependencies.

setuptools_scm is really nice because it completely handles setting the version number. Running fortls --version on this commit now reports 2.0.2.dev7+g98adb50 -- this encodes how many commits since the previous release, along with the exact commit hash, while still being compatible with semver.

@ZedThree
Copy link
Author

This partly replaces #31

@gnikit
Copy link
Member

gnikit commented Jan 25, 2022

I will have a look but I would try and squeeze one thing per PR when it comes to the build system. Also, I am not so sure what happens to the documentation deployment with this, since it peaks up the version from _version.py which (from my understanding) will not have been generated unless we build the extension. The states between github actions do not persist

Copy link
Member

@gnikit gnikit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job overall. I am slightly concerned about the documentation generation.
I will allow it to run on the CI and see how that goes.

@codecov
Copy link

codecov bot commented Jan 25, 2022

Codecov Report

Merging #32 (1dc53de) into dev (0057f62) will decrease coverage by 0.08%.
The diff coverage is 54.54%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev      #32      +/-   ##
==========================================
- Coverage   81.02%   80.94%   -0.09%     
==========================================
  Files          10       10              
  Lines        4290     4298       +8     
==========================================
+ Hits         3476     3479       +3     
- Misses        814      819       +5     
Impacted Files Coverage Δ
fortls/version.py 44.44% <44.44%> (ø)
fortls/interface.py 100.00% <100.00%> (ø)
fortls/langserver.py 71.85% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0057f62...1dc53de. Read the comment docs.

* dev:
  Update changelog
  Add additional shields
  Disable GPG signing of auto-commit
  Increments version
  Updates docs with proper json syntax
  Update CHANGELOG.md
  Fixes multiprocess bug
  Simplifies uri file and swaps os to Path
  Simplify unittest caller
  Preserves paths when using shlex
  Makes unittest input to be a list
  Makes unittest use Path instead of os.path
  Adds Windows CI
  Improves coverage
  Further removal of fstrings
  Imports commit version to doc
  Improve code structure
  Improves code style
  Improves test case paths
  Disable the incrementation of the version
Guards against future package renames
Ensures version is correct
@ZedThree
Copy link
Author

I've added .readthedocs.yaml in order to tell it to pip install the package and the extra requirements

@ZedThree
Copy link
Author

I might suggest also replacing the docs Github Action with using readthedocs directly on PRs: https://docs.readthedocs.io/en/stable/pull-requests.html

@gnikit
Copy link
Member

gnikit commented Jan 27, 2022

About the docs. I don't see a compelling reason to change/add to GitHub Pages readthedocs for this project. From my understanding readthedocs, as proposed here, would replace gh-pages. The existing Actions implementations work robustly with no maintenance required, the same is not true for the .readthedocs.yaml. There is no easy way to simulate deployment and that hardcoded Python version, looks exactly like the thing we will forget to change in a future upgrade. Implementing the proposed changes would just increase maintenance time substantially.

I would resist the urge to make any more changes, other than setup.py, setup.cfg and pyproject.toml (and versions). You can open a separate issue for the readthedocs and what improvements it adds to the documentation (I am not overly familiar with it's features).

FYI the sphinx docs Action is the recommended route according to the documentation. When ammaraskar/sphinx-action stops using requirements.txt, that would be a good time for us to switch too or basically whatever sphinx says is the prefered way to deploy on gh-pages.

@ZedThree
Copy link
Author

Ah, apologies, I had assumed the project was already using readthedocs and the GHA here was just for testing, so I was just intending to add some config! I'll revert that commit and add a pre-build-command: pip install .[docs] to the action.

@gnikit
Copy link
Member

gnikit commented Jan 27, 2022

No worries, I use the sphinx readdocs theme (which I might change to puro) but not readocs itself.

add a pre-build-command: pip install .[docs] to the action.

The Action runs from within docs directory so you will have to do a relative import. That said I don't see a reason why change the docs requirements.txt. To build docs you still need to cd into docs and call make html so I would keep all the dependencies within one dir.

@ZedThree
Copy link
Author

The docs action should work now! It turns out the action hasn't been maintained for some time, and it has a few bugs. Notably that the image it's based on is very out of date which uses a version of sphinx incompatible with some of the docs dependencies. Switching to the sphinx-toolbox fork, and bumping the required version of sphinx fixes that.

While cd docs; make html will still work, with all of the dependencies now specified in setup.cfg, it's now possible to do the following in a fresh environment:

pip install -e .[tests,doc]   # Install all dependencies for building, running, testing, and docs
pytest --cov=fortls           # Run tests
python setup.py build_sphinx  # Build dosc

@gnikit
Copy link
Member

gnikit commented Jan 28, 2022

Let me know when you are happy with this

@gnikit
Copy link
Member

gnikit commented Feb 4, 2022

@ZedThree is this ready to merge? If so could you enable the option for me to push changes to the branch, otherwise I will have to cherry-pick into another PR. Either way is fine by me

* dev:
  Create codeql-analysis.yml
  Increments version
  Do not include debug cmd arguments
  Adds unittest for autocompletion as snippets
  Updates formatting for fr strings
  Create FUNDING.yml
  Fix text completion for procedures
@ZedThree
Copy link
Author

ZedThree commented Feb 4, 2022

Yep, ready to merge. I've merged in dev to fix the conflicts. It looks like I can't give you push access because the fork is from an organisation rather than a user account.

@gnikit
Copy link
Member

gnikit commented Feb 4, 2022

Okay don't worry I will cherry-pick your commits into another PR then. BTW I was thinking something like this about setuptools_scm_git_archive since we will only be making use of it when installing straight from the repo

@gnikit
Copy link
Member

gnikit commented Feb 5, 2022

Fixed in #44

@gnikit gnikit closed this Feb 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use setuptools_scm for versioning Replace setup.py with pyproject.toml and setup.cfg
2 participants