Skip to content

Commit

Permalink
build sdist need to recreate generated files
Browse files Browse the repository at this point in the history
- fix(entrypoints): remove support for --version option
- refactor: add module constants_maybe. Move constants.__version_app constants.__url__
- ci(tox-test): remove py314
- ci: build sdist to run build plugins to recreate generated files
  • Loading branch information
msftcangoblowm committed Aug 5, 2024
1 parent b2b82a9 commit 7525618
Show file tree
Hide file tree
Showing 17 changed files with 129 additions and 51 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ jobs:
- name: "Install dependencies"
run: |
python -m pip install -r requirements/tox$LOCK_SUFFIX
python -m pip install -r requirements/prod$LOCK_SUFFIX
python -m pip install -r requirements/kit$LOCK_SUFFIX
# Create generated files: version file and .lnk files. sdist tarball ignored
- name: "Build sdist to run plugins. Creates generated files"
env:
SET_LOCK: ${{ vars.DRAINSWAMP_SET_LOCK }}
run: |
set -xe
echo "python -m build -C--kind='current' -C--set-lock='$SET_LOCK'"
python -m build -C--kind="current" -C--set-lock="$SET_LOCK"
- name: "Tox lint"
run: |
Expand All @@ -74,6 +85,17 @@ jobs:
# Runs on 3.9, but hashes supported by pip-tools is
# not supported by setuptools. So don't expect hashes
python -m pip install -r requirements/tox$LOCK_SUFFIX
python -m pip install -r requirements/prod$LOCK_SUFFIX
python -m pip install -r requirements/kit$LOCK_SUFFIX
# Create generated files: version file and .lnk files. sdist tarball ignored
- name: "Build sdist to run plugins. Create generated files"
env:
SET_LOCK: ${{ vars.DRAINSWAMP_SET_LOCK }}
run: |
set -xe
echo "python -m build -C--kind='current' -C--set-lock='$SET_LOCK'"
python -m build -C--kind="current" -C--set-lock="$SET_LOCK"
- name: "Tox mypy"
run: |
Expand Down Expand Up @@ -105,6 +127,17 @@ jobs:
run: |
set -xe
python -m pip install -r requirements/tox$LOCK_SUFFIX
python -m pip install -r requirements/prod$LOCK_SUFFIX
python -m pip install -r requirements/kit$LOCK_SUFFIX
# Create generated files: version file and .lnk files. sdist tarball ignored
- name: "Build sdist to run plugins. Creates generated files"
env:
SET_LOCK: ${{ vars.DRAINSWAMP_SET_LOCK }}
run: |
set -xe
echo "python -m build -C--kind='current' -C--set-lock='$SET_LOCK'"
python -m build -C--kind="current" -C--set-lock="$SET_LOCK"
- name: "Tox docs"
run: |
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,18 @@ jobs:
- name: "Install dependencies"
run: |
set -xe
python -m pip install -r requirements/tox$LOCK_SUFFIX
python -m pip install -r requirements/prod$LOCK_SUFFIX
python -m pip install -r requirements/kit$LOCK_SUFFIX
- name: "Refresh dependency lock .lnk files"
# Create generated files: version file and .lnk files. sdist tarball ignored
- name: "Build sdist to run plugins. Create generated files"
env:
SET_LOCK: ${{ vars.DRAINSWAMP_SET_LOCK }}
run: |
set -xe
python src/drain_swamp/cli_unlock.py refresh --set-lock=$SET_LOCK
echo "python -m build -C--kind='current' -C--set-lock='$SET_LOCK'"
python -m build -C--kind="current" -C--set-lock="$SET_LOCK"
- name: "Run tox for ${{ matrix.python-version }}"
run: |
Expand Down
10 changes: 10 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ Changelog

.. scriv-start-here
.. _changes_1-2-1:

Version 1.2.1 — 2024-08-05
--------------------------

- fix(entrypoints): remove support for --version option
- refactor: add module constants_maybe. Move constants.__version_app constants.__url__
- ci(tox-test): remove py314
- ci: build sdist to run build plugins to recreate generated files

.. _changes_1-2-0:

Version 1.2.0 — 2024-08-05
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ That's a lot of boilerplate code ... gone! Not all, but most.

**New in 1.2.x**

generate version file if missing;
generate version file if missing; ci workflows recreate generated files;

**New in 1.1.x**

Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
# @@@ editable
copyright = "2024–2024, Dave Faulkmore"
# The short X.Y.Z version.
version = "1.2.0"
version = "1.2.1"
# The full version, including alpha/beta/rc tags.
release = "1.2.0"
release = "1.2.1"
# The date of release, in "monthname day, year" format.
release_date = "August 5, 2024"
# @@@ end
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ That's a lot of boilerplate code ... gone! Not all, but most.

**New in 1.2.x**

generate version file if missing;
generate version file if missing; ci workflows recreate generated files;

**New in 1.1.x**

Expand Down
6 changes: 1 addition & 5 deletions src/drain_swamp/cli_igor.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,7 @@
pass
# pep366 ...done

from .constants import (
__version_app,
g_app_name,
)
from .constants import g_app_name
from .igor_utils import (
build_package,
edit_for_release,
Expand Down Expand Up @@ -278,7 +275,6 @@
@click.group(
context_settings={"help_option_names": ["-h", "--help"]},
)
@click.version_option(version=__version_app)
def main():
"""Command-line for drain-swamp. Prints usage"""

Expand Down
1 change: 0 additions & 1 deletion src/drain_swamp/cli_scm_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
@click.group(
context_settings={"help_option_names": ["-h", "--help"]},
)
@click.version_option(version="0.0.1")
def main():
"""Command-line for scm-version. Prints usage"""

Expand Down
2 changes: 0 additions & 2 deletions src/drain_swamp/cli_unlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
from .constants import (
SUFFIX_LOCKED,
SUFFIX_UNLOCKED,
__version_app,
)
from .exceptions import (
BackendNotSupportedError,
Expand Down Expand Up @@ -181,7 +180,6 @@
@click.group(
context_settings={"help_option_names": ["-h", "--help"]},
)
@click.version_option(version=__version_app)
def main():
"""Command-line for pipenv-unlock. Prints usage"""

Expand Down
37 changes: 3 additions & 34 deletions src/drain_swamp/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
package level constants
.. py:data:: __all__
:type: tuple[str, str, str, str, str, str, str, str, str, str, str]
:type: tuple[str, str, str, str, str, str, str, str, str]
:value: ("g_app_name", "package_name", "SUFFIX_IN", "SUFFIX_LOCKED", \
"SUFFIX_UNLOCKED", "SUFFIX_SYMLINK", "__version_app", "__url__", \
"PATH_PIP_COMPILE", "PROG_LOCK", "PROG_UNLOCK")
"SUFFIX_UNLOCKED", "SUFFIX_SYMLINK", "PATH_PIP_COMPILE", "PROG_LOCK", \
"PROG_UNLOCK")
Module exports
Expand Down Expand Up @@ -50,22 +50,6 @@
:type: str
:value: ".lnk"
.. py:data:: __version_app
:type: str
Official app version. Semantic versioning fully supported. So pre and post releases,
release candidate, and dev releases are possible
tagged post releases are encouraged. Cuz that means used
:command:`git rebase` to fix a problem at when it originally occured
rather than applying the fix and ignoring the past
.. py:data:: __url__
:type: str
rtd URL to for current tagged version. This is not used for anything.
Just here for completeness.
.. py:data:: PATH_PIP_COMPILE
:type: pathlib.Path
Expand Down Expand Up @@ -128,21 +112,13 @@
import sys
from pathlib import Path

from ._version import __version__
from .version_semantic import (
SemVersion,
sanitize_tag,
)

__all__ = (
"g_app_name",
"package_name",
"SUFFIX_IN",
"SUFFIX_LOCKED",
"SUFFIX_UNLOCKED",
"SUFFIX_SYMLINK",
"__version_app",
"__url__",
"PATH_PIP_COMPILE",
"PROG_LOCK",
"PROG_UNLOCK",
Expand All @@ -157,13 +133,6 @@
SUFFIX_UNLOCKED = ".unlock"
SUFFIX_SYMLINK = ".lnk"

# Removes epoch and local. Fixes version
__version_app, local = sanitize_tag(__version__)

sv = SemVersion()
sv.parse_ver(__version__, local=local)
__url__ = sv.readthedocs_url(g_app_name, is_latest=False)

# Required only for pytest
DEBUG = False
IS_TESTING = "pytest" in sys.modules
Expand Down
50 changes: 50 additions & 0 deletions src/drain_swamp/constants_maybe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""
.. moduleauthor:: Dave Faulkmore <https://mastodon.social/@msftcangoblowme>
The _version module is generated and not guaranteed to exist.
When _version is missing, such as after a :code:`git clone` or within CI/CD,
there is no reason to allow this fyi only package info to be the cause of failure
.. py:data:: __version_app
:type: str
Official app version. Semantic versioning fully supported. So pre and post releases,
release candidate, and dev releases are possible
tagged post releases are encouraged. Cuz that means used
:command:`git rebase` to fix a problem at when it originally occured
rather than applying the fix and ignoring the past
.. py:data:: __url__
:type: str
rtd URL to for current tagged version. This is not used for anything.
Just here for completeness.
.. py:data:: __all__
:type: tuple[str, str]
:value: ("__version_app", "__url__")
Module exports
"""

from ._version import __version__
from .constants import g_app_name
from .version_semantic import (
SemVersion,
sanitize_tag,
)

__all__ = (
"__version_app",
"__url__",
)

# Removes epoch and local. Fixes version
__version_app, local = sanitize_tag(__version__)

sv = SemVersion()
sv.parse_ver(__version__, local=local)
__url__ = sv.readthedocs_url(g_app_name, is_latest=False)
9 changes: 9 additions & 0 deletions src/drain_swamp/constants_maybe.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from typing import Final

__all__ = (
"__version_app",
"__url__",
)

__version_app: Final[str]
__url__: Final[str]
2 changes: 2 additions & 0 deletions tests/test_cli_igor.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ def test_cli_main():
"""Minimally test package version is printed"""
runner = CliRunner()
# --version
"""
cmd = ["--version"]
result = runner.invoke(main, cmd)
assert result.exit_code == 0
assert "version" in result.stdout
"""

# --help
cmd = ["--help"]
Expand Down
2 changes: 2 additions & 0 deletions tests/test_cli_scm_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ def test_cli_main():
"""Minimally test package version is printed"""
runner = CliRunner()
# --version
"""
cmd = ["--version"]
result = runner.invoke(main, cmd)
assert result.exit_code == 0
assert "version" in result.stdout
"""

# --help
cmd = ["--help"]
Expand Down
2 changes: 2 additions & 0 deletions tests/test_cli_unlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ def test_cli_main():
"""Minimally test package version is printed"""
runner = CliRunner()
# --version
"""
cmd = ["--version"]
result = runner.invoke(main, cmd)
assert result.exit_code == 0
assert "version" in result.stdout
"""

# --help
cmd = ["--help"]
Expand Down
7 changes: 7 additions & 0 deletions tests/test_versioning_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,13 @@ def test_readthedocs_package_name(self):
project_name_actual = uri.split(".")[0]
self.assertNotIn("_", project_name_actual)

# package_name contains hyphens. Gets converted to underscores
str_url = sv.readthedocs_url(g_app_name)
protocol_len = len("https://")
uri = str_url[protocol_len:]
project_name_actual = uri.split(".")[0]
self.assertEqual(project_name_actual, project_name)

for v_in, v_expected, anchor in testdata_valids:
# clean up semantic version str
v_actual, _ = sanitize_tag(v_in)
Expand Down
4 changes: 2 additions & 2 deletions tox-test.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# pypy3.10-7.3.16 requires Rust package manager, Cargo. (7161KB --> 22MB installed)
# sudo xbps-install -S --yes cargo
envlist = py{py3,39,310,311,312,313,314}
envlist = py{py3,39,310,311,312,313}

toxworkdir = {env:TOXWORKDIR:.tox}

Expand All @@ -31,7 +31,7 @@ setenv =
PYTHON_COLORS=0
TOXINIDIR = {toxinidir}
DS_CONFIG_SETTINGS={temp_dir}/setuptools-build.toml
py{py3,39,310,311,312,313,314}: COVERAGE_FILE = .coverage.{envname}
py{py3,39,310,311,312,313}: COVERAGE_FILE = .coverage.{envname}

# tox not recognizing config_settings passed via cli
# python -m build -C--kind="tag" -C--set-lock="0"
Expand Down

0 comments on commit 7525618

Please sign in to comment.