Skip to content

Commit 5726567

Browse files
committed
Pass Distribution object back from subprocess
Upstream change removes the need for much of our workaround: pypa/setuptools#1890 I do not remove turning the object into a dict, as it would change the public signature of `get_setup_information`.
1 parent 5d8e22c commit 5726567

3 files changed

Lines changed: 8 additions & 23 deletions

File tree

colcon_python_setup_py/package_identification/python_setup_py.py

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -275,26 +275,7 @@ def _get_setup_information(setup_py, *, env=None):
275275
'dist = run_setup('
276276
" 'setup.py', script_args=('--dry-run',), stop_after='config')",
277277

278-
"skip_keys = ('cmdclass', 'distclass', 'ext_modules', 'metadata')",
279-
'data = {'
280-
' key: value for key, value in dist.__dict__.items() '
281-
' if ('
282-
# skip private properties
283-
" not key.startswith('_') and "
284-
# skip methods
285-
' not callable(value) and '
286-
# skip objects whose representation can't be evaluated
287-
' key not in skip_keys and '
288-
# skip display options since they have no value, using metadata instead
289-
' key not in dist.display_option_names'
290-
' )'
291-
'}',
292-
"data['metadata'] = {"
293-
' k: v for k, v in dist.metadata.__dict__.items() '
294-
# skip values with custom type OrderedSet
295-
" if k not in ('license_files', 'provides_extras')}",
296-
297-
'pickle.dump(data, sys.stdout)']
278+
'pickle.dump(dist, sys.stdout)']
298279

299280
# invoke distutils.core.run_setup() in a separate interpreter
300281
cmd = [
@@ -303,5 +284,9 @@ def _get_setup_information(setup_py, *, env=None):
303284
cmd, stdout=subprocess.PIPE,
304285
cwd=os.path.abspath(str(setup_py.parent)), check=True, env=env)
305286
output = result.stdout
287+
dist = pickle.loads(output)
306288

307-
return pickle.loads(output)
289+
# turn into a dict for backwards compatibility
290+
dist_dict = dist.__dict__.copy()
291+
dist_dict['metadata'] = dist.metadata.__dict__
292+
return dist_dict

setup.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ keywords = colcon
2727
[options]
2828
install_requires =
2929
colcon-core>=0.3.10
30-
setuptools
30+
# DistributionMetadata not picklable in these versions https://github.com/pypa/setuptools/issues/1888
31+
setuptools !=42.*,!=43.*,!=44.*,!=45.*
3132
packages = find:
3233
tests_require =
3334
flake8>=3.6.0

test/spell_check.words

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
apache
22
chdir
33
colcon
4-
distclass
54
hashable
65
iterdir
76
lstrip

0 commit comments

Comments
 (0)