Skip to content

Commit 50285ef

Browse files
authored
Merge pull request #1156 from nerdvegas/whichcraft
Whichcraft
2 parents f3ddbb1 + 9bb386c commit 50285ef

File tree

6 files changed

+100
-3
lines changed

6 files changed

+100
-3
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Change Log
22

3+
## 2.98.2 (2021-11-19)
4+
[Source](https://github.com/nerdvegas/rez/tree/2.98.2) | [Diff](https://github.com/nerdvegas/rez/compare/2.98.1...2.98.2)
5+
6+
Added unmodified whichcraft vendored lib.
7+
See:
8+
* https://github.com/cookiecutter/whichcraft/blob/master/whichcraft.py
9+
* https://github.com/nerdvegas/rez/pull/1155
10+
311
## 2.98.1 (2021-11-19)
412
[Source](https://github.com/nerdvegas/rez/tree/2.98.1) | [Diff](https://github.com/nerdvegas/rez/compare/2.98.0...2.98.1)
513

release-rez.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def generate_changelog_entry(issue_nums):
237237
"-s", "--step", choices=("push", "tag", "release_notes"),
238238
help="Just run one step of the release process")
239239
parser.add_argument(
240-
"-c", "--changelog", nargs='+', metavar="ISSUE", type=int,
240+
"-c", "--changelog", nargs='*', metavar="ISSUE", type=int,
241241
help="Generate changelog entry to be added to CHANGELOG.md")
242242
parser.add_argument(
243243
"-v", "--verbose", action="store_true",
@@ -246,7 +246,7 @@ def generate_changelog_entry(issue_nums):
246246
opts = parser.parse_args()
247247
verbose = opts.verbose
248248

249-
if opts.changelog:
249+
if opts.changelog is not None:
250250
issue_nums = opts.changelog
251251
generate_changelog_entry(issue_nums)
252252
sys.exit(0)

src/rez/utils/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22

33
# Update this value to version up Rez. Do not place anything else in this file.
4-
_rez_version = "2.98.1"
4+
_rez_version = "2.98.2"
55

66

77
# Copyright 2013-2016 Allan Johns.

src/rez/vendor/whichcraft/LICENSE

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Copyright (c) 2015-2016, Daniel Roy Greenfeld
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5+
6+
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7+
8+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9+
10+
* Neither the name of whichcraft nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11+
12+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

src/rez/vendor/whichcraft/__init__.py

Whitespace-only changes.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# -*- coding: utf-8 -*-
2+
3+
__author__ = "Daniel Roy Greenfeld"
4+
__email__ = "[email protected]"
5+
__version__ = "0.6.1"
6+
7+
import os
8+
import sys
9+
10+
try: # Forced testing
11+
from shutil import which
12+
except ImportError: # Forced testing
13+
# Versions prior to Python 3.3 don't have shutil.which
14+
15+
def which(cmd, mode=os.F_OK | os.X_OK, path=None):
16+
"""Given a command, mode, and a PATH string, return the path which
17+
conforms to the given mode on the PATH, or None if there is no such
18+
file.
19+
`mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result
20+
of os.environ.get("PATH"), or can be overridden with a custom search
21+
path.
22+
Note: This function was backported from the Python 3 source code.
23+
"""
24+
# Check that a given file can be accessed with the correct mode.
25+
# Additionally check that `file` is not a directory, as on Windows
26+
# directories pass the os.access check.
27+
28+
def _access_check(fn, mode):
29+
return os.path.exists(fn) and os.access(fn, mode) and not os.path.isdir(fn)
30+
31+
# If we're given a path with a directory part, look it up directly
32+
# rather than referring to PATH directories. This includes checking
33+
# relative to the current directory, e.g. ./script
34+
if os.path.dirname(cmd):
35+
if _access_check(cmd, mode):
36+
return cmd
37+
38+
return None
39+
40+
if path is None:
41+
path = os.environ.get("PATH", os.defpath)
42+
if not path:
43+
return None
44+
45+
path = path.split(os.pathsep)
46+
47+
if sys.platform == "win32":
48+
# The current directory takes precedence on Windows.
49+
if os.curdir not in path:
50+
path.insert(0, os.curdir)
51+
52+
# PATHEXT is necessary to check on Windows.
53+
pathext = os.environ.get("PATHEXT", "").split(os.pathsep)
54+
# See if the given file matches any of the expected path
55+
# extensions. This will allow us to short circuit when given
56+
# "python.exe". If it does match, only test that one, otherwise we
57+
# have to try others.
58+
if any(cmd.lower().endswith(ext.lower()) for ext in pathext):
59+
files = [cmd]
60+
else:
61+
files = [cmd + ext for ext in pathext]
62+
else:
63+
# On other platforms you don't have things like PATHEXT to tell you
64+
# what file suffixes are executable, so just pass on cmd as-is.
65+
files = [cmd]
66+
67+
seen = set()
68+
for dir in path:
69+
normdir = os.path.normcase(dir)
70+
if normdir not in seen:
71+
seen.add(normdir)
72+
for thefile in files:
73+
name = os.path.join(dir, thefile)
74+
if _access_check(name, mode):
75+
return name
76+
77+
return None

0 commit comments

Comments
 (0)