Skip to content

Commit

Permalink
For consistency, ensure Extension.sources is always a pathlib.Path ob…
Browse files Browse the repository at this point in the history
…ject and adjust expectations in tests.
  • Loading branch information
jaraco committed Mar 3, 2024
1 parent 45a232a commit 9cc0c93
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion distutils/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
modules in setup scripts."""

import os
import pathlib
import warnings

# This class is really only used by the "build_ext" command, so it might
Expand Down Expand Up @@ -115,7 +116,7 @@ def __init__(
)

self.name = name
self.sources = sources
self.sources = list(map(pathlib.Path, sources))
self.include_dirs = include_dirs or []
self.define_macros = define_macros or []
self.undef_macros = undef_macros or []
Expand Down
3 changes: 2 additions & 1 deletion distutils/tests/test_build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import textwrap
import site
import contextlib
import pathlib
import platform
import tempfile
import importlib
Expand Down Expand Up @@ -335,7 +336,7 @@ def test_get_source_files(self):
dist = Distribution({'name': 'xx', 'ext_modules': modules})
cmd = self.build_ext(dist)
cmd.ensure_finalized()
assert cmd.get_source_files() == ['xxx']
assert cmd.get_source_files() == [pathlib.Path('xxx')]

def test_unicode_module_names(self):
modules = [
Expand Down
2 changes: 1 addition & 1 deletion distutils/tests/test_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_extension_init(self):
with pytest.raises(AssertionError):
Extension('name', ['file', 1])
ext = Extension('name', ['file1', 'file2'])
assert ext.sources == ['file1', 'file2']
assert ext.sources == [Path('file1'), Path('file2')]
ext = Extension('name', [Path('file1'), Path('file2')])
assert ext.sources == [Path('file1'), Path('file2')]

Expand Down

0 comments on commit 9cc0c93

Please sign in to comment.