Skip to content

Commit

Permalink
Merge pull request #115 from jedie/dev
Browse files Browse the repository at this point in the history
Apply manageprojects updates: Skip Python 3.9 support
  • Loading branch information
jedie authored Dec 21, 2023
2 parents 05ed519 + 9805a81 commit 8d2a1bb
Show file tree
Hide file tree
Showing 17 changed files with 63 additions and 75 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.12", "3.11", "3.10", "3.9"]
env:
PYTHONUNBUFFERED: 1
PYTHONWARNINGS: always
python-version: ["3.12", "3.11", "3.10"]
steps:
- name: Checkout
run: |
Expand All @@ -34,7 +31,7 @@ jobs:
with:
python-version: '${{ matrix.python-version }}'
cache: 'pip' # caching pip dependencies
cache-dependency-path: '**/requirements.dev.txt'
cache-dependency-path: '**/requirements.*.txt'

- name: 'Bootstrap app venv'
# The first CLI call will create the .venv
Expand All @@ -59,6 +56,9 @@ jobs:
./dev-cli.py safety
- name: 'Run tests with Python v${{ matrix.python-version }}'
env:
PYTHONUNBUFFERED: 1
PYTHONWARNINGS: always
run: |
./dev-cli.py coverage
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ Usage: ./cli.py format-file [OPTIONS] FILE_PATH
╭─ Options ────────────────────────────────────────────────────────────────────────────────────────╮
│ --py-version TEXT Fallback Python version for darker/pyupgrade, if │
│ version is not defined in pyproject.toml │
│ [default: 3.9]
│ [default: 3.10]
│ --max-line-length -l INTEGER Fallback max. line length for darker/isort etc., if │
│ not defined in .editorconfig │
│ [default: 119] │
Expand Down Expand Up @@ -332,6 +332,10 @@ See also git tags: https://github.com/jedie/manageprojects/tags

[comment]: <> (✂✂✂ auto generated history start ✂✂✂)

* [v0.17.0](https://github.com/jedie/manageprojects/compare/v0.16.2...v0.17.0)
* 2023-12-21 - Unify BASE_PATH / PACKAGE_ROOT etc.
* 2023-12-21 - Apply manageprojects updates: Skip Python 3.9 support
* 2023-12-21 - Update requirements
* [v0.16.2](https://github.com/jedie/manageprojects/compare/v0.16.1...v0.16.2)
* 2023-12-16 - Update pre-commit-config
* 2023-12-16 - Skip test_readme_history() on CI
Expand All @@ -344,11 +348,11 @@ See also git tags: https://github.com/jedie/manageprojects/tags
* 2023-12-02 - Use code style tooling from cli-base-utilities
* 2023-12-01 - Apply https://github.com/jedie/cookiecutter_templates updates
* 2023-12-01 - Use: cli_base.cli_tools.test_utils.logs.AssertLogs
* [v0.15.4](https://github.com/jedie/manageprojects/compare/v0.15.3...v0.15.4)
* 2023-11-27 - Use "flake8-bugbear", too.

<details><summary>Expand older history entries ...</summary>

* [v0.15.4](https://github.com/jedie/manageprojects/compare/v0.15.3...v0.15.4)
* 2023-11-27 - Use "flake8-bugbear", too.
* [v0.15.3](https://github.com/jedie/manageprojects/compare/v0.15.2...v0.15.3)
* 2023-11-09 - Bugfix "reverse" if context contains a list
* 2023-11-07 - Update requirements
Expand Down
5 changes: 3 additions & 2 deletions cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"""

import hashlib
import shlex
import subprocess
import sys
import venv
Expand All @@ -32,7 +33,7 @@ def print_no_pip_error():
sys.exit(-1)


assert sys.version_info >= (3, 9), 'Python version is too old!'
assert sys.version_info >= (3, 10), f'Python version {sys.version_info} is too old!'


if sys.platform == 'win32': # wtf
Expand Down Expand Up @@ -77,7 +78,7 @@ def venv_up2date():


def verbose_check_call(*popen_args):
print(f'\n+ {" ".join(str(arg) for arg in popen_args)}\n')
print(f'\n+ {shlex.join(str(arg) for arg in popen_args)}\n')
return subprocess.check_call(popen_args)


Expand Down
5 changes: 3 additions & 2 deletions dev-cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"""

import hashlib
import shlex
import subprocess
import sys
import venv
Expand All @@ -32,7 +33,7 @@ def print_no_pip_error():
sys.exit(-1)


assert sys.version_info >= (3, 9), 'Python version is too old!'
assert sys.version_info >= (3, 10), f'Python version {sys.version_info} is too old!'


if sys.platform == 'win32': # wtf
Expand Down Expand Up @@ -77,7 +78,7 @@ def venv_up2date():


def verbose_check_call(*popen_args):
print(f'\n+ {" ".join(str(arg) for arg in popen_args)}\n')
print(f'\n+ {shlex.join(str(arg) for arg in popen_args)}\n')
return subprocess.check_call(popen_args)


Expand Down
2 changes: 1 addition & 1 deletion manageprojects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
Manage Python / Django projects
"""

__version__ = '0.16.2'
__version__ = '0.17.0'
__author__ = 'Jens Diemer <[email protected]>'
24 changes: 10 additions & 14 deletions manageprojects/cli/cli_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
import subprocess
import sys
from pathlib import Path
from typing import Optional

import rich_click as click
from bx_py_utils.path import assert_is_dir, assert_is_file
from bx_py_utils.path import assert_is_dir
from cli_base.cli_tools.subprocess_utils import verbose_check_call
from cli_base.cli_tools.verbosity import OPTION_KWARGS_VERBOSE
from cli_base.cli_tools.version_info import print_version
Expand Down Expand Up @@ -39,9 +38,6 @@
logger = logging.getLogger(__name__)


PACKAGE_ROOT = Path(manageprojects.__file__).parent.parent
assert_is_file(PACKAGE_ROOT / 'pyproject.toml')

OPTION_ARGS_DEFAULT_TRUE = dict(is_flag=True, show_default=True, default=True)
OPTION_ARGS_DEFAULT_FALSE = dict(is_flag=True, show_default=True, default=False)
ARGUMENT_EXISTING_DIR = dict(
Expand Down Expand Up @@ -116,12 +112,12 @@ def cli():
def start_project(
template: str,
output_dir: Path,
directory: Optional[str],
checkout: Optional[str],
directory: str | None,
checkout: str | None,
input: bool,
replay: bool,
password: Optional[str],
config_file: Optional[Path],
password: str | None,
config_file: Path | None,
):
"""
Start a new "managed" project via a CookieCutter Template.
Expand Down Expand Up @@ -199,8 +195,8 @@ def start_project(
def update_project(
project_path: Path,
overwrite: bool,
password: Optional[str],
config_file: Optional[Path],
password: str | None,
config_file: Path | None,
input: bool,
cleanup: bool,
):
Expand Down Expand Up @@ -250,9 +246,9 @@ def clone_project(
project_path: Path,
output_dir: Path,
input: bool,
checkout: Optional[str] = None,
password: Optional[str] = None,
config_file: Optional[Path] = None,
checkout: str | None = None,
password: str | None = None,
config_file: Path | None = None,
):
"""
Clone existing project by replay the cookiecutter template in a new directory.
Expand Down
3 changes: 2 additions & 1 deletion manageprojects/cli/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@

import manageprojects
from manageprojects import constants
from manageprojects.constants import BASE_PATH
from manageprojects.utilities.publish import publish_package


logger = logging.getLogger(__name__)


PACKAGE_ROOT = Path(manageprojects.__file__).parent.parent
PACKAGE_ROOT = BASE_PATH.parent
assert_is_file(PACKAGE_ROOT / 'pyproject.toml')

OPTION_ARGS_DEFAULT_TRUE = dict(is_flag=True, show_default=True, default=True)
Expand Down
5 changes: 4 additions & 1 deletion manageprojects/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import sys
from pathlib import Path

import manageprojects


INITIAL_REVISION = 'initial_revision'
INITIAL_DATE = 'initial_date'
Expand All @@ -24,7 +26,8 @@
]
)
)
FORMAT_PY_FILE_DEFAULT_MIN_PYTON_VERSION = '3.9'
FORMAT_PY_FILE_DEFAULT_MIN_PYTON_VERSION = '3.10'
FORMAT_PY_FILE_DEFAULT_MAX_LINE_LENGTH = 119

PY_BIN_PATH = Path(sys.executable).parent
BASE_PATH = Path(manageprojects.__file__).parent
2 changes: 0 additions & 2 deletions manageprojects/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@

from bx_py_utils.path import assert_is_file

import manageprojects
from manageprojects.utilities.pyproject_toml import TomlDocument, get_toml_document


PROJECT_PATH = Path(manageprojects.__file__).parent.parent
GIT_BIN_PARENT = Path(shutil.which('git')).parent


Expand Down
3 changes: 2 additions & 1 deletion manageprojects/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from unittest.mock import MagicMock

from manageprojects.cli import cli_app
from manageprojects.cli.cli_app import PACKAGE_ROOT, start_project, update_project
from manageprojects.cli.cli_app import start_project, update_project
from manageprojects.cli.dev import PACKAGE_ROOT
from manageprojects.cli.dev import cli as dev_cli
from manageprojects.constants import PY_BIN_PATH
from manageprojects.data_classes import CookiecutterResult
Expand Down
25 changes: 13 additions & 12 deletions manageprojects/tests/test_format_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from cli_base.cli_tools.test_utils.logs import AssertLogs
from packaging.version import Version

from manageprojects.cli.dev import PACKAGE_ROOT
from manageprojects.constants import PY_BIN_PATH
from manageprojects.format_file import (
Config,
Expand All @@ -17,7 +18,7 @@
get_pyproject_info,
)
from manageprojects.test_utils.subprocess import SimpleRunReturnCallback, SubprocessCallMock
from manageprojects.tests.base import GIT_BIN_PARENT, PROJECT_PATH
from manageprojects.tests.base import GIT_BIN_PARENT
from manageprojects.utilities.temp_path import TemporaryDirectory


Expand Down Expand Up @@ -111,9 +112,9 @@ def test_get_pyproject_info(self):
self.assertEqual(
get_pyproject_info(file_path=Path(__file__), default_min_py_version='3.7'),
PyProjectInfo(
pyproject_toml_path=PROJECT_PATH / 'pyproject.toml',
py_min_ver=Version('3.9'),
raw_py_ver_req='>=3.9,<4',
pyproject_toml_path=PACKAGE_ROOT / 'pyproject.toml',
py_min_ver=Version('3.10'),
raw_py_ver_req='>=3.10',
),
)

Expand All @@ -129,11 +130,11 @@ def test_get_config(self):
self.assertEqual(
config,
Config(
git_info=GitInfo(cwd=PROJECT_PATH, main_branch_name='main'),
git_info=GitInfo(cwd=PACKAGE_ROOT, main_branch_name='main'),
pyproject_info=PyProjectInfo(
pyproject_toml_path=PROJECT_PATH / 'pyproject.toml',
py_min_ver=Version('3.9'),
raw_py_ver_req='>=3.9,<4',
pyproject_toml_path=PACKAGE_ROOT / 'pyproject.toml',
py_min_ver=Version('3.10'),
raw_py_ver_req='>=3.10',
),
max_line_length=119,
),
Expand All @@ -146,7 +147,7 @@ def test_get_config(self):
Config(
git_info=None,
pyproject_info=PyProjectInfo(
py_min_ver=Version('3.9'), pyproject_toml_path=None, raw_py_ver_req=None
py_min_ver=Version('3.10'), pyproject_toml_path=None, raw_py_ver_req=None
),
max_line_length=119,
),
Expand All @@ -173,7 +174,7 @@ def test_format_one_file(self):
[
'.../pyupgrade',
'--exit-zero-even-if-changed',
'--py39-plus',
'--py310-plus',
'manageprojects/tests/test_format_file.py',
],
[
Expand Down Expand Up @@ -201,7 +202,7 @@ def test_format_one_file(self):
'--line-length',
'119',
'--target-version',
'py39',
'py310',
'manageprojects/tests/test_format_file.py',
],
['.../flake8', '--max-line-length', '119', 'manageprojects/tests/test_format_file.py'],
Expand Down Expand Up @@ -238,7 +239,7 @@ def test_format_one_file(self):
[
'.../pyupgrade',
'--exit-zero-even-if-changed',
'--py39-plus',
'--py310-plus',
'manageprojects/tests/test_format_file.py',
],
['.../autoflake', '--in-place', 'manageprojects/tests/test_format_file.py'],
Expand Down
2 changes: 1 addition & 1 deletion manageprojects/tests/test_project_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from packaging.version import Version

from manageprojects import __version__
from manageprojects.cli.cli_app import PACKAGE_ROOT
from manageprojects.cli.dev import PACKAGE_ROOT
from manageprojects.test_utils.project_setup import check_editor_config, get_py_max_line_length


Expand Down
3 changes: 2 additions & 1 deletion manageprojects/tests/test_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from bx_py_utils.path import assert_is_file

from manageprojects import constants
from manageprojects.cli.cli_app import PACKAGE_ROOT, cli
from manageprojects.cli.cli_app import cli
from manageprojects.cli.dev import PACKAGE_ROOT
from manageprojects.cli.dev import cli as dev_cli
from manageprojects.test_utils.click_cli_utils import invoke_click
from manageprojects.tests.base import BaseTestCase
Expand Down
4 changes: 2 additions & 2 deletions manageprojects/tests/test_utilities_pyproject_toml.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from bx_py_utils.test_utils.datetime import parse_dt
from cli_base.cli_tools.test_utils.logs import AssertLogs

import manageprojects
from manageprojects.constants import BASE_PATH
from manageprojects.data_classes import ManageProjectsMeta
from manageprojects.tests.base import BaseTestCase
from manageprojects.utilities.pyproject_toml import PyProjectToml, find_pyproject_toml
Expand Down Expand Up @@ -268,7 +268,7 @@ def test_expand_existing_toml(self):
logs.assert_in('Read existing pyproject.toml')

def test_find_pyproject_toml(self):
own_pyproject_toml = Path(manageprojects.__file__).parent.parent / 'pyproject.toml'
own_pyproject_toml = BASE_PATH.parent / 'pyproject.toml'
assert_is_file(own_pyproject_toml)
self.assertEqual(find_pyproject_toml(file_path=Path(__file__)), own_pyproject_toml)

Expand Down
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ readme = "README.md"
authors = [
{name = 'Jens Diemer', email = '[email protected]'}
]
requires-python = ">=3.9,<4"
requires-python = ">=3.10"
dependencies = [
"cookiecutter>=2.4.0", # https://github.com/cookiecutter/cookiecutter
"tomlkit",
Expand All @@ -28,7 +28,7 @@ dependencies = [
"codespell", # https://github.com/codespell-project/codespell
"mypy", # https://github.com/python/mypy

"cli-base-utilities>=0.7.0rc2", # https://github.com/jedie/cli-base-utilities
"cli-base-utilities", # https://github.com/jedie/cli-base-utilities
"click", # https://github.com/pallets/click/
"rich-click", # https://github.com/ewels/rich-click
"rich", # https://github.com/Textualize/rich
Expand Down Expand Up @@ -125,7 +125,7 @@ exclude_lines = [
legacy_tox_ini = """
[tox]
isolated_build = True
envlist = py{312,311,310,39}
envlist = py{312,311,310}
skip_missing_interpreters = True
[testenv]
Expand Down Expand Up @@ -168,6 +168,7 @@ applied_migrations = [
"be3f649", # 2023-08-22T19:36:57+02:00
"385f654", # 2023-10-08T21:09:24+02:00
"d1ed4b1", # 2023-12-01T21:41:29+01:00
"c538ae7", # 2023-12-21T20:21:58+01:00
]

[manageprojects.cookiecutter_context.cookiecutter]
Expand Down
Loading

0 comments on commit 8d2a1bb

Please sign in to comment.