Skip to content

Commit

Permalink
Merge pull request #54 from jacebrowning/release-2.2
Browse files Browse the repository at this point in the history
Bump version to 2.2 and update tooling
  • Loading branch information
jacebrowning authored Jun 29, 2023
2 parents a6ca71f + 3448560 commit b3b68fc
Show file tree
Hide file tree
Showing 13 changed files with 810 additions and 754 deletions.
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Temporary Python files
*.pyc
*.egg-info
__pycache__
.ipynb_checkpoints
*.egg-info/
__pycache__/
.ipynb_checkpoints/
setup.py
pip-wheel-metadata/

Expand All @@ -12,6 +12,7 @@ Icon*
# Temporary virtual environment files
/.cache/
/.venv/
tmp/

# Temporary server files
.env
Expand Down
1 change: 0 additions & 1 deletion .python-version

This file was deleted.

2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
python 3.11.3
poetry 1.5.1
2 changes: 1 addition & 1 deletion .verchew.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ version = 1

cli = dot
cli_version_arg = -V
version = 2
version = 7 || 8
optional = true
message = This is only needed to generate UML diagrams for documentation.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"freezegun",
"minilog",
"minimalistic",
"mypy",
"sinfo",
"USERPROFILE",
"venv",
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Release Notes

## 2.2 (beta)
## 2.2 (2023-06-29)

- Dropped support for Python 3.7.
- Added `py.typed` for better `mypy` support.

## 2.1 (2022-03-06)

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
To confirm these system dependencies are configured correctly:

```text
$ make bootstrap
$ make doctor
```

Expand Down
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,22 @@ MODULES := $(wildcard $(PACKAGE)/*.py)
# MAIN TASKS ##################################################################

.PHONY: all
all: format check test mkdocs ## Run all tasks that determine CI status
all: doctor format check test mkdocs ## Run all tasks that determine CI status

.PHONY: dev
dev: install .clean-test ## Continuously run CI tasks when files chanage
poetry run sniffer

# SYSTEM DEPENDENCIES #########################################################

.PHONY: boostrap
boostrap: ## Attempt to install system dependencies
asdf plugin add python || asdf plugin update python
asdf plugin add poetry https://github.com/asdf-community/asdf-poetry.git || asdf plugin update poetry
asdf install

.PHONY: doctor
doctor: ## Confirm system dependencies are available
doctor: ## Confirm system dependencies are available
bin/verchew

# PROJECT DEPENDENCIES ########################################################
Expand All @@ -27,6 +33,7 @@ install: $(DEPENDENCIES) .cache ## Install project dependencies

$(DEPENDENCIES): poetry.lock
@ rm -rf $(VIRTUAL_ENV)/.poetry-*
@ rm -rf ~/Library/Preferences/pypoetry
@ poetry config virtualenvs.in-project true
poetry install
@ touch $@
Expand Down Expand Up @@ -97,7 +104,7 @@ format: install
@ echo

.PHONY: check
check: install format ## Run formaters, linters, and static analysis
check: install format ## Run formaters, linters, and static analysis
ifdef CI
git diff --exit-code
endif
Expand Down
42 changes: 22 additions & 20 deletions bin/update
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import shutil
import subprocess
import sys


CWD = os.getcwd()
TMP = tempfile.gettempdir()
CONFIG = {
Expand All @@ -25,12 +26,12 @@ CONFIG = {
}


def install(package='cookiecutter'):
def install(package="cookiecutter"):
try:
importlib.import_module(package)
except ImportError:
print("Installing cookiecutter")
subprocess.check_call([sys.executable, '-m', 'pip', 'install', package])
subprocess.check_call([sys.executable, "-m", "pip", "install", package])


def run():
Expand All @@ -40,7 +41,7 @@ def run():

os.chdir(TMP)
cookiecutter(
'https://github.com/jacebrowning/template-python.git',
"https://github.com/jacebrowning/template-python.git",
no_input=True,
overwrite_if_exists=True,
extra_context=CONFIG,
Expand All @@ -49,30 +50,31 @@ def run():

def copy():
for filename in [
os.path.join('bin', 'update'),
os.path.join('bin', 'checksum'),
os.path.join('bin', 'open'),
os.path.join('bin', 'verchew'),
'.appveyor.yml',
'.coveragerc',
'.gitattributes',
'.gitignore',
'.pydocstyle.ini',
'.pylint.ini',
'.scrutinizer.yml',
'.verchew.ini',
'CONTRIBUTING.md',
'Makefile',
'scent.py',
os.path.join("bin", "update"),
os.path.join("bin", "checksum"),
os.path.join("bin", "open"),
os.path.join("bin", "verchew"),
".appveyor.yml",
".coveragerc",
".gitattributes",
".gitignore",
".pydocstyle.ini",
".pylint.ini",
".scrutinizer.yml",
".tool-versions",
".verchew.ini",
"CONTRIBUTING.md",
"Makefile",
"scent.py",
]:
src = os.path.join(TMP, CONFIG['project_name'], filename)
src = os.path.join(TMP, CONFIG["project_name"], filename)
dst = os.path.join(CWD, filename)
print("Updating " + filename)
with suppress(FileNotFoundError):
shutil.copy(src, dst)


if __name__ == '__main__':
if __name__ == "__main__":
install()
run()
copy()
52 changes: 37 additions & 15 deletions bin/verchew
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

#
# The MIT License (MIT)
# Copyright © 2016, Jace Browning
#
Expand Down Expand Up @@ -47,11 +47,14 @@ else:
import configparser
from urllib.request import urlretrieve

__version__ = '3.1.1'
__version__ = '3.4'

SCRIPT_URL = (
"https://raw.githubusercontent.com/jacebrowning/verchew/main/verchew/script.py"
)
WRAPPER_URL = (
"https://raw.githubusercontent.com/jacebrowning/verchew/main/verchew/wrapper.sh"
)

CONFIG_FILENAMES = ['verchew.ini', '.verchew.ini', '.verchewrc', '.verchew']

Expand Down Expand Up @@ -112,7 +115,8 @@ def main():
log.debug("PATH: %s", os.getenv('PATH'))

if args.vendor:
vendor_script(args.vendor)
vendor_script(SCRIPT_URL, args.vendor)
vendor_script(WRAPPER_URL, args.vendor + "-wrapper")
sys.exit(0)

path = find_config(args.root, generate=args.init)
Expand Down Expand Up @@ -171,14 +175,14 @@ def configure_logging(count=0):
logging.basicConfig(level=level, format="%(levelname)s: %(message)s")


def vendor_script(path):
def vendor_script(url, path):
root = os.path.abspath(os.path.join(path, os.pardir))
if not os.path.isdir(root):
log.info("Creating directory %s", root)
os.makedirs(root)

log.info("Downloading %s to %s", SCRIPT_URL, path)
urlretrieve(SCRIPT_URL, path)
log.info("Downloading %s to %s", url, path)
urlretrieve(url, path)

log.debug("Making %s executable", path)
mode = os.stat(path).st_mode
Expand Down Expand Up @@ -236,6 +240,10 @@ def parse_config(path):
data[name]['version'] = version
data[name]['patterns'] = [v.strip() for v in version.split('||')]

data[name]['optional'] = data[name].get(
'optional', 'false'
).strip().lower() in ('true', 'yes', 'y', True)

return data


Expand All @@ -260,7 +268,7 @@ def check_dependencies(config):
if "not found" in output:
actual = "Not found"
else:
actual = output.split('\n')[0].strip('.')
actual = output.split('\n', maxsplit=1)[0].strip('.')
expected = settings['version'] or "<anything>"
print("{0}: {1}, EXPECTED: {2}".format(name, actual, expected))
show(
Expand All @@ -280,30 +288,44 @@ def get_version(program, argument=None):
if argument is None:
args = [program, '--version']
elif argument:
args = [program, argument]
args = [program] + argument.split()
else:
args = [program]

show("$ {0}".format(" ".join(args)))
output = call(args)
lines = output.splitlines()
show(lines[0] if lines else "<nothing>")

if lines:
for line in lines:
if any(char.isdigit() for char in line):
show(line)
break
else:
show(lines[0])
else:
show("<nothing>")

return output


def match_version(pattern, output):
if "not found" in output.split('\n')[0]:
lines = output.splitlines()
if "not found" in lines[0]:
return False

regex = pattern.replace('.', r'\.') + r'(\b|/)'

log.debug("Matching %s: %s", regex, output)
match = re.match(regex, output)
if match is None:
match = re.match(r'.*[^\d.]' + regex, output)
for line in lines:
log.debug("Matching %s: %s", regex, line)
match = re.match(regex, line)
if match is None:
log.debug("Matching %s: %s", regex, line)
match = re.match(r'.*[^\d.]' + regex, line)
if match:
return True

return bool(match)
return False


def call(args):
Expand Down
Loading

0 comments on commit b3b68fc

Please sign in to comment.