这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@shadowwalkersb
Copy link
Contributor

Currently, the activation script paths are gathered with glob.glob which returns its results in arbitrary order. AFAICT the resulting results are not sorted or manipulated anywhere else. This caused us problems when we added an activation script to a metapackage of ours where we wanted to manipulate the environment variables set by the new compilers, ContinuumIO/anaconda-issues#9172. This PR sorts the resulting list of activation scripts. This way packages can ensure when their activation scripts are run by naming them accordingly. As @msarahan suggested, a script named zz_patch_flags.sh will run after compiler scripts that are activate-*.sh.

Here, sorting is done in two places, but one of them is redundant. I am submitting both of them, but will remove one upon feedback.

@shadowwalkersb shadowwalkersb requested a review from a team as a code owner April 17, 2018 21:05
@shadowwalkersb
Copy link
Contributor Author

cc @mingwandroid , @msarahan

return self.path_conversion(sorted(glob(join(
prefix, 'etc', 'conda', 'activate.d', '*' + self.script_extension
)))
))))
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's keep all the logic in this helper method. So prefer this over the change on line 173.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed and done.

Copy link
Contributor

@kalefranz kalefranz left a comment

Choose a reason for hiding this comment

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

I didn't realize glob() returned in random order. This is a good catch.

))))

def _get_deactivate_scripts(self, prefix):
return self.path_conversion(glob(join(
Copy link
Contributor

Choose a reason for hiding this comment

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

We should also do the same thing here. Except to be technically correct, it should be sorted() with a reverse=True flag.

@kalefranz
Copy link
Contributor

The test failures are a list vs tuple mismatch. I think if you remove the line 173 change we should be good on those specific test failures.

@mingwandroid
Copy link
Contributor

I think sorted alphanumerically is better than random, but I also think topologically sorting first then alphanumerically after is best.

@kalefranz
Copy link
Contributor

kalefranz commented Apr 17, 2018 via email

@shadowwalkersb
Copy link
Contributor Author

Anything else needs to be done here? When can we expect this to go in?

Copy link
Contributor

@kalefranz kalefranz left a comment

Choose a reason for hiding this comment

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

LGTM

@kalefranz kalefranz merged commit 65e50ed into conda:master Apr 19, 2018
@shadowwalkersb shadowwalkersb deleted the activation-scripts-order branch April 19, 2018 14:33
@jakirkham
Copy link
Member

Is there an issue for using topo sort for this?

@kalefranz
Copy link
Contributor

@jakirkham The launch point there is #5082

@mbargull
Copy link
Member

xref: #6338 (comment)

@github-actions
Copy link

github-actions bot commented Sep 3, 2021

Hi there, thank you for your contribution to Conda!

This pull request has been automatically locked since it has not had recent activity after it was closed.

Please open a new issue or pull request if needed.

@github-actions github-actions bot added the locked [bot] locked due to inactivity label Sep 3, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cli pertains to the CLI interface locked [bot] locked due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants