Skip to content

Remove docs dependency on setuptools_scm #989

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 8 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
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ repos:
- sphinx
- types-docutils
- types-PyYAML
- types-setuptools
args:
- --python-version=3.10
pass_filenames: false
Expand All @@ -179,6 +180,7 @@ repos:
- types-dataclasses # Needed for checking py3.6 with a later interpreter
- types-docutils
- types-PyYAML
- types-setuptools
args:
- --python-version=3.6

Expand Down
27 changes: 11 additions & 16 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
# Ref: https://www.sphinx-doc.org/en/master/usage/configuration.html
"""Configuration file for the Sphinx docs."""

from functools import partial

from importlib.metadata import version as get_version
from pathlib import Path
from sys import path

from setuptools_scm import get_version


# -- Path setup --------------------------------------------------------------

PROJECT_ROOT_DIR = Path(__file__).parents[1].resolve()
get_scm_version = partial(get_version, root=PROJECT_ROOT_DIR)

# Make in-tree extension importable in non-tox setups/envs, like RTD.
# Refs:
Expand All @@ -36,23 +34,20 @@
author = f"{project} project contributors"
copyright = author # pylint:disable=redefined-builtin

# fmt: off
NAVIGATOR_VERSION = get_version("ansible_navigator")

# The short X.Y version
version = ".".join(
Copy link
Member

Choose a reason for hiding this comment

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

This is a Sphinx setting. Don't lose it. Although, I'm still against breaking what setuptools-scm provides. If you want to reuse the installed dist metadata, you'd have to (1) integrate setuptools-scm into packaging first and then (2) somehow solve the self-reinstallation on every local build in an optimal way (without tox -r).

get_scm_version(
local_scheme="no-local-version",
).split(".")[:3],
)
# including .Z, resulting in the X.Y.Z version
version = ".".join(NAVIGATOR_VERSION.split(".")[:3])

# The full version, including alpha/beta/rc tags
release = get_scm_version()
release = NAVIGATOR_VERSION

rst_epilog = f"""
.. |project| replace:: {project}
.. |release_l| replace:: ``v{release}``
"""


# -- General configuration ---------------------------------------------------


Expand Down Expand Up @@ -277,8 +272,8 @@
"substitution", # replace common ASCII shortcuts into their symbols
]
myst_substitutions = {
"project": project,
"release": release,
"release_l": f"`v{release}`",
"version": version,
"project": project,
"release": release,
"release_l": f"`v{release}`",
"version": version,
}
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
name = "Contributor-facing changes"
showcontent = true

[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.2"]
Copy link
Member

Choose a reason for hiding this comment

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

wheel shouldn't be in this list, setuptools' PEP 517 build backend auto-adds it already.

Copy link
Member

Choose a reason for hiding this comment

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

(and of course move this to a separate PR as well)

Copy link
Member

Choose a reason for hiding this comment

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

There's a separate issue for that so don't forget to link it too: #553.

Copy link
Member

Choose a reason for hiding this comment

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

See also: #554


[tool.black]
line-length = 100
Expand Down Expand Up @@ -95,3 +97,5 @@ skip_glob = ["tests/fixtures/common/collections*"] # Skip ansible content due to

[tool.pylint.format]
max-line-length = 100

[tool.setuptools_scm]
Copy link
Member

Choose a reason for hiding this comment

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

This whole dist packaging setup refactoring should go into a separate PR as it's not related to docs. It could be accepted separately while the rest of this PR is still in a state that has to be rejected.

Copy link
Member

Choose a reason for hiding this comment

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

(side note: that separate PR should probably also make use of the write_to setting)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It can't yet. The _version file contains more than just the package version.

Copy link
Member

@webknjaz webknjaz Feb 21, 2022

Choose a reason for hiding this comment

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

No, you can do that now. Just don't point it at an existing file. Instead, point it at a gitignored _scm_version.py that you'd import from the _version.py.
Example: https://github.com/sphinx-contrib/sphinxcontrib-towncrier/blob/532e343/pyproject.toml#L16 + https://github.com/sphinx-contrib/sphinxcontrib-towncrier/blob/532e343/src/sphinxcontrib/towncrier/_version.py#L5.

P.S. Also, the same approach is used in ansible-pylibssh.

Copy link
Member

Choose a reason for hiding this comment

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

Pro tip: create a _scm_version.pyi to take care of typing.