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

Installer updates #662

Merged
merged 9 commits into from
Jul 20, 2019
Merged

Installer updates #662

merged 9 commits into from
Jul 20, 2019

Conversation

nerdvegas
Copy link
Contributor

@nerdvegas nerdvegas commented Jul 12, 2019

This PR updates the current installer. Changes include:

  • patched distlib (in build_utils) has been removed. The patch we were relying on has since been made part of the main distlib release, which we already have vendored;
  • virtualenv has been updated to latest;
  • scripts have been removed, and entry points are used instead;
  • installation occurs via wheel;
  • install.py code has been cleaned up and simplified. Specifically, standard use of distlib.ScriptMaker has been put in place;
  • INSTALL.md has been updated with a full explanation of the installer, and why a pip-based installation is not the same as using install.py. Reviewers are encouraged to read this file.

It would be great if others could test this, especially Windows users.

ajohns added 7 commits July 12, 2019 08:51
-using vendor.distlib instead - new version now incorporates patch previously relied on
-see https://bitbucket.org/pypa/distlib/commits/bff28df
-added _entry_points module
-misc fixes in setup.py
-removed hacky ScriptMaker code in install.py
@nerdvegas
Copy link
Contributor Author

Note also that this PR supersedes #625, although I'm interested in incorporating parts of that into separate PRs (notably, automated pip uploads). I'm also interested in Appveyor, which also belongs in a separate PR (and there is one - #339 - which should be compared with what's available from #625 and potentially combined).

@instinct-vfx
Copy link
Contributor

Will test this today.

@instinct-vfx
Copy link
Contributor

I just gave this a quick run to test the pip installation. The behavior does not match INSTALL.md.

However, this comes with a caveat - rez command line tools are disabled once inside a rez environment (ie after using the rez-env command). The reasons are given in the next section.

I did the following to install rez through pip:

python setup.py bdist_wheel
pip install rez-2.36.0-py2-none-any.whl

Now Rez executables still work inside resolved shells though:

image

This should not work, should it?

btw. please let me know if you prefer this to be comments in the diff section i can also move it there.

@instinct-vfx
Copy link
Contributor

Also there seems to be an issue with paths containing ~. As our deployment setup installs from a tempfolder generated location this can contain ~ if the corresponding user profile has certain properties (like mine does). Still investigating what change exactly causes that issue and if it is something that should be fixed in Rez or in our setup.

Copy link
Contributor

@mottosso mottosso left a comment

Choose a reason for hiding this comment

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

Great stuff! I've added my two cents, from my humble experience with Rez on PyPI.

INSTALL.md Outdated
]$ pip install rez
```

However, this comes with a caveat - _rez command line tools are disabled once
Copy link
Contributor

Choose a reason for hiding this comment

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

One solution may be to append the parent directory of which("rez") in the get_syspaths() method, here. This would also work on Windows.

INSTALL.md Outdated
Specifically:

* When within a rez environment (ie after using the `rez-env` command), the rez
command line tools would not be guaranteed to function correctly;
Copy link
Contributor

Choose a reason for hiding this comment

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

If the above method works, then this may be checked off safely.

INSTALL.md Outdated
* When within a rez environment (ie after using the `rez-env` command), the rez
command line tools would not be guaranteed to function correctly;
* When within a rez environment, other packages' tools (that were also installed
with pip) would remain visible, but would not be guaranteed to work.
Copy link
Contributor

Choose a reason for hiding this comment

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

This may be addressed using one of the methods you mentioned in #625.

I made a prototype of this a few weeks ago but haven't been testing it in production for more than a few days, and only on Windows. I've updated it to work on Linux just now, you can test it and see if it fits the bill like this:

$ pip install bleeding-rez
$ rez --version
bleeding-rez-2.33.4
$ rez env python --isolated

The environment you'll get is completely void of anything from the parent environment, including any PYTHONPATH or site-packages. Now, this is so barebones, that it also excludes rez itself from PATH. So if you wanted it there, you could add it here, where bash and lsb_release are explicitly added as well.

Alternatively, the REZ_ENVIRONMENT variable takes a JSON-serialised environment to be used in place of the skeleton environment built into the source. Out of the box you're left with a Docker-like environment, with only the shell itself plus your resolve.

When you enter a rez environment, the rez packages in the resolve configure
that environment as they see fit. For example, it is not uncommon for a python
package to append to PYTHONPATH. Environment variables such as PYTHONPATH
affect the behaviour of tools, including rez itself, and this can cause it to
Copy link
Contributor

@mottosso mottosso Jul 12, 2019

Choose a reason for hiding this comment

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

This would possibly be addressed by the above as well.

to avoid this problem. Specifically:

* Rez is installed into a virtualenv so that it operates standalone;
* The rez tools are shebanged with `python -E`, in order to protect them from
Copy link
Contributor

Choose a reason for hiding this comment

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

If the --isolated method works, the python -E is embedded into Rez, which means we could skip this particular step.

* Rez is installed into a virtualenv so that it operates standalone;
* The rez tools are shebanged with `python -E`, in order to protect them from
environment variables that affect python's behaviour;
* The rez tools are stored in their own directory, so that other unrelated tools
Copy link
Contributor

Choose a reason for hiding this comment

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

And finally, due to explicit control over the environment, this would also go away. Pof!

@nerdvegas
Copy link
Contributor Author

nerdvegas commented Jul 12, 2019 via email

@nerdvegas
Copy link
Contributor Author

nerdvegas commented Jul 12, 2019 via email

install.py Outdated
_, pip_executable = get_venv_executable(dest_dir, "pip")

# build wheel
run_command([py_executable, "setup.py", "bdist_wheel"])

Choose a reason for hiding this comment

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

I think we can simplify and solidify this by doing:

run_command([py_executable, "-m", "pip", "install", "."])
  1. Using py_executable -m pip you don't need to take care of finding pip. Python will do it for us.
  2. pip install . will build the wheel for you and install it for you. It is a little cleaner and a preferred approach from what I know. The other benefit is that you don't have to look for the wheel in the dist directory which could have some development stuff in there is not cleaned-up before running the install.py file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice, changes coming

@@ -13,11 +13,20 @@
sys.exit(1)


if sys.version_info < (2, 6):
print("install failed - requires python v2.6 or greater", file=sys.stderr)
if sys.version_info < (2, 7):

Choose a reason for hiding this comment

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

While we are there, we should also check for python 3. And we should also set the python_requires argument in the setup function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A py3 port is coming soon (another dev is working on it) so I think I'll leave this for now.

@scriptname("rez-build")
def run_rez_bind():
from rez.cli._main import run
return run("bind")
Copy link
Member

Choose a reason for hiding this comment

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

I think you copy/pasted a little too fast 😛 It should be build and the function name should also contain build as right now it override the bind. Same for rez-config.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for the catch, fixes coming

@JeanChristopheMorinPerso
Copy link
Member

Ah, it may be that the tool disabling only works in a virtualenv-based pip
installation.

Come to think of it, yeah there's no reliable way to remove visibility of
rez tools without taking out a bunch of other stuff as well. I'll update
the docs in this PR.

Yep, tool disabling only works when installing with install.py. We could potentially detect from the rez tools if we are not in recommended deployment method and log a warning maybe? I know some tools that does this (pipenv is the first to come to my mind). Or simply block the usage. We could call rez-system.is_production_rez_install from https://github.com/nerdvegas/rez/blob/master/src/rez/cli/_main.py#L72 and spit out a warning if it's false: We detected that Rez was installed with Pip. Please be aware the rez command line tools are not guaranteed to function correctly. See <link to wiki> for more information.

What do you think?

INSTALL.md Outdated
@@ -1,3 +1,85 @@
# Installation

See https://github.com/nerdvegas/rez/wiki/Getting-Started#installation


First, install Rez. Download the source, and, from the source directory, run:

Choose a reason for hiding this comment

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

Philosophical question (sorry in advance): Should we move this doc in the https://github.com/nerdvegas/rez/wiki/Getting-Started#installation doc? I'm also wondering if we should add a mention about how to install in the README as it's usually a common practice to do so.

Or we want to tackle that into a separate subject and wait for your roadmap before deciding?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes to both, will make those changes.

@instinct-vfx
Copy link
Contributor

Also there seems to be an issue with paths containing ~. As our deployment setup installs from a tempfolder generated location this can contain ~ if the corresponding user profile has certain properties (like mine does). Still investigating what change exactly causes that issue and if it is something that should be fixed in Rez or in our setup.

Please ignore this one, i found the issue and it is not within Rez. Sorry for that.

-warning msg on cli tools added for non-pip installation
-simplified setup.py

@scriptname("rez")
def run_rez():
check_production_install()

Choose a reason for hiding this comment

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

I'm wondering if you had a reason to not move that into the rez.cli._main.run. I have no problem if we do the check here. The only reason why I was mentioning rez.cli._main is because that would allow us to remove some duplication and have the check more centralized. Maybe you see a future where one command would not need the check?

@nerdvegas
Copy link
Contributor Author

nerdvegas commented Jul 16, 2019 via email

@JeanChristopheMorinRodeoFX
Copy link
Contributor

It makes a lot of sense.

I'm also wondering if we should write some tests to make sure it behaves as we want and that it stays like this in the future. With potentially all the cases we found in the last couple of weeks.

What do you think? Not too sure how we would go on testing that though.

@nerdvegas
Copy link
Contributor Author

nerdvegas commented Jul 17, 2019 via email

@nerdvegas
Copy link
Contributor Author

Can anyone confirm that this has been tested on Windows? I think we're ready to merge if so.

@instinct-vfx
Copy link
Contributor

I tried it and it broke for me in various places. I am not sure if this is our setup though. Will do a vanilla install and report later today. Sorry for the delay. Too many things going on at once he.

Copy link
Contributor

@instinct-vfx instinct-vfx left a comment

Choose a reason for hiding this comment

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

After setting things up properly and deploying using our deployment setup everything seems to be working fine as far as i can tell. Sorry again for the delays.

@nerdvegas nerdvegas merged commit b866c29 into master Jul 20, 2019
davidlatwe added a commit to davidlatwe/rez that referenced this pull request Mar 12, 2021
Now the setup.py is able to make binary scripts by itself and
install them as data_files under rez production dir 'bin/rez'
(or 'Scripts/rez' on Windows). However, console_scripts 'rez'
is conflicting with the rez production dir 'rez'.

Since the previous install.py already removing those scripts
before doing the *patch*, console_scripts should be ignored
in new setup.py.

See AcademySoftwareFoundation#625 and AcademySoftwareFoundation#662 for reason
why adding console_scripts in the first place.
@bpabel bpabel deleted the installer-updates branch January 19, 2023 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants