Skip to content

fix(setup): read() helper leaks an unclosed file handle (+1 more) - #17

Open
andrewwhitecdw wants to merge 1 commit into
NVIDIA:masterfrom
andrewwhitecdw:bugfix/setup-assorted-3f1f552a
Open

andrewwhitecdw wants to merge 1 commit into
NVIDIA:masterfrom
andrewwhitecdw:bugfix/setup-assorted-3f1f552a

Conversation

@andrewwhitecdw

@andrewwhitecdw andrewwhitecdw commented Jul 27, 2026 •

Copy link
Copy Markdown

This PR addresses 2 issues in setup.py.

Fix 1

fix: read() helper leaks an unclosed file handle

Fix: Replace:

def read(fname):
    return open(os.path.join(os.path.dirname(__file__), fname)).read()

with:

def read(fname):
    with open(os.path.join(os.path.dirname(__file__), fname)) as f:
        return f.read()

Fix 2

fix: package_data paths are project-root relative, not package relative

Fix: Apply patch:

--- a/setup.py
+++ b/setup.py
@@ -25,6 +25,8 @@ def get_all_files(find_dir):
 
 all_config_files = get_all_files(path.join(_ROOT, path.join('nvdu', 'config')))
 print("all_config_files: {}".format(all_config_files))
+package_rel_config_files = [path.relpath(f, path.join(_ROOT, 'nvdu')) for f in all_config_files]
+
 
 __version__ = '.'.join(map(str, __version_info__))
 
@@ -50,7 +52,7 @@ setup(
     keywords = "nvdu, nvidia",
     packages=find_packages(),
-    package_data={'': all_config_files},
+    package_data={'nvdu': package_rel_config_files},
     include_package_data=True,
     install_requires = [
         "numpy",

Files changed

  • setup.py

@andrewwhitecdw
andrewwhitecdw marked this pull request as ready for review July 27, 2026 21:22
@andrewwhitecdw

Copy link
Copy Markdown
Author

Closing this sweep-generated PR: PR has 2 commits; sweep requires exactly one commit per PR. It does not meet the sweep requirements (single signed-off commit).

Signed-off-by: Andrew White <andrewwhitecdw@users.noreply.github.com>
Signed-off-by: andrewwhitecdw <andrewwhitecdw@users.noreply.github.com>
@andrewwhitecdw
andrewwhitecdw force-pushed the bugfix/setup-assorted-3f1f552a branch from db08d5b to c5c52d9 Compare August 18, 2026 00:21
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