Skip to content

Commit e5bddbb

Browse files
scripts/ tests/: updated to match new location of pipcl.py in src/.
1 parent eda615d commit e5bddbb

8 files changed

Lines changed: 22 additions & 36 deletions

File tree

scripts/gh_release.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989

9090
pymupdf_dir = os.path.abspath( f'{__file__}/../..')
9191

92-
sys.path.insert(0, pymupdf_dir)
92+
sys.path.insert(0, f'{pymupdf_dir}/src')
9393
import pipcl
9494
del sys.path[0]
9595

scripts/sysinstall.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989

9090
pymupdf_dir = os.path.abspath( f'{__file__}/../..')
9191

92-
sys.path.insert(0, pymupdf_dir)
92+
sys.path.insert(0, f'{pymupdf_dir}/src')
9393
import pipcl
9494
del sys.path[0]
9595

scripts/test.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@
379379
pymupdf_dir_abs = os.path.abspath( f'{__file__}/../..')
380380

381381
try:
382-
sys.path.insert(0, pymupdf_dir_abs)
382+
sys.path.insert(0, f'{pymupdf_dir_abs}/src')
383383
import pipcl
384384
finally:
385385
del sys.path[0]
@@ -1140,13 +1140,9 @@ def get_requires_for_build_wheel(config_settings=None):
11401140
with open(f'{testdir}/pyproject.toml', 'w') as f:
11411141
f.write(textwrap.dedent('''
11421142
[build-system]
1143-
# We define required packages in setup.py:get_requires_for_build_wheel().
1144-
requires = []
1145-
1146-
# See pep-517.
1147-
#
1148-
build-backend = "setup"
1149-
backend-path = ["."]
1143+
requires = ['pipcl']
1144+
build-backend = 'setup'
1145+
backend-path = ['.']
11501146
'''))
11511147

11521148
shutil.copy2(f'{pymupdf_dir_abs}/pipcl.py', f'{testdir}/pipcl.py')
@@ -1513,16 +1509,17 @@ def getmtime(path):
15131509

15141510
def get_pyproject_required(ppt=None):
15151511
'''
1516-
Returns space-separated names of required packages in pyproject.toml. We
1512+
Returns list of names of required packages in pyproject.toml. We
15171513
do not do a proper parse and rely on the packages being in a single line.
15181514
'''
15191515
if ppt is None:
15201516
ppt = os.path.abspath(f'{__file__}/../../pyproject.toml')
15211517
with open(ppt) as f:
15221518
for line in f:
1523-
m = re.match('^requires = \\[(.*)\\]$', line)
1519+
m = re.match('^ *requires = \\[(.*)\\]$', line)
15241520
if m:
1525-
names = m.group(1).replace(',', ' ').replace('"', '')
1521+
names = m.group(1).replace(',', ' ').replace('"', '').replace("'", '')
1522+
names = names.split()
15261523
return names
15271524
else:
15281525
assert 0, f'Failed to find "requires" line in {ppt}'
@@ -1538,6 +1535,7 @@ def wrap_get_requires_for_build_wheel(dir_):
15381535
ppt = os.path.join(dir_abs, 'pyproject.toml')
15391536
if os.path.exists(ppt):
15401537
ret += get_pyproject_required(ppt)
1538+
log(f'{ret=}')
15411539
if os.path.exists(os.path.join(dir_abs, 'setup.py')):
15421540
sys.path.insert(0, dir_abs)
15431541
try:

tests/test_codespell.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,7 @@ def test_codespell():
4444
--ignore-multiline-regex 'codespell:ignore-begin.*codespell:ignore-end'
4545
''')
4646

47-
sys.path.append(root)
48-
try:
49-
import pipcl
50-
finally:
51-
del sys.path[0]
47+
import pipcl
5248

5349
git_files = pipcl.git_items(root)
5450

tests/test_general.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,15 +1082,11 @@ def test_cli_out():
10821082
import platform
10831083
import re
10841084
import subprocess
1085+
import pipcl
10851086
log_prefix = None
10861087
if os.environ.get('PYMUPDF_USE_EXTRA') == '0':
10871088
log_prefix = f'.+Using non-default setting from PYMUPDF_USE_EXTRA: \'0\''
10881089

1089-
sys.path.append(os.path.normpath(f'{__file__}/../..'))
1090-
try:
1091-
import pipcl
1092-
finally:
1093-
del sys.path[0]
10941090
pipcl.show_system()
10951091
def check(
10961092
expect_out,
@@ -1482,11 +1478,7 @@ def test_open2():
14821478
# of tests/resources/test_open2_expected.json regardless of the actual
14831479
# checkout directory.
14841480
print()
1485-
sys.path.append(root)
1486-
try:
1487-
import pipcl
1488-
finally:
1489-
del sys.path[0]
1481+
import pipcl
14901482
paths = pipcl.git_items(f'{root}/tests/resources')
14911483
paths = fnmatch.filter(paths, f'test_open2.*')
14921484
paths = [f'tests/resources/{i}' for i in paths]

tests/test_memory.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,7 @@ def test_4125():
178178
import psutil
179179

180180
root = os.path.normpath(f'{__file__}/../..')
181-
sys.path.insert(0, root)
182-
try:
183-
import pipcl
184-
finally:
185-
del sys.path[0]
181+
import pipcl
186182

187183
process = psutil.Process()
188184

tests/test_pylint.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,7 @@ def test_pylint():
102102

103103
root = os.path.abspath(f'{__file__}/../..')
104104

105-
sys.path.insert(0, root)
106105
import pipcl
107-
del sys.path[0]
108106

109107
# We want to run pylist on all of our src/*.py files so we find them with
110108
# `pipcl.git_items()`. However this seems to fail on github windows with
@@ -124,9 +122,11 @@ def test_pylint():
124122
'fitz___init__.py',
125123
'fitz_table.py',
126124
'fitz_utils.py',
125+
'pipcl.py',
127126
'pymupdf.py',
128127
'table.py',
129128
'utils.py',
129+
'wdev.py',
130130
]
131131
leafs.sort()
132132
try:
@@ -139,6 +139,9 @@ def test_pylint():
139139
leafs_git.sort()
140140
assert leafs_git == leafs, f'leafs:\n {leafs!r}\nleafs_git:\n {leafs_git!r}'
141141
for leaf in leafs:
142+
if leaf == 'pipcl.py':
143+
# Has various warnings but it's old code that we will eventually stop using.
144+
continue
142145
command += f' {directory}/{leaf}'
143146
print(f'Running: {command}')
144147
subprocess.run(command, shell=1, check=1)

tests/test_release.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
g_root_abs = os.path.normpath(f'{__file__}/../../')
99

1010
sys.path.insert(0, g_root_abs)
11+
sys.path.insert(0, f'{g_root_abs}/src')
1112
try:
1213
import pipcl
1314
import setup
1415
finally:
15-
del sys.path[0]
16+
del sys.path[0:2]
1617

1718
g_root = pipcl.relpath(g_root_abs)
1819

0 commit comments

Comments
 (0)