Skip to content

Commit fa54f30

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 9066cc8 commit fa54f30

File tree

3 files changed

+7
-22
lines changed

3 files changed

+7
-22
lines changed

colcon_python_setup_py/package_identification/python_setup_py.py

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -277,25 +277,6 @@ def _get_setup_information(setup_py, *, env=None):
277277
'dist = run_setup('
278278
" 'setup.py', script_args=('--dry-run',), stop_after='config')",
279279

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

301282
# invoke distutils.core.run_setup() in a separate interpreter
@@ -305,5 +286,9 @@ def _get_setup_information(setup_py, *, env=None):
305286
cmd, stdout=subprocess.PIPE,
306287
cwd=os.path.abspath(str(setup_py.parent)), check=True, env=env)
307288
output = result.stdout
289+
dist = pickle.loads(output)
308290

309-
return pickle.loads(output)
291+
# turn into a dict for backwards compatibility
292+
dist_dict = dist.__dict__.copy()
293+
dist_dict['metadata'] = dist.metadata.__dict__
294+
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)