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

Feature/add 'prefix' argument to rez-pip #802

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/rez/cli/pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ def setup_parser(parser, completions=False):
"-r", "--release", action="store_true",
help="install as released package; if not set, package is installed "
"locally only")
parser.add_argument(
"-p", "--install_path", type=str, metavar='PATH',
predat marked this conversation as resolved.
Show resolved Hide resolved
help="install package to a custom location")
parser.add_argument(
"PACKAGE",
help="package to install or archive/url to install from")
Expand Down Expand Up @@ -55,7 +58,8 @@ def command(opts, parser, extra_arg_groups=None):
opts.PACKAGE,
pip_version=opts.pip_ver,
python_version=opts.py_ver,
release=opts.release)
release=opts.release,
install_path=opts.install_path)

# print summary
#
Expand Down
9 changes: 6 additions & 3 deletions src/rez/pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def find_pip_from_context(python_version, pip_version=None):


def pip_install_package(source_name, pip_version=None, python_version=None,
mode=InstallMode.min_deps, release=False):
mode=InstallMode.min_deps, release=False, install_path=None):
"""Install a pip-compatible python package as a rez package.
Args:
source_name (str): Name of package or archive/url containing the pip
Expand Down Expand Up @@ -223,8 +223,11 @@ def pip_install_package(source_name, pip_version=None, python_version=None,

# TODO: should check if packages_path is writable before continuing with pip
#
packages_path = (config.release_packages_path if release
else config.local_packages_path)
if install_path is not None:
packages_path = install_path
else:
packages_path = (config.release_packages_path if release
else config.local_packages_path)

tmpdir = mkdtemp(suffix="-rez", prefix="pip-")
stagingdir = os.path.join(tmpdir, "rez_staging")
Expand Down
7 changes: 5 additions & 2 deletions wiki/pages/Pip.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ optional arguments:
-s, --search search for the package on PyPi
-r, --release install as released package; if not set, package is
installed locally only
-p PATH, --install_path PATH
install package to a custom location
-v, --verbose verbose mode, repeat for more verbosity
```

Expand Down Expand Up @@ -107,8 +109,9 @@ remove your [user site](https://docs.python.org/3.7/library/site.html) from the
You have two options when you want to convert a pip package to a rez package. You can
install it, or release it. Install means that it will install in your
[local_packages_path](Configuring-Rez#local_packages_path), while
release means it will be installed in your
[release_packages_path](Configuring-Rez#release_packages_path).
release means it will be installed in your [release_packages_path](Configuring-Rez#release_packages_path).
You can also specify a custom installation location using `--install_path` (or `-p`).


You can (and we recommend) use the `--python-version` to choose for which python
version you want to install a given package. This will make `rez-pip` to resolve
Expand Down