Skip to content

refactor: use pathlib for the paths that can take it - #347

Merged
jdhughes-dev merged 1 commit into
developfrom
pathlib-abspath-dirname
Aug 19, 2026
Merged

refactor: use pathlib for the paths that can take it#347
jdhughes-dev merged 1 commit into
developfrom
pathlib-abspath-dirname

Conversation

@jdhughes-dev

Copy link
Copy Markdown
Collaborator

Converts the os.path.abspath and os.path.dirname calls whose pathlib equivalent behaves the same, and takes the vs2dt main source from the parent directory rather than from a ".." segment that abspath had to normalize away.

Four are deliberately kept and now carry a comment saying why:

  • pymake.py and pymake_base.py compare os.path.dirname against a directory, and a target with no directory has to give "" rather than the "." Path.parent gives.
  • pymake.py uses os.path.abspath as the key for the build targets list, where removing the ".." segments is what makes two spellings of a target count as one.
  • _meson_build.py needs os.path.relpath, which has no pathlib equivalent before python 3.12.

Verified by exercising _update_vs2dt_files on a source tree, and the mfusg makefile is byte identical.

Convert the os.path.abspath and os.path.dirname calls whose pathlib
equivalent behaves the same, and take the vs2dt main source from the
parent directory rather than from a ".." segment abspath had to normalize
away.

The four that are left are commented with what they rely on: dirname
giving the empty string for a target with no directory, which Path.parent
gives as ".", and abspath removing the ".." segments so that two spellings
of a target count as one in the build targets list.
@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.894%. Comparing base (325919c) to head (cd117ba).

Files with missing lines Patch % Lines
pymake/pymake.py 50.000% 1 Missing ⚠️
pymake/pymake_build_apps.py 0.000% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##           develop      #347       +/-   ##
=============================================
- Coverage   80.911%   80.894%   -0.018%     
=============================================
  Files           20        20               
  Lines         3269      3266        -3     
=============================================
- Hits          2645      2642        -3     
  Misses         624       624               
Files with missing lines Coverage Δ
pymake/pymake_base.py 90.125% <ø> (ø)
pymake/utils/_meson_build.py 90.311% <ø> (ø)
pymake/utils/_usgs_src_update.py 95.638% <100.000%> (-0.027%) ⬇️
pymake/utils/usgsprograms.py 76.315% <ø> (ø)
pymake/pymake.py 75.146% <50.000%> (ø)
pymake/pymake_build_apps.py 79.824% <0.000%> (-0.176%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jdhughes-dev
jdhughes-dev merged commit 799dd10 into develop Aug 19, 2026
23 checks passed
@jdhughes-dev
jdhughes-dev deleted the pathlib-abspath-dirname branch August 19, 2026 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant