Skip to content

Mock the actual setup provider defined in setup.py - #120

Merged
pombredanne merged 4 commits into
aboutcode-org:mainfrom
bennati:pr-116-2
Mar 1, 2023
Merged

Mock the actual setup provider defined in setup.py#120
pombredanne merged 4 commits into
aboutcode-org:mainfrom
bennati:pr-116-2

Conversation

@bennati

Copy link
Copy Markdown
Contributor

Currently. setup is always mocked using distutils.core but this might cause issues with certain packages. Fix this behavior by parsing the setup.py file for the correct module to import.

Closes: #116

Signed-off-by: Bennati, Stefano stefano.bennati@here.com

@bennati
bennatiforce-pushed the pr-116-2 branch 2 times, most recently from 2139cd6 to b3b27e5CompareJanuary 20, 2023 08:25
@TG1999

Copy link
Copy Markdown
Contributor

@bennati thanks! please provide a few tests with the files you faced this issue.

@TG1999

Copy link
Copy Markdown
Contributor

@bennati you need to regenerate the test outputs, the dependencies have been updated for the tests so for fixing tests in test_cli use this command:

PYINSP_REGEN_TEST_FIXTURES=yes pytest -vvs

for fixing tests in test_resolution, please compare the changes from the expected output.

@bennati

bennati commented Jan 24, 2023

Copy link
Copy Markdown
ContributorAuthor

@TG1999 EDIT I cherry-picked the commits that fix the tests from the other PR #117

@bennati

Copy link
Copy Markdown
ContributorAuthor

Is there anything left to do before we can merge this?

@pombredanne

Copy link
Copy Markdown
Member

Thanks. Let me check! there seems to be something weird with your latest commit as make valid should not have changed etc/ and src/_packagedcode/

@bennati

Copy link
Copy Markdown
ContributorAuthor

@pombredanne should I just refactor the last commit and remove the changes to the unrelated files?

@npatel2509

Copy link
Copy Markdown

@pombredanne Please suggest if there is anything left or a blocker to merge this MR?

@TG1999

Copy link
Copy Markdown
Contributor

@bennati please remove the changes to unrelated files.

@bennati
bennatiforce-pushed the pr-116-2 branch 2 times, most recently from fa3a091 to 3447f9eCompareFebruary 7, 2023 09:09
@bennati

Copy link
Copy Markdown
ContributorAuthor

Removed the unrelated changes

@TG1999TG1999 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@npatel2509

Copy link
Copy Markdown

@pombredanne please suggest if any further modifications is require or if we can proceed to merge the changes?

@pombredannepombredanne left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM overall! but I have a few nitpickings for your consideration.

Comment threadsrc/python_inspector/setup_py_live_eval.py Outdated
"defaulting to 'distutils.core'."
)
setup_provider = "distutils.core"
exec(f"import {setup_provider}")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure that we can get something that's safe to work here. In particular importing setuptools since version 66 has several possible problems... Could we do better and not need to import this? If we really need to import it, we should IMHO vendor a version of setuptools that before version 66?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed it and imported both libraries

@bennati
bennatiforce-pushed the pr-116-2 branch 4 times, most recently from a40a70a to a4e60d9CompareFebruary 15, 2023 08:11
@bennati

Copy link
Copy Markdown
ContributorAuthor

The tests keep failing despite all my attempts, help is appreciated!

@bennati
bennatiforce-pushed the pr-116-2 branch 2 times, most recently from b82cdb1 to a57af53CompareFebruary 20, 2023 15:34
@bennati
bennati requested review from TG1999 and removed request for pombredanneFebruary 20, 2023 17:15
@bennati
bennati requested review from pombredanne and removed request for TG1999February 20, 2023 17:15
@bennati

Copy link
Copy Markdown
ContributorAuthor

Tests are now successful, can we merge this?

@pombredanne

Copy link
Copy Markdown
Member

@bennati Would you mind to:

  1. undo the changes made strictly from black formatting
  2. run instead afterwards make valid that will only black format certain files but not all

And may review your commit streams for good message and a possible squash?
Thanks

Currently `setup` is always mocked using `distutils.core`
but this might cause issues with certain packages.
Fix this behavior by parsing the `setup.py` file for the correct
module to import.
Closes: aboutcode-org#116
Signed-off-by: Bennati, Stefano <stefano.bennati@here.com>
Signed-off-by: Bennati, Stefano <stefano.bennati@here.com>
@bennati
bennatiforce-pushed the pr-116-2 branch 2 times, most recently from d049c1b to cfdcedfCompareFebruary 23, 2023 09:44
Signed-off-by: Bennati, Stefano <stefano.bennati@here.com>
Signed-off-by: Bennati, Stefano <stefano.bennati@here.com>
@bennati

Copy link
Copy Markdown
ContributorAuthor

Done, we can squash all commits

@bennati

Copy link
Copy Markdown
ContributorAuthor

Another week has passed

@pombredannepombredanne left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks. Merging

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failure parsing dependences of pypi:packer.py

4 participants

@bennati@TG1999@pombredanne@npatel2509