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 issue 826 - correct python and pip fallback #878

Merged
merged 14 commits into from
Apr 30, 2020

Conversation

j0yu
Copy link
Contributor

@j0yu j0yu commented Apr 18, 2020

Installation Closes #826

Ran across #826 while trying to refactoring pip wiki fix PR #749. The CI for #749 is also added here since it requires the pip fallback fix

  1. Use python2 or python3 rather than python

    Currently with disgusting hack and thinking about either (need feedback!):

  2. Fallback to more compatible pip version if possible

j0yu added a commit to wwfxuk/rez that referenced this pull request Apr 18, 2020
@j0yu j0yu marked this pull request as ready for review April 20, 2020 09:54
src/rez/pip.py Outdated
python_version,
pip_version=pip_version or "latest"
)
for version in [pip_version, pip_version or "latest"]:
Copy link
Contributor

Choose a reason for hiding this comment

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

won't this attempt to find the same pip version twice, when pip_version is specified?

src/rez/pip.py Outdated

if not py_exe:
else: # No break from: for version in [pip_version,...]
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't believe I've been writing python this long and have never seen this. There's nothing technically wrong with this, but tbh I'd avoid it because it's so esoteric.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, I also find it fairly susceptible to indent/whitespace messing up logic if code was reformatted/refactored incorrectly hence the comment. I'll see if I can change it up a bit

src/rez/pip.py Outdated
# by RexExecutor.append_system_paths(), which calls Shell.get_syspaths()
shell_class = create_shell().__class__
current_syspaths = shell_class.syspaths
try:
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I don't think we should do this. Not because it's a hack per se, but because it isn't threadsafe. Ie this could alter syspaths in a context being created in another thread.

@nerdvegas
Copy link
Contributor

nerdvegas commented Apr 22, 2020

So wrt find_python_from_package:

  1. Why recreate a context containing just python, rather than possibly [python, pip]? The pip package isn't going to provide a python exe so this seems unnecessary?

  2. In terms of what to do about avoid system paths. We could fix this by providing some arg to execute_shell/etc like no_append_sys_paths. However it's not the right fix in the long run, when we (hopefully) have the more granular env-var control in place - once that's there, you should be able to do an execute_shell and redefine how any given var behaves anyway (eg inherits original value etc).

So 2. is basically your first suggestion, but I think no_append_sys_paths is a bit better naming since no_append_sys_paths=False is definitely default behaviour. I would go with this. Definitely not with the hack in place currently, see comments.

Cheers
A

j0yu added a commit to wwfxuk/rez that referenced this pull request Apr 22, 2020
@j0yu
Copy link
Contributor Author

j0yu commented Apr 22, 2020

  1. Why recreate a context containing just python, rather than possibly [python, pip]? The pip package isn't going to provide a python exe so this seems unnecessary?

Good point, the logic can be much simpler now too!

but I think no_append_sys_paths is a bit better naming since no_append_sys_paths = False is definitely default behaviour. I would go with this.

Cool, I'll go with

@j0yu
Copy link
Contributor Author

j0yu commented Apr 22, 2020

Actually, I still prefer the name without the no_ prefix to avoid DNEG double negatives like in your example and also, to avoid statements like if not no_append_sys_path:

@j0yu j0yu force-pushed the fix-826-pip-fallback branch from ce3c9da to 72f6a00 Compare April 22, 2020 15:07
linux-containers:
name: python:${{ matrix.python-version }} - ${{ matrix.method }}
runs-on: ubuntu-latest
container: python:${{ matrix.python-version }}
Copy link
Member

Choose a reason for hiding this comment

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

That runs the test in a docker container right? What's the reason for doing this? I can't think of a case where install rez would fail in a container but not on a bare metal/vm machine. But maybe I'm missing something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was just double checking that if the system already has Python it wasn't doing anything different from using actions/setup-python

It didn't, see here, so I'll remove it

- name: Install
run: |
${{ matrix.method }}
find /opt/rez/ -maxdepth 2

Choose a reason for hiding this comment

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

I'm tempted to suggest to use check-manifest to test that pip would install the correct files. Though, we would probably have to work a little bit on the MANIFEST.in to make it work. But that should be done in another PR IMO if we ever decide to go that way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, sounds like a good idea. Let's get a new PR/issue opened for that

- '3.6'
- '3.7'
method:
- 'python ./install.py'

Choose a reason for hiding this comment

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

We technically already test this type of install quite a lot for all platforms and all python versions. I think it would make sense to test this here, but only if we test install.py more in depth, like make sure it installs the rez scripts in the rez folder correctly, and on all platforms. We should also test https://github.com/nerdvegas/rez/blob/master/install.py#L81.

Without testing these things, I have the feeling we will just have jobs that will take CPU time without much benefits.

What do you think?

Copy link
Contributor Author

@j0yu j0yu Apr 27, 2020

Choose a reason for hiding this comment

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

test install.py more in depth, like make sure it installs the rez scripts in the rez folder correctly, and on all platforms. We should also test https://github.com/nerdvegas/rez/blob/master/install.py#L81.

I agree with testing python -E, let's do those in a separate PRs.

We technically already test this type of install quite a lot for all platforms and all python versions.

Does rez-selftest check python ./install.py? The other CI tests checks via python ./install.py ./build where as I wanted this to actually check the wiki's python ./install.py


Originally these tests were written just to double check what is said in the Installation Wiki page actually holds true and is not misleading beginners.

So far, this is just a start and we can expand on it to more in-depth and multi-platform tests in the future to ensure whenever someone discovers this project and tries to follow the wiki step by step, it should just work.

j0yu added a commit to j0yu/bleeding-rez that referenced this pull request Apr 27, 2020
@j0yu j0yu mentioned this pull request Apr 27, 2020
1 task
@j0yu j0yu requested a review from nerdvegas April 27, 2020 13:53
src/rez/pip.py Outdated Show resolved Hide resolved
@nerdvegas
Copy link
Contributor

Ok cheers, pretty much ready to merge this. Ran out of time just now but this will be done soon.
Thx
A

ps - let's keep separate issues (eg installation CI) in separate PRs ;) The smaller the PR the easier it is for me to digest and merge it.

@j0yu
Copy link
Contributor Author

j0yu commented Apr 28, 2020

Cheers for the review! I've updated with changes to code comments.

ps - let's keep separate issues (eg installation CI) in separate PRs ;) The smaller the PR the easier it is for me to digest and merge it.

Sure thing, I'll keep that in mind next time!

@nerdvegas nerdvegas merged commit e599cb5 into AcademySoftwareFoundation:master Apr 30, 2020
@j0yu j0yu deleted the fix-826-pip-fallback branch April 30, 2020 09:15
j0yu added a commit to j0yu/bleeding-rez that referenced this pull request Jul 14, 2020
j0yu added a commit to wwfxuk/rez that referenced this pull request Jul 14, 2020
j0yu added a commit to wwfxuk/rez that referenced this pull request Aug 5, 2020
j0yu added a commit to wwfxuk/rez that referenced this pull request Aug 5, 2020
j0yu added a commit to wwfxuk/rez that referenced this pull request Aug 16, 2020
j0yu added a commit to wwfxuk/rez that referenced this pull request Sep 15, 2020
j0yu added a commit to wwfxuk/rez that referenced this pull request Mar 18, 2021
j0yu pushed a commit to wwfxuk/rez that referenced this pull request Mar 30, 2021
commit 8d51e29
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Mon Apr 27 15:16:37 2020 +0100

    Emphasised pip CLI warnings

commit e0d698e
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Wed Apr 22 11:36:00 2020 +0100

    Extra links to install from GitHub

commit 13183cf
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Wed Apr 22 10:56:48 2020 +0100

    Updated CLI in rez-env warning

commit e922172
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Sat Apr 18 17:39:40 2020 +0100

    Just update Installation.md

    See AcademySoftwareFoundation#878 for CI check
j0yu pushed a commit to wwfxuk/rez that referenced this pull request Mar 30, 2021
commit 8d51e29
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Mon Apr 27 15:16:37 2020 +0100

    Emphasised pip CLI warnings

commit e0d698e
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Wed Apr 22 11:36:00 2020 +0100

    Extra links to install from GitHub

commit 13183cf
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Wed Apr 22 10:56:48 2020 +0100

    Updated CLI in rez-env warning

commit e922172
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Sat Apr 18 17:39:40 2020 +0100

    Just update Installation.md

    See AcademySoftwareFoundation#878 for CI check
j0yu pushed a commit to wwfxuk/rez that referenced this pull request Jun 4, 2021
commit 8d51e29
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Mon Apr 27 15:16:37 2020 +0100

    Emphasised pip CLI warnings

commit e0d698e
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Wed Apr 22 11:36:00 2020 +0100

    Extra links to install from GitHub

commit 13183cf
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Wed Apr 22 10:56:48 2020 +0100

    Updated CLI in rez-env warning

commit e922172
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Sat Apr 18 17:39:40 2020 +0100

    Just update Installation.md

    See AcademySoftwareFoundation#878 for CI check
j0yu pushed a commit to j0yu/bleeding-rez that referenced this pull request Jun 4, 2021
commit 8d51e29
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Mon Apr 27 15:16:37 2020 +0100

    Emphasised pip CLI warnings

commit e0d698e
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Wed Apr 22 11:36:00 2020 +0100

    Extra links to install from GitHub

commit 13183cf
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Wed Apr 22 10:56:48 2020 +0100

    Updated CLI in rez-env warning

commit e922172
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Sat Apr 18 17:39:40 2020 +0100

    Just update Installation.md

    See AcademySoftwareFoundation#878 for CI check
j0yu pushed a commit to wwfxuk/rez that referenced this pull request Jul 9, 2021
commit 8d51e29
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Mon Apr 27 15:16:37 2020 +0100

    Emphasised pip CLI warnings

commit e0d698e
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Wed Apr 22 11:36:00 2020 +0100

    Extra links to install from GitHub

commit 13183cf
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Wed Apr 22 10:56:48 2020 +0100

    Updated CLI in rez-env warning

commit e922172
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Sat Apr 18 17:39:40 2020 +0100

    Just update Installation.md

    See AcademySoftwareFoundation#878 for CI check
j0yu pushed a commit to wwfxuk/rez that referenced this pull request Jul 21, 2021
commit 8d51e29
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Mon Apr 27 15:16:37 2020 +0100

    Emphasised pip CLI warnings

commit e0d698e
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Wed Apr 22 11:36:00 2020 +0100

    Extra links to install from GitHub

commit 13183cf
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Wed Apr 22 10:56:48 2020 +0100

    Updated CLI in rez-env warning

commit e922172
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Sat Apr 18 17:39:40 2020 +0100

    Just update Installation.md

    See AcademySoftwareFoundation#878 for CI check
j0yu pushed a commit to wwfxuk/rez that referenced this pull request Aug 3, 2021
commit 8d51e29
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Mon Apr 27 15:16:37 2020 +0100

    Emphasised pip CLI warnings

commit e0d698e
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Wed Apr 22 11:36:00 2020 +0100

    Extra links to install from GitHub

commit 13183cf
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Wed Apr 22 10:56:48 2020 +0100

    Updated CLI in rez-env warning

commit e922172
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Sat Apr 18 17:39:40 2020 +0100

    Just update Installation.md

    See AcademySoftwareFoundation#878 for CI check
j0yu pushed a commit to wwfxuk/rez that referenced this pull request Aug 19, 2021
commit 8d51e29
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Mon Apr 27 15:16:37 2020 +0100

    Emphasised pip CLI warnings

commit e0d698e
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Wed Apr 22 11:36:00 2020 +0100

    Extra links to install from GitHub

commit 13183cf
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Wed Apr 22 10:56:48 2020 +0100

    Updated CLI in rez-env warning

commit e922172
Author: Joseph Yu <josephyu2712+github@gmail.com>
Date:   Sat Apr 18 17:39:40 2020 +0100

    Just update Installation.md

    See AcademySoftwareFoundation#878 for CI check
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 issues finding pip executable
3 participants