-
Notifications
You must be signed in to change notification settings - Fork 55
Better python package identification #215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
rotu
wants to merge
7
commits into
colcon:master
from
RoverRobotics-forks:better_package_identification
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5d17a59
Rework Package identification tests
rotu dd03ac4
add xfail to known word list
dirk-thomas a9f8179
Add a test for setup.py with no name
rotu 70c5c4e
Better package identification
rotu efde854
remove xfail from known words again
dirk-thomas 1864386
remove xfail for new test
rotu 3f670a8
switch to ProcessPool
rotu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # Copyright 2019 Rover Robotics via Dan Rose | ||
| # Licensed under the Apache License, Version 2.0 | ||
|
|
||
| import distutils.core | ||
| import os | ||
|
|
||
|
|
||
| def run_setup_py(cwd: str, env: dict, script_args=(), stop_after='run'): | ||
| """ | ||
| Modify the current process and run setup.py. | ||
|
|
||
| This should be run in a subprocess so as not to dirty the state of the | ||
| current process. | ||
|
|
||
| :param cwd: Absolute path to a directory containing a setup.py script | ||
| :param env: Environment variables to set before running setup.py | ||
| :param script_args: command-line arguments to pass to setup.py | ||
| :param stop_after: which | ||
| :returns: The properties of a Distribution object, minus some useless | ||
| and/or unpicklable properties | ||
| """ | ||
| # need to be in setup.py's parent dir to detect any setup.cfg | ||
| os.chdir(cwd) | ||
|
|
||
| os.environ.clear() | ||
| os.environ.update(env) | ||
|
|
||
| result = distutils.core.run_setup( | ||
| 'setup.py', script_args=script_args, stop_after=stop_after) | ||
|
|
||
| # could just return all attrs in result.__dict__, but we take this | ||
| # opportunity to filter a few things that don't need to be there | ||
| return { | ||
| attr: value for attr, value in result.__dict__.items() | ||
| if ( | ||
| # These *seem* useful but always have the value 0. | ||
| # Look for their values in the 'metadata' object instead. | ||
| attr not in result.display_option_names | ||
| # Getter methods | ||
| and not callable(value) | ||
| # Private properties | ||
| and not attr.startswith('_') | ||
| # Objects that are generally not picklable | ||
| and attr not in ('cmdclass', 'distclass', 'ext_modules') | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ deps | |
| descs | ||
| getpid | ||
| iterdir | ||
| localhost | ||
| lstrip | ||
| mkdtemp | ||
| nargs | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.