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

Fix rez-pip on Windows #1155

Conversation

manuelkoester
Copy link

Resolves #904 , #1024

This is my first PR here, please let me know if there's more to add. :)

Intended change

This should now fix the issues with rez-pip on windows, which previously was not able to find python.

Implementation

The implementation by @ColinKennedy is basically taken from here and therefore based on another library called whichcraft. The library function is extended to also take an environment parameter.
The library is BSD licensed and I tried to include the relevant copyright notices.

Tested on

Windows 10
Rez 2.98
Python 3.9.7


Suggestions/feedback welcome!

Cheers,
Manuel

Copy link
Contributor

@davidlatwe davidlatwe left a comment

Choose a reason for hiding this comment

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

Just did a visual review as my two cents, also pinning @nerdvegas for enabling the GitHub workflow.

Comment on lines -39 to -41
default_pathext = \
'.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC'
pathext = env.get("PATHEXT", default_pathext).split(os.pathsep)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we better keep the default_pathext, for backward compat.

Comment on lines +3 to 7

# Source: https://github.com/cookiecutter/whichcraft/blob/0.6.1/whichcraft.py
# Copyright (c) 2015-2016, Daniel Roy Greenfeld
# All rights reserved.

Copy link
Contributor

@davidlatwe davidlatwe Nov 18, 2021

Choose a reason for hiding this comment

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

Not sure if this is okay, since Rez is going to be re-licensed under Apache2.0 (#1119) and the whichcraft is under BSD-3.

if any(cmd.lower().endswith(ext.lower()) for ext in pathext):
files = [cmd]
else:
files = [cmd + ext for ext in pathext]
Copy link
Contributor

Choose a reason for hiding this comment

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

And just for consistency, ensure the ext is lowercase.

Suggested change
files = [cmd + ext for ext in pathext]
files = [cmd + ext.lower() for ext in pathext]

Comment on lines -60 to -61
# On windows the system paths might have %systemroot%
name = os.path.expandvars(name)
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 better keep this, see 4bf62bf.

@JeanChristopheMorinPerso
Copy link
Member

@davidlatwe I approved the workflows.

@nerdvegas
Copy link
Contributor

Hi Manuel,

Looks good, but there's a few things we need to do:

  1. Incorporate David's suggested changes, that all looks correct to me.
  2. BSD-3 is compatible with Apache2.0 so we're good there. HOWEVER, we do need to include the licence in full, as well as copyright notice.
  3. I need you to sign off on Rez License Change: LGPLv3 to Apache2.0 #1119 before I can merge this PR. It's ok if this isn't done in time however, I can just merge the PR after the license change is done (and that's happening very soon).

The best way to deal with this imo is to add whichcraft as a vendored lib (see others in vendor/). However, I would like to do this in a way that lets us easily see what modifications have been made also (unfortunately this wasn't done in existing vendored libs, live and learn). To that end, may I suggest:

  1. We add whichcraft as a vendored lib, unmodified, and we do a release with this added
  2. We put in a separate PR which adds the modifications, and in this we include a comment referencing the commit hash of the original added in (1).

This way, if we ever need to update the vendored lib while keeping our rez-specific changes, we have enough info to rebase on.

Action items:

  • create PR for adding unmodified whichcraft vendored lib
  • create PR incorporating the modifications in this PR, including those suggested by David

With this in mind let's leave this PR as-is and keep it for reference only, and I'll just close it after we've done all of the above.

Thx
A

@nerdvegas
Copy link
Contributor

@nerdvegas
Copy link
Contributor

See #1157

@nerdvegas nerdvegas closed this Nov 19, 2021
Sign up for free to 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.

rez-pip not working ?
4 participants