Skip to content

Commit e971ad3

Browse files
committed
chore: update boilerplate
1 parent 5430a57 commit e971ad3

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

setup_boilerplate.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Package(setup_boilerplate.Package):
4444
import docutils.utils
4545
import setuptools
4646

47-
__version__ = '2022.08.27'
47+
__version__ = '2023.03.09'
4848

4949
_LOG = logging.getLogger(__name__)
5050

@@ -202,15 +202,9 @@ def visit_reference(self, node: docutils.nodes.reference) -> None:
202202
# we ignore the section part when checking if file exists
203203
path = path.with_name(path.name[:path.name.index('#')])
204204
try:
205-
resolved_path = path.resolve(strict=True)
205+
self.root_dir.joinpath(path).resolve(strict=True)
206206
except FileNotFoundError:
207207
return
208-
try:
209-
resolved_path.relative_to(self.root_dir)
210-
except ValueError:
211-
return
212-
if not path.is_file():
213-
return
214208
_LOG.debug('RelativeRefFinder: reference points to existing file')
215209
self.references.append(node)
216210

test/test_setup.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import importlib
44
import itertools
5+
import logging
56
import os
67
import pathlib
78
import runpy
@@ -12,16 +13,31 @@
1213
import typing as t
1314
import unittest
1415

15-
__version__ = '2022.08.27'
16+
__version__ = '2023.03.09'
17+
18+
_LOG = logging.getLogger(__name__)
19+
20+
21+
def expand_args_by_globbing_items(*args: str) -> t.Tuple[str, ...]:
22+
"""Expand a list of glob expressions."""
23+
cwd = pathlib.Path.cwd()
24+
expanded_args = []
25+
for arg in args:
26+
if '*' not in arg:
27+
expanded_args.append(arg)
28+
continue
29+
expanded_arg = [str(_.relative_to(cwd)) for _ in cwd.glob(arg)]
30+
assert expanded_arg, arg
31+
_LOG.debug('expanded arg "%s" to %s', arg, expanded_arg)
32+
expanded_args += expanded_arg
33+
_LOG.debug('expanded args to %s', expanded_args)
34+
return tuple(expanded_args)
1635

1736

1837
def run_program(*args, glob: bool = False) -> None:
1938
"""Run subprocess with given args. Use path globbing for each arg that contains an asterisk."""
2039
if glob:
21-
cwd = pathlib.Path.cwd()
22-
args = tuple(itertools.chain.from_iterable(
23-
list(str(_.relative_to(cwd)) for _ in cwd.glob(arg)) if '*' in arg else [arg]
24-
for arg in args))
40+
args = expand_args_by_globbing_items(*args)
2541
try:
2642
subprocess.run(args, check=True)
2743
except subprocess.CalledProcessError as err:
@@ -97,7 +113,7 @@ def import_module_member(module_name: str, member_name: str) -> t.Any:
97113
(None, 'setup.py', True), ('this file', 'setup.py', True), (None, 'test/test_setup.py', True),
98114
(None, 'test/test_setup.py#L98', True), ('line 5 of this file', 'setup.py#L5', True),
99115
(None, 'http://site.com', False), (None, '../something/else', False), (None, 'no.thing', False),
100-
(None, '/my/abs/path', False)]
116+
(None, '/my/abs/path', False), ('test dir', 'test', True)]
101117

102118

103119
def get_package_folder_name():
@@ -293,7 +309,7 @@ class Package(package): # pylint: disable=too-few-public-methods, missing-docst
293309

294310
@unittest.skipUnless(os.environ.get('TEST_PACKAGING') or os.environ.get('CI'),
295311
'skipping packaging tests for actual package')
296-
class IntergrationTests(unittest.TestCase):
312+
class IntegrationTests(unittest.TestCase):
297313
"""Test if the boilerplate can actually create a valid package."""
298314

299315
pkg_name = get_package_folder_name()

0 commit comments

Comments
 (0)