Skip to content

Commit

Permalink
Merge branch 'main' into new-sphinx-theme
Browse files Browse the repository at this point in the history
  • Loading branch information
travishathaway authored Nov 28, 2023
2 parents 7cee78b + f77849b commit 79d2ae7
Show file tree
Hide file tree
Showing 47 changed files with 535 additions and 332 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/lock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
if: '!github.event.repository.fork'
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v4
- uses: dessant/lock-threads@v5
with:
# Number of days of inactivity before a closed issue is locked
issue-inactive-days: 365
Expand All @@ -42,5 +42,5 @@ jobs:
# Reason for locking a pull request, value must be one of resolved, off-topic, too heated, spam or ''
pr-lock-reason: resolved

# Limit locking to only issues or pull requests, value must be one of issues, prs or ''
process-only: ''
# Limit locking to issues, pull requests or discussions, value must be a comma separated list of issues, prs, discussions or ''
process-only: issues, prs
26 changes: 16 additions & 10 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
shell: bash -el {0}
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -125,7 +125,7 @@ jobs:
--file ./tests/requirements.txt \
--file ./tests/requirements-linux.txt \
${{ env.CONDA_CHANNEL_LABEL }}::${{ env.CONDA_VERSION }}
pip install -e .
pip install -e . --no-deps
- name: Show info
run: |
Expand Down Expand Up @@ -224,13 +224,19 @@ jobs:
run-post: false # skip post cleanup

- name: Setup environment
shell: cmd /C CALL {0}
run: |
choco install visualstudio2017-workload-vctools
conda install -q -y -c defaults `
--file .\tests\requirements.txt `
--file .\tests\requirements-windows.txt `
${{ env.CONDA_CHANNEL_LABEL }}::conda
pip install -e .
@echo on
CALL choco install visualstudio2017-workload-vctools || exit 1
CALL conda install -q -y -c defaults ^
--file .\tests\requirements.txt ^
--file .\tests\requirements-windows.txt ^
${{ env.CONDA_CHANNEL_LABEL }}::conda || exit 1
:: TEMPORARY
if "${{ matrix.python-version }}" == "3.8" CALL conda install "https://anaconda.org/conda-forge/menuinst/2.0.0/download/win-64/menuinst-2.0.0-py38hd3f51b4_1.conda" || exit 1
if "${{ matrix.python-version }}" == "3.11" CALL conda install "https://anaconda.org/conda-forge/menuinst/2.0.0/download/win-64/menuinst-2.0.0-py311h12c1d0e_1.conda" || exit 1
:: /TEMPORARY
CALL pip install -e . --no-deps || exit 1
- name: Show info
run: |
Expand Down Expand Up @@ -288,7 +294,7 @@ jobs:
runs-on: macos-11
defaults:
run:
shell: bash -l {0}
shell: bash -el {0}
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -341,7 +347,7 @@ jobs:
--file ./tests/requirements.txt \
--file ./tests/requirements-macos.txt \
${{ env.CONDA_CHANNEL_LABEL }}::conda
pip install -e .
pip install -e . --no-deps
- name: Show info
run: |
Expand Down
17 changes: 4 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,19 @@ repos:
files: \.py$
args: [--license-filepath, .github/disclaimer.txt, --no-extra-eol]
exclude: ^conda_build/version.py
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
# upgrade standard Python codes
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/psf/black
rev: 23.10.1
hooks:
# auto format Python codes
- id: black
- repo: https://github.com/asottile/blacken-docs
rev: 1.16.0
hooks:
# auto format Python codes within docstrings
- id: blacken-docs
additional_dependencies: [black]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.4
rev: v0.1.6
hooks:
# lint & attempt to correct failures (e.g. pyupgrade)
- id: ruff
args: [--fix]
# compatible replacement for black
- id: ruff-format
- repo: meta
# see https://pre-commit.com/#meta-hooks
hooks:
Expand Down
6 changes: 3 additions & 3 deletions conda_build/_load_setup_py_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,18 @@ def setup(**kw):
parser.add_argument("setup_file", help="path or filename of setup.py file")
parser.add_argument(
"--from-recipe-dir",
help=("look for setup.py file in recipe " "dir (as opposed to work dir)"),
help="look for setup.py file in recipe dir (as opposed to work dir)",
default=False,
action="store_true",
)
parser.add_argument(
"--recipe-dir",
help=("(optional) path to recipe dir, where " "setup.py should be found"),
help="(optional) path to recipe dir, where setup.py should be found",
)

parser.add_argument(
"--permit-undefined-jinja",
help=("look for setup.py file in recipe " "dir (as opposed to work dir)"),
help="look for setup.py file in recipe dir (as opposed to work dir)",
default=False,
action="store_true",
)
Expand Down
13 changes: 7 additions & 6 deletions conda_build/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def convert(
)
elif package_file.endswith(".whl"):
raise RuntimeError(
"Conversion from wheel packages is not " "implemented yet, stay tuned."
"Conversion from wheel packages is not implemented yet, stay tuned."
)
else:
raise RuntimeError("cannot convert: %s" % package_file)
Expand Down Expand Up @@ -656,17 +656,18 @@ def debug(
]
if len(matched_outputs) > 1:
raise ValueError(
"Specified --output-id matches more than one output ({}). Please refine your output id so that only "
"a single output is found.".format(matched_outputs)
f"Specified --output-id matches more than one output ({matched_outputs}). "
"Please refine your output id so that only a single output is found."
)
elif not matched_outputs:
raise ValueError(
f"Specified --output-id did not match any outputs. Available outputs are: {outputs} Please check it and try again"
f"Specified --output-id did not match any outputs. Available outputs are: {outputs} "
"Please check it and try again"
)
if len(matched_outputs) > 1 and not path_is_build_dir:
raise ValueError(
"More than one output found for this recipe ({}). Please use the --output-id argument to filter down "
"to a single output.".format(outputs)
f"More than one output found for this recipe ({outputs}). "
"Please use the --output-id argument to filter down to a single output."
)
else:
matched_outputs = outputs
Expand Down
26 changes: 15 additions & 11 deletions conda_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,12 @@ def regex_files_py(
match_records[file] = {"type": type, "submatches": []}
# else:
# if match_records[file]['absolute_offset'] != absolute_offset:
# print("Dropping match.pos() of {}, neq {}".format(absolute_offset, match_records[file]['absolute_offset']))
# print(
# "Dropping match.pos() of {}, neq {}".format(
# absolute_offset,
# match_records[file]['absolute_offset'],
# )
# )
g_index = len(match.groups())
if g_index == 0:
# Complete match.
Expand Down Expand Up @@ -636,8 +641,9 @@ def have_regex_files(
return match_records
import copy

match_records_rg, match_records_re = copy.deepcopy(match_records), copy.deepcopy(
match_records
match_records_rg, match_records_re = (
copy.deepcopy(match_records),
copy.deepcopy(match_records),
)
if not isinstance(regex_re, (bytes, bytearray)):
regex_re = regex_re.encode("utf-8")
Expand Down Expand Up @@ -2254,7 +2260,9 @@ def _write_sh_activation_text(file_handle, m):
if value:
if not done_necessary_env:
# file_handle.write(
# 'export CCACHE_SLOPPINESS="pch_defines,time_macros${CCACHE_SLOPPINESS+,$CCACHE_SLOPPINESS}"\n')
# 'export CCACHE_SLOPPINESS="pch_defines,time_macros'
# '${CCACHE_SLOPPINESS+,$CCACHE_SLOPPINESS}"\n'
# )
# file_handle.write('export CCACHE_CPP2=true\n')
done_necessary_env = True
if method == "symlinks":
Expand All @@ -2263,16 +2271,12 @@ def _write_sh_activation_text(file_handle, m):
file_handle.write(f"pushd {dirname_ccache_ln_bin}\n")
file_handle.write('if [ -n "$CC" ]; then\n')
file_handle.write(
" [ -f {ccache} ] && [ ! -f $(basename $CC) ] && ln -s {ccache} $(basename $CC) || true\n".format(
ccache=ccache
)
f" [ -f {ccache} ] && [ ! -f $(basename $CC) ] && ln -s {ccache} $(basename $CC) || true\n"
)
file_handle.write("fi\n")
file_handle.write('if [ -n "$CXX" ]; then\n')
file_handle.write(
" [ -f {ccache} ] && [ ! -f $(basename $CXX) ] && ln -s {ccache} $(basename $CXX) || true\n".format(
ccache=ccache
)
f" [ -f {ccache} ] && [ ! -f $(basename $CXX) ] && ln -s {ccache} $(basename $CXX) || true\n"
)
file_handle.write("fi\n")
file_handle.write("popd\n")
Expand Down Expand Up @@ -4084,7 +4088,7 @@ def handle_anaconda_upload(paths, config):
prompter = "$ "
if not upload or anaconda is None:
no_upload_message = (
"# If you want to upload package(s) to anaconda.org later, type:\n" "\n"
"# If you want to upload package(s) to anaconda.org later, type:\n\n"
)
no_upload_message += (
"\n"
Expand Down
10 changes: 7 additions & 3 deletions conda_build/cli/main_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@

from .. import api, build, source, utils
from ..conda_interface import add_parser_channels, binstar_upload, cc_conda_build
from ..config import Config, get_channel_urls, zstd_compression_level_default
from ..config import (
get_channel_urls,
get_or_merge_config,
zstd_compression_level_default,
)
from ..deprecations import deprecated
from ..utils import LoggingContext
from .actions import KeyValueAction
Expand Down Expand Up @@ -437,7 +441,7 @@ def parse_args(args):
)
p.add_argument(
"--stats-file",
help=("File path to save build statistics to. Stats are " "in JSON format"),
help="File path to save build statistics to. Stats are in JSON format",
)
p.add_argument(
"--extra-deps",
Expand Down Expand Up @@ -514,7 +518,7 @@ def check_action(recipe, config):

def execute(args):
_parser, args = parse_args(args)
config = Config(**args.__dict__)
config = get_or_merge_config(None, **args.__dict__)
build.check_external()

# change globals in build module, see comment there as well
Expand Down
2 changes: 1 addition & 1 deletion conda_build/cli/main_develop.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def parse_args(args):
Install a Python package in 'development mode'.
This works by creating a conda.pth file in site-packages."""
This works by creating a conda.pth file in site-packages.""",
# TODO: Use setup.py to determine any entry-points to install.
)

Expand Down
2 changes: 1 addition & 1 deletion conda_build/cli/main_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def get_render_parser():
p.add_argument(
"--output",
action="store_true",
help="Output the conda package filename which would have been " "created",
help="Output the conda package filename which would have been created",
)
p.add_argument(
"--python",
Expand Down
14 changes: 10 additions & 4 deletions conda_build/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,11 +868,11 @@ def clean(self, remove_folders=True):
rm_rf(os.path.join(self.build_folder, "prefix_files"))
else:
print(
"\nLeaving build/test directories:" "\n Work:\n",
"\nLeaving build/test directories:\n Work:\n",
self.work_dir,
"\n Test:\n",
self.test_dir,
"\nLeaving build/test environments:" "\n Test:\nsource activate ",
"\nLeaving build/test environments:\n Test:\nsource activate ",
self.test_prefix,
"\n Build:\nsource activate ",
self.build_prefix,
Expand Down Expand Up @@ -913,8 +913,9 @@ def __exit__(self, e_type, e_value, traceback):
self.clean(remove_folders=False)


def get_or_merge_config(config, variant=None, **kwargs):
"""Always returns a new object - never changes the config that might be passed in."""
def _get_or_merge_config(config, variant=None, **kwargs):
# This function should only ever be called via get_or_merge_config.
# It only exists for us to monkeypatch a default config when running tests.
if not config:
config = Config(variant=variant)
else:
Expand All @@ -928,6 +929,11 @@ def get_or_merge_config(config, variant=None, **kwargs):
return config


def get_or_merge_config(config, variant=None, **kwargs):
"""Always returns a new object - never changes the config that might be passed in."""
return _get_or_merge_config(config, variant=variant, **kwargs)


def get_channel_urls(args):
channel_urls = args.get("channel") or args.get("channels") or ()
final_channel_urls = []
Expand Down
3 changes: 1 addition & 2 deletions conda_build/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ def __init__(
self.packages.append(pkg)
if not self.packages:
raise RuntimeError(
"failed to parse packages from exception:"
" {}".format(str(conda_exception))
f"failed to parse packages from exception: {conda_exception}"
)

def __str__(self):
Expand Down
31 changes: 17 additions & 14 deletions conda_build/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,19 +312,21 @@ def _delegated_update_index(
dir_path = parent_path
subdirs = [dirname]

return _update_index(
dir_path,
check_md5=check_md5,
channel_name=channel_name,
patch_generator=patch_generator,
threads=threads,
verbose=verbose,
progress=progress,
subdirs=subdirs,
warn=warn,
current_index_versions=current_index_versions,
debug=debug,
)
log_level = logging.DEBUG if debug else logging.INFO if verbose else logging.WARNING
with utils.LoggingContext(log_level):
return _update_index(
dir_path,
check_md5=check_md5,
channel_name=channel_name,
patch_generator=patch_generator,
threads=threads,
verbose=verbose,
progress=progress,
subdirs=subdirs,
warn=warn,
current_index_versions=current_index_versions,
debug=debug,
)


# Everything below is deprecated to maintain API/feature compatibility.
Expand Down Expand Up @@ -360,7 +362,8 @@ def update_index(
if dirname in utils.DEFAULT_SUBDIRS:
if warn:
log.warn(
"The update_index function has changed to index all subdirs at once. You're pointing it at a single subdir. "
"The update_index function has changed to index all subdirs at once. "
"You're pointing it at a single subdir. "
"Please update your code to point it at the channel root, rather than a subdir."
)
return update_index(
Expand Down
14 changes: 2 additions & 12 deletions conda_build/jinja_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,8 @@ def __init__(
__call__
) = (
__getitem__
) = (
__lt__
) = (
__le__
) = (
__gt__
) = (
__ge__
) = (
__complex__
) = __pow__ = __rpow__ = lambda self, *args, **kwargs: self._return_undefined(
self._undefined_name
) = __lt__ = __le__ = __gt__ = __ge__ = __complex__ = __pow__ = __rpow__ = (
lambda self, *args, **kwargs: self._return_undefined(self._undefined_name)
)

# Accessing an attribute of an Undefined variable
Expand Down
Loading

0 comments on commit 79d2ae7

Please sign in to comment.