Skip to content

Commit

Permalink
pw_build: pw_python_distribution package_data support
Browse files Browse the repository at this point in the history
pw_python_distribution target setup.cfg files can add package_data
or entry_point sections now. Entries are already processed correctly
to not clobber others merged from existing pw_python_package targets.

Change-Id: Ia1d73aa9407452d08f1bac4cf078404d4afcb119
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/109550
Reviewed-by: Carlos Chinchilla <[email protected]>
Pigweed-Auto-Submit: Anthony DiGirolamo <[email protected]>
Commit-Queue: Auto-Submit <[email protected]>
  • Loading branch information
AnthonyDiGirolamo authored and CQ Bot Account committed Sep 8, 2022
1 parent 59ce3b3 commit 889c9b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
8 changes: 7 additions & 1 deletion pw_build/py/create_python_tree_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ def test_update_config_with_packages(self) -> None:
[options]
zip_safe = False
[options.package_data]
megapackage =
py.typed
''')
config = load_common_config(common_config=common_config,
append_git_sha=False,
Expand Down Expand Up @@ -230,6 +234,8 @@ def test_update_config_with_packages(self) -> None:
httpwatcher
[options.package_data]
megapackage =
py.typed
mars =
py.typed
saturn =
Expand All @@ -244,7 +250,7 @@ def test_update_config_with_packages(self) -> None:
expected_cfg_lines = [
line.rstrip() for line in expected_cfg.splitlines() if line
]
self.assertEqual(result_cfg_lines, expected_cfg_lines)
self.assertEqual(expected_cfg_lines, result_cfg_lines)


@parameterized.expand([
Expand Down
16 changes: 4 additions & 12 deletions pw_build/py/pw_build/create_python_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,6 @@ def load_common_config(common_config: Optional[Path] = None,
raise UnexpectedConfigSection(
f'[options] packages already defined as: {value}')

if config.has_section('options.package_data'):
raise UnexpectedConfigSection(
'[options.package_data] already defined as:\n' +
str(dict(config['options.package_data'].items())))

if config.has_section('options.entry_points'):
raise UnexpectedConfigSection(
'[options.entry_points] already defined as:\n' +
str(dict(config['options.entry_points'].items())))

# Append build metadata if applicable.
build_metadata = []
if append_date:
Expand All @@ -166,8 +156,10 @@ def update_config_with_packages(
) -> None:
"""Merge setup.cfg files from a set of python packages."""
config['options']['packages'] = 'find:'
config['options.package_data'] = {}
config['options.entry_points'] = {}
if not config.has_section('options.package_data'):
config['options.package_data'] = {}
if not config.has_section('options.entry_points'):
config['options.entry_points'] = {}

# Save a list of packages being bundled.
included_packages = [pkg.package_name for pkg in python_packages]
Expand Down

0 comments on commit 889c9b3

Please sign in to comment.