Skip to content
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

Add only those sys.paths which contain an ansible_collections directory path #322

Merged
merged 6 commits into from
Aug 29, 2023

Conversation

audgirka
Copy link
Contributor

@audgirka audgirka commented Aug 24, 2023

Fixes: #323

Depends on #325

@audgirka audgirka requested a review from a team as a code owner August 24, 2023 10:23
@github-actions github-actions bot added the bug Something isn't working label Aug 24, 2023
Copy link
Member

@ssbarnea ssbarnea left a comment

Choose a reason for hiding this comment

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

I would be far more confident about a test that asserts the fact that a collection that is installed under sitepackages is found after making this change instead of just checking the addition of the folder to the list.

What I do not know is how we can get a collection installed there in order to perform this test.

@cidrblock Any ideas?

The reason I am asking this is because I am not sure if the addition of the path really works and I find behavior test as adding more confidence than one that only does a unit-testing.

@zhan9san
Copy link
Contributor

Plz kindly take a look at this comment
#318 (comment)

@zhan9san
Copy link
Contributor

Do we really need to add isolated in condition here?

#318 (comment)

@audgirka audgirka force-pushed the fix/add_site_package branch from 74441ba to 686e545 Compare August 25, 2023 11:02
@cidrblock cidrblock self-requested a review August 25, 2023 13:51
Copy link
Collaborator

@cidrblock cidrblock left a comment

Choose a reason for hiding this comment

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

I think this PR fixes #323 but I don't see specifically how it addresses ansible/molecule#4015. Can the title be modified please?

WRT to the change in tests, My preference is to test all permutations of the conditions evalutated in the code.

@cidrblock
Copy link
Collaborator

I would be far more confident about a test that asserts the fact that a collection that is installed under sitepackages is found after making this change instead of just checking the addition of the folder to the list.

What I do not know is how we can get a collection installed there in order to perform this test.

@cidrblock Any ideas?

The reason I am asking this is because I am not sure if the addition of the path really works and I find behavior test as adding more confidence than one that only does a unit-testing.

@ssbarnea You are 100% right. The test I added could be improved. The only reason to iterate sys.paths is because it exposes the site-packages directories where a full ansible might be found. I will PR a change to the test shortly.

@cidrblock
Copy link
Collaborator

@zhan9san I have captured your concerns as new issues

#323
#324

@audgirka audgirka changed the title Add site package paths to collection_paths Add only those sys.paths which contain an ansible_collections directory Aug 25, 2023
@audgirka audgirka changed the title Add only those sys.paths which contain an ansible_collections directory Add only those sys.paths which contain an ansible_collections directory Aug 25, 2023
@audgirka audgirka changed the title Add only those sys.paths which contain an ansible_collections directory Add only those sys.paths which contain an ansible_collections directory path Aug 25, 2023
@audgirka
Copy link
Contributor Author

audgirka commented Aug 25, 2023

I think this PR fixes #323 but I don't see specifically how it addresses ansible/molecule#4015. Can the title be modified please?

WRT to the change in tests, My preference is to test all permutations of the conditions evalutated in the code.

@cidrblock Because the issue states that the collection was installed in the site packages path which was not added to the collection_paths earlier.
Now since we're adding it, this will solve the issue.

@audgirka audgirka requested review from cidrblock and ssbarnea August 25, 2023 15:40
Copy link
Collaborator

@cidrblock cidrblock left a comment

Choose a reason for hiding this comment

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

one comment

src/ansible_compat/runtime.py Outdated Show resolved Hide resolved
@cidrblock
Copy link
Collaborator

I would be far more confident about a test that asserts the fact that a collection that is installed under sitepackages is found after making this change instead of just checking the addition of the folder to the list.

What I do not know is how we can get a collection installed there in order to perform this test.

@cidrblock Any ideas?

The reason I am asking this is because I am not sure if the addition of the path really works and I find behavior test as adding more confidence than one that only does a unit-testing.

@ssbarnea I think #325 is a better test, LMKWYT

@zhan9san
Copy link
Contributor

@cidrblock Because the issue states that the collection was installed in the site packages path which was not added to the collection_paths earlier.
Now since we're adding it, this will solve the issue.

I agree with @cidrblock that this PR only fixes the issue described in #323 .

And I think the issue described by @lod in ansible/molecule#4015 (comment) is fixed by #318

But the issue described by @isuftin in ansible/molecule#4015 (comment) is not related to this PR.

@audgirka audgirka requested a review from cidrblock August 29, 2023 09:35
@audgirka audgirka merged commit d736af6 into main Aug 29, 2023
@audgirka audgirka deleted the fix/add_site_package branch August 29, 2023 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unecessary addition of all sys.path entries
4 participants