Skip to content

Commit 457e6a6

Browse files
authored
bpo-45561: Run smelly.py tool from $(srcdir) (GH-29138)
1 parent 0242094 commit 457e6a6

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

Makefile.pre.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2420,7 +2420,7 @@ distclean: clobber
24202420

24212421
# Check that all symbols exported by libpython start with "Py" or "_Py"
24222422
smelly: @DEF_MAKE_RULE@
2423-
$(RUNSHARED) ./$(BUILDPYTHON) Tools/scripts/smelly.py
2423+
$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/smelly.py
24242424

24252425
# Find files with funny names
24262426
funny:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Run smelly.py tool from $(srcdir).

Tools/scripts/smelly.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,11 @@ def check_library(library, dynamic=False):
108108

109109
def check_extensions():
110110
print(__file__)
111-
srcdir = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
112-
filename = os.path.join(srcdir, "pybuilddir.txt")
111+
# This assumes pybuilddir.txt is in same directory as pyconfig.h.
112+
# In the case of out-of-tree builds, we can't assume pybuilddir.txt is
113+
# in the source folder.
114+
config_dir = os.path.dirname(sysconfig.get_config_h_filename())
115+
filename = os.path.join(config_dir, "pybuilddir.txt")
113116
try:
114117
with open(filename, encoding="utf-8") as fp:
115118
pybuilddir = fp.readline()
@@ -118,7 +121,7 @@ def check_extensions():
118121
return True
119122

120123
print(f"Check extension modules from {pybuilddir} directory")
121-
builddir = os.path.join(srcdir, pybuilddir)
124+
builddir = os.path.join(config_dir, pybuilddir)
122125
nsymbol = 0
123126
for name in os.listdir(builddir):
124127
if not name.endswith(".so"):

0 commit comments

Comments
 (0)