Skip to content

Commit

Permalink
Pass Distribution object back from subprocess
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
rotu committed Apr 24, 2020
1 parent 9066cc8 commit fa54f30
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 22 deletions.
25 changes: 5 additions & 20 deletions colcon_python_setup_py/package_identification/python_setup_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,25 +277,6 @@ def _get_setup_information(setup_py, *, env=None):
'dist = run_setup('
" 'setup.py', script_args=('--dry-run',), stop_after='config')",

"skip_keys = ('cmdclass', 'distclass', 'ext_modules', 'metadata')",
'data = {'
' key: value for key, value in dist.__dict__.items() '
' if ('
# skip private properties
" not key.startswith('_') and "
# skip methods
' not callable(value) and '
# skip objects whose representation can't be evaluated
' key not in skip_keys and '
# skip display options since they have no value, using metadata instead
' key not in dist.display_option_names'
' )'
'}',
"data['metadata'] = {"
' k: v for k, v in dist.metadata.__dict__.items() '
# skip values with custom type OrderedSet
" if k not in ('license_files', 'provides_extras')}",

'pickle.dump(data, sys.stdout.buffer)']

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

return pickle.loads(output)
# turn into a dict for backwards compatibility
dist_dict = dist.__dict__.copy()
dist_dict['metadata'] = dist.metadata.__dict__
return dist_dict
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ keywords = colcon
[options]
install_requires =
colcon-core>=0.3.10
setuptools
# DistributionMetadata not picklable in these versions https://github.com/pypa/setuptools/issues/1888
setuptools !=42.*,!=43.*,!=44.*,!=45.*
packages = find:
tests_require =
flake8>=3.6.0
Expand Down
1 change: 0 additions & 1 deletion test/spell_check.words
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
apache
chdir
colcon
distclass
hashable
iterdir
lstrip
Expand Down

0 comments on commit fa54f30

Please sign in to comment.