Skip to content

Commit

Permalink
-minor PR changes
Browse files Browse the repository at this point in the history
-note that local part of pip version changed to keep separators intact. In rez, 'x_y' is one version token
-ver, changelog updated
  • Loading branch information
ajohns committed Jun 26, 2019
1 parent 16f679b commit a48ac1e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

## [2.33.0](https://github.com/nerdvegas/rez/tree/2.33.0) (2019-06-26)
[Full Changelog](https://github.com/nerdvegas/rez/compare/2.32.1...2.33.0)

**Merged pull requests:**

- Update distlib vendor library [\#654](https://github.com/nerdvegas/rez/pull/654) ([lambdaclan](https://github.com/lambdaclan))
- [WIP] Feature/pip install modern [\#602](https://github.com/nerdvegas/rez/pull/602) ([lambdaclan](https://github.com/lambdaclan))

## [2.32.1](https://github.com/nerdvegas/rez/tree/2.32.1) (2019-06-24)
[Full Changelog](https://github.com/nerdvegas/rez/compare/2.32.0...2.32.1)

Expand Down
35 changes: 23 additions & 12 deletions src/rez/pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import os
import re


VERSION_PATTERN = r"""
v?
(?:
Expand Down Expand Up @@ -61,6 +62,7 @@
re.VERBOSE | re.IGNORECASE,
)


class InstallMode(Enum):
# don't install dependencies. Build may fail, for example the package may
# need to compile against a dependency. Will work for pure python though.
Expand All @@ -82,7 +84,7 @@ class InstallMode(Enum):


def _get_dependencies(requirement, distributions):
def get_distrubution_name(pip_name):
def get_distribution_name(pip_name):
pip_to_rez_name = pip_name.lower().replace("-", "_")
for dist in distributions:
_name, _ = parse_name_and_version(dist.name_and_version)
Expand All @@ -98,7 +100,7 @@ def get_distrubution_name(pip_name):
try:
name, version = parse_name_and_version(package)
version = version.replace("==", "")
name = get_distrubution_name(name)
name = get_distribution_name(name)
except DistlibException:
n, vs = package.split(' (')
vs = vs[:-1]
Expand All @@ -110,10 +112,10 @@ def get_distrubution_name(pip_name):
versions.append(version)
version = "".join(versions)

name = get_distrubution_name(name)
name = get_distribution_name(name)
result.append("-".join([name, version]))
else:
name = get_distrubution_name(package)
name = get_distribution_name(package)
result.append(name)

return result
Expand Down Expand Up @@ -144,7 +146,7 @@ def pip_to_rez_version(dist_version):
Development release segment: .devN - always lowercase
Local version identifiers MUST comply with the following scheme:
<public version identifier>[+<local version label>] - use - instead of + convert . to _
<public version identifier>[+<local version label>] - use - instead of +
Arguments:
dist_version (str): The distribution version to be converted.
Expand All @@ -167,7 +169,7 @@ def pip_to_rez_version(dist_version):
dev = available_segments["dev"].lower()
version += dev
if "local" in available_segments:
local = available_segments["local"].replace("-", "_")
local = available_segments["local"]
version += "-" + local

return version
Expand Down Expand Up @@ -221,7 +223,7 @@ def find_pip(pip_version=None, python_version=None):

try:
context = create_context(pip_version, python_version)
except BuildError as e:
except BuildError:
# fall back on system pip. Not ideal but at least it's something
from rez.backport.shutilwhich import which

Expand All @@ -233,8 +235,10 @@ def find_pip(pip_version=None, python_version=None):
"will be used instead." % pip_exe)
context = None
else:
raise e
finally:
raise

# check pip version, must be >=19 to support PEP517
try:
pattern = r"pip\s(?P<ver>\d+\.*\d*\.*\d*)"
ver_str = subprocess.check_output([pip_exe, '-V'])
match = re.search(pattern, ver_str)
Expand All @@ -243,6 +247,10 @@ def find_pip(pip_version=None, python_version=None):

if int(pip_major) < 19:
raise VersionError("pip >= 19 is required! Please update your pip.")
except:
# silently skip if pip version detection failed, pip itself will show
# a reasonable error message at the least.
pass

return pip_exe, context

Expand Down Expand Up @@ -342,9 +350,11 @@ def pip_install_package(source_name, pip_version=None, python_version=None,
_log(buf.getvalue())

# Build pip commandline
cmd = [pip_exe, "install",
"--use-pep517",
"--target=%s" % destpath]
cmd = [
pip_exe, "install",
"--use-pep517",
"--target=%s" % destpath
]

if mode == InstallMode.no_deps:
cmd.append("--no-deps")
Expand Down Expand Up @@ -388,6 +398,7 @@ def pip_install_package(source_name, pip_version=None, python_version=None,
# expected location to match wheel RECORD files
installed_filepath = installed_file[0]
bin_prefix = os.path.join('..', '..', 'bin') + os.sep

if installed_filepath.startswith(bin_prefix):
# account for extra parentdir as explained above
installed = os.path.join(destpath, '_', installed_filepath)
Expand Down
2 changes: 1 addition & 1 deletion src/rez/utils/_version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


# Update this value to version up Rez. Do not place anything else in this file.
_rez_version = "2.32.1"
_rez_version = "2.33.0"

try:
from rez.vendor.version.version import Version
Expand Down

0 comments on commit a48ac1e

Please sign in to comment.