Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pymake/pymake.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def compress_targets(self):
# set appdir based on first target, assumes that the path
# for all of the targets are the same
if appdir is None:
appdir = os.path.dirname(target)
appdir = str(Path(target).parent)
# determine files in appdir if no applications build at this
# time (--keep command line argument)
else:
Expand Down Expand Up @@ -529,6 +529,8 @@ def set_build_target_bool(self, target=None):
target = self.target

if self.appdir is not None:
# os.path.dirname rather than Path.parent, because a target
# with no directory has to compare unequal to an appdir of "."
if os.path.dirname(self.target) != self.appdir:
target = str(Path(self.appdir) / Path(target).name)

Expand Down Expand Up @@ -646,7 +648,7 @@ def _set_extrafiles(self):

# evaluate extrafiles type
if extrafiles:
srcdir = os.path.abspath(self.srcdir)
srcdir = Path(self.srcdir).absolute()
if isinstance(extrafiles, list):
for idx, value in enumerate(extrafiles):
fpth = str(Path(srcdir) / value)
Expand Down Expand Up @@ -820,6 +822,8 @@ def update_build_targets(self):
-------

"""
# os.path.abspath rather than Path.absolute, because it removes the
# ".." segments and so two spellings of a target count as one
if os.path.abspath(self.target) not in self.build_targets:
if self.verbose:
print(f"adding {self.target} to build_targets list")
Expand Down
4 changes: 3 additions & 1 deletion pymake/pymake_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,9 @@ def _write_makedefaults(
line += "endif\n\n"
f.write(line)

# get path to executable
# get path to executable. os.path.dirname rather than
# Path.parent, because a target with no directory has to give
# the empty string here rather than "."
dpth = os.path.dirname(target)
if len(dpth) > 0:
dpth = os.path.relpath(dpth, make_dir)
Expand Down
3 changes: 1 addition & 2 deletions pymake/pymake_build_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

"""

import os
import shutil
import sys
from datetime import datetime
Expand Down Expand Up @@ -118,7 +117,7 @@ def build_apps(
if appdir is None:
base_pth = "."
else:
base_pth = os.path.dirname(appdir)
base_pth = str(Path(appdir).parent)

# set the meson directory if a pymake object was not passed in
if pymake_object is None:
Expand Down
2 changes: 2 additions & 0 deletions pymake/utils/_meson_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ def meson_setup(
else:
command_list.append("--prefix=$(pwd)")

# os.path, because the install directory is relative to the build
# file and Path.relative_to cannot walk up before python 3.12
libdir = os.path.relpath(os.path.abspath(appdir), os.path.abspath(mesondir))
command_list.append(f"--libdir={libdir}")
command_list.append(f"--bindir={libdir}")
Expand Down
6 changes: 2 additions & 4 deletions pymake/utils/_usgs_src_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,12 +596,10 @@ def _update_vs2dt_files(srcdir, **kwargs):

"""
# move the main source into the source directory
f1 = Path(srcdir) / ".." / "vs2dt3_3.f"
f1 = os.path.abspath(f1)
f1 = (Path(srcdir).parent / "vs2dt3_3.f").absolute()
if not Path(f1).is_file():
raise OSError(f"{f1} does not exist")
f2 = Path(srcdir) / "vs2dt3_3.f"
f2 = os.path.abspath(f2)
f2 = (Path(srcdir) / "vs2dt3_3.f").absolute()
shutil.move(f1, f2)
if not Path(f2).is_file():
raise OSError(f"{f2} does not exist")
Expand Down
1 change: 0 additions & 1 deletion pymake/utils/usgsprograms.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ def _build_usgs_database(self):
-------

"""
# pth = os.path.dirname(os.path.abspath(pymake.__file__))
fpth = Path(__file__).parent / PROGRAM_DATA_FILE
with open(fpth, "rb") as f:
programs = tomllib.load(f)["program"]
Expand Down
Loading