Skip to content

Commit b3b68fc

Browse files
authored
Merge pull request #54 from jacebrowning/release-2.2
Bump version to 2.2 and update tooling
2 parents a6ca71f + 3448560 commit b3b68fc

File tree

13 files changed

+810
-754
lines changed

13 files changed

+810
-754
lines changed

.gitignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Temporary Python files
22
*.pyc
3-
*.egg-info
4-
__pycache__
5-
.ipynb_checkpoints
3+
*.egg-info/
4+
__pycache__/
5+
.ipynb_checkpoints/
66
setup.py
77
pip-wheel-metadata/
88

@@ -12,6 +12,7 @@ Icon*
1212
# Temporary virtual environment files
1313
/.cache/
1414
/.venv/
15+
tmp/
1516

1617
# Temporary server files
1718
.env

.python-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

.tool-versions

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
python 3.11.3
2+
poetry 1.5.1

.verchew.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ version = 1
1717

1818
cli = dot
1919
cli_version_arg = -V
20-
version = 2
20+
version = 7 || 8
2121
optional = true
2222
message = This is only needed to generate UML diagrams for documentation.

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"freezegun",
66
"minilog",
77
"minimalistic",
8+
"mypy",
89
"sinfo",
910
"USERPROFILE",
1011
"venv",

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Release Notes
22

3-
## 2.2 (beta)
3+
## 2.2 (2023-06-29)
44

55
- Dropped support for Python 3.7.
6+
- Added `py.typed` for better `mypy` support.
67

78
## 2.1 (2022-03-06)
89

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
To confirm these system dependencies are configured correctly:
1919

2020
```text
21+
$ make bootstrap
2122
$ make doctor
2223
```
2324

Makefile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,22 @@ MODULES := $(wildcard $(PACKAGE)/*.py)
55
# MAIN TASKS ##################################################################
66

77
.PHONY: all
8-
all: format check test mkdocs ## Run all tasks that determine CI status
8+
all: doctor format check test mkdocs ## Run all tasks that determine CI status
99

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

1414
# SYSTEM DEPENDENCIES #########################################################
1515

16+
.PHONY: boostrap
17+
boostrap: ## Attempt to install system dependencies
18+
asdf plugin add python || asdf plugin update python
19+
asdf plugin add poetry https://github.com/asdf-community/asdf-poetry.git || asdf plugin update poetry
20+
asdf install
21+
1622
.PHONY: doctor
17-
doctor: ## Confirm system dependencies are available
23+
doctor: ## Confirm system dependencies are available
1824
bin/verchew
1925

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

2834
$(DEPENDENCIES): poetry.lock
2935
@ rm -rf $(VIRTUAL_ENV)/.poetry-*
36+
@ rm -rf ~/Library/Preferences/pypoetry
3037
@ poetry config virtualenvs.in-project true
3138
poetry install
3239
@ touch $@
@@ -97,7 +104,7 @@ format: install
97104
@ echo
98105

99106
.PHONY: check
100-
check: install format ## Run formaters, linters, and static analysis
107+
check: install format ## Run formaters, linters, and static analysis
101108
ifdef CI
102109
git diff --exit-code
103110
endif

bin/update

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import shutil
99
import subprocess
1010
import sys
1111

12+
1213
CWD = os.getcwd()
1314
TMP = tempfile.gettempdir()
1415
CONFIG = {
@@ -25,12 +26,12 @@ CONFIG = {
2526
}
2627

2728

28-
def install(package='cookiecutter'):
29+
def install(package="cookiecutter"):
2930
try:
3031
importlib.import_module(package)
3132
except ImportError:
3233
print("Installing cookiecutter")
33-
subprocess.check_call([sys.executable, '-m', 'pip', 'install', package])
34+
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
3435

3536

3637
def run():
@@ -40,7 +41,7 @@ def run():
4041

4142
os.chdir(TMP)
4243
cookiecutter(
43-
'https://github.com/jacebrowning/template-python.git',
44+
"https://github.com/jacebrowning/template-python.git",
4445
no_input=True,
4546
overwrite_if_exists=True,
4647
extra_context=CONFIG,
@@ -49,30 +50,31 @@ def run():
4950

5051
def copy():
5152
for filename in [
52-
os.path.join('bin', 'update'),
53-
os.path.join('bin', 'checksum'),
54-
os.path.join('bin', 'open'),
55-
os.path.join('bin', 'verchew'),
56-
'.appveyor.yml',
57-
'.coveragerc',
58-
'.gitattributes',
59-
'.gitignore',
60-
'.pydocstyle.ini',
61-
'.pylint.ini',
62-
'.scrutinizer.yml',
63-
'.verchew.ini',
64-
'CONTRIBUTING.md',
65-
'Makefile',
66-
'scent.py',
53+
os.path.join("bin", "update"),
54+
os.path.join("bin", "checksum"),
55+
os.path.join("bin", "open"),
56+
os.path.join("bin", "verchew"),
57+
".appveyor.yml",
58+
".coveragerc",
59+
".gitattributes",
60+
".gitignore",
61+
".pydocstyle.ini",
62+
".pylint.ini",
63+
".scrutinizer.yml",
64+
".tool-versions",
65+
".verchew.ini",
66+
"CONTRIBUTING.md",
67+
"Makefile",
68+
"scent.py",
6769
]:
68-
src = os.path.join(TMP, CONFIG['project_name'], filename)
70+
src = os.path.join(TMP, CONFIG["project_name"], filename)
6971
dst = os.path.join(CWD, filename)
7072
print("Updating " + filename)
7173
with suppress(FileNotFoundError):
7274
shutil.copy(src, dst)
7375

7476

75-
if __name__ == '__main__':
77+
if __name__ == "__main__":
7678
install()
7779
run()
7880
copy()

bin/verchew

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
3-
3+
#
44
# The MIT License (MIT)
55
# Copyright © 2016, Jace Browning
66
#
@@ -47,11 +47,14 @@ else:
4747
import configparser
4848
from urllib.request import urlretrieve
4949

50-
__version__ = '3.1.1'
50+
__version__ = '3.4'
5151

5252
SCRIPT_URL = (
5353
"https://raw.githubusercontent.com/jacebrowning/verchew/main/verchew/script.py"
5454
)
55+
WRAPPER_URL = (
56+
"https://raw.githubusercontent.com/jacebrowning/verchew/main/verchew/wrapper.sh"
57+
)
5558

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

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

114117
if args.vendor:
115-
vendor_script(args.vendor)
118+
vendor_script(SCRIPT_URL, args.vendor)
119+
vendor_script(WRAPPER_URL, args.vendor + "-wrapper")
116120
sys.exit(0)
117121

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

173177

174-
def vendor_script(path):
178+
def vendor_script(url, path):
175179
root = os.path.abspath(os.path.join(path, os.pardir))
176180
if not os.path.isdir(root):
177181
log.info("Creating directory %s", root)
178182
os.makedirs(root)
179183

180-
log.info("Downloading %s to %s", SCRIPT_URL, path)
181-
urlretrieve(SCRIPT_URL, path)
184+
log.info("Downloading %s to %s", url, path)
185+
urlretrieve(url, path)
182186

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

243+
data[name]['optional'] = data[name].get(
244+
'optional', 'false'
245+
).strip().lower() in ('true', 'yes', 'y', True)
246+
239247
return data
240248

241249

@@ -260,7 +268,7 @@ def check_dependencies(config):
260268
if "not found" in output:
261269
actual = "Not found"
262270
else:
263-
actual = output.split('\n')[0].strip('.')
271+
actual = output.split('\n', maxsplit=1)[0].strip('.')
264272
expected = settings['version'] or "<anything>"
265273
print("{0}: {1}, EXPECTED: {2}".format(name, actual, expected))
266274
show(
@@ -280,30 +288,44 @@ def get_version(program, argument=None):
280288
if argument is None:
281289
args = [program, '--version']
282290
elif argument:
283-
args = [program, argument]
291+
args = [program] + argument.split()
284292
else:
285293
args = [program]
286294

287295
show("$ {0}".format(" ".join(args)))
288296
output = call(args)
289297
lines = output.splitlines()
290-
show(lines[0] if lines else "<nothing>")
298+
299+
if lines:
300+
for line in lines:
301+
if any(char.isdigit() for char in line):
302+
show(line)
303+
break
304+
else:
305+
show(lines[0])
306+
else:
307+
show("<nothing>")
291308

292309
return output
293310

294311

295312
def match_version(pattern, output):
296-
if "not found" in output.split('\n')[0]:
313+
lines = output.splitlines()
314+
if "not found" in lines[0]:
297315
return False
298316

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

301-
log.debug("Matching %s: %s", regex, output)
302-
match = re.match(regex, output)
303-
if match is None:
304-
match = re.match(r'.*[^\d.]' + regex, output)
319+
for line in lines:
320+
log.debug("Matching %s: %s", regex, line)
321+
match = re.match(regex, line)
322+
if match is None:
323+
log.debug("Matching %s: %s", regex, line)
324+
match = re.match(r'.*[^\d.]' + regex, line)
325+
if match:
326+
return True
305327

306-
return bool(match)
328+
return False
307329

308330

309331
def call(args):

0 commit comments

Comments
 (0)