Skip to content

Commit

Permalink
Merge branch 'main' into add-pins
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimergp authored Oct 20, 2023
2 parents 65257e9 + 2a082a7 commit d7174cc
Show file tree
Hide file tree
Showing 14 changed files with 195 additions and 677 deletions.
8 changes: 4 additions & 4 deletions .authors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
first_commit: 2019-02-17 13:35:45
- name: Min RK
email: [email protected]
num_commits: 29
num_commits: 30
first_commit: 2016-09-15 09:07:34
github: minrk
- name: Phil Elson
Expand Down Expand Up @@ -236,7 +236,7 @@
email: [email protected]
alternate_emails:
- [email protected]
num_commits: 32
num_commits: 39
first_commit: 2019-06-27 08:26:49
github: xhochy
- name: C.A.M. Gerlach
Expand Down Expand Up @@ -393,7 +393,7 @@
github: shadowwalkersb
- name: Matthew R. Becker
email: [email protected]
num_commits: 152
num_commits: 154
first_commit: 2020-01-07 17:44:33
github: beckermr
alternate_emails:
Expand Down Expand Up @@ -476,7 +476,7 @@
github: jwillemsen
- name: Jaime Rodríguez-Guerra
email: [email protected]
num_commits: 99
num_commits: 104
first_commit: 2020-11-01 14:18:08
github: jaimergp
- name: Bastian Zimmermann
Expand Down
4 changes: 2 additions & 2 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
Isuru Fernando <[email protected]> Isuru Fernando <[email protected]>
Matthew R. Becker <[email protected]> Matthew R Becker <[email protected]>
Matthew R. Becker <[email protected]> beckermr <[email protected]>
Jaime Rodríguez-Guerra <[email protected]>
Christopher J. Wright <[email protected]> christopher <[email protected]>
Christopher J. Wright <[email protected]> Christopher J. 'CJ' Wright <[email protected]>
Anthony Scopatz <[email protected]>
Jaime Rodríguez-Guerra <[email protected]>
Phil Elson <[email protected]> pelson <[email protected]>
Filipe Fernandes <[email protected]> Filipe <[email protected]>
Filipe Fernandes <[email protected]> ocefpaf <[email protected]>
Uwe L. Korn <[email protected]> Uwe L. Korn <[email protected]>
Dougal J. Sutherland <[email protected]>
shadow_walker <[email protected]>
Uwe L. Korn <[email protected]> Uwe L. Korn <[email protected]>
Michael Sarahan <[email protected]> Mike Sarahan <[email protected]>
Min RK <[email protected]>
Leo Fang <[email protected]> Leo Fang <[email protected]>
Expand Down
4 changes: 2 additions & 2 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ Authors are sorted by number of commits.

* Isuru Fernando
* Matthew R. Becker
* Jaime Rodríguez-Guerra
* Christopher J. Wright
* Anthony Scopatz
* Jaime Rodríguez-Guerra
* Phil Elson
* Filipe Fernandes
* Uwe L. Korn
* Dougal J. Sutherland
* shadow_walker
* Uwe L. Korn
* Michael Sarahan
* Min RK
* Leo Fang
Expand Down
37 changes: 37 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,43 @@ conda-smithy Change Log

.. current developments
v3.27.1
====================

**Fixed:**

* Crash when XDG_CACHE_DIR is defined

**Authors:**

* Min RK



v3.27.0
====================

**Added:**

* Cache the contents of ``conda-forge-pinning`` and only check every 15min for an updated version.
The re-check interval can be configured via the ``CONDA_FORGE_PINNING_LIFETIME`` environment variable.

**Changed:**

* Do not strip version constraints for ``mamba update``. (#1773 via #1774)
* If one supplies ``--no-check-uptodate`` on the commandline, we will no longer check and print a warning if conda-smithy is outdated.

**Removed:**

* Removed the ``updatecb3`` command. It is advised to do this update manually if you still encounter a recipe using the old compiler ``toolchain``.

**Authors:**

* Jaime Rodríguez-Guerra
* Uwe L. Korn



v3.26.3
====================

Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ out of by specifying `--without-anaconda-token`, as such execpted package upload
```
github:
user_or_org: YOUR_GITHUB_USER_OR_ORG
channels:
targets:
-
- YOUR_ANACONDA_CHANNEL
```

6. **Re-render the feedstock:** ``conda smithy rerender --feedstock_directory ./foo-feedstock``
Expand Down
46 changes: 1 addition & 45 deletions conda_smithy/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def __call__(self, args):
)

print(
"\nRepository created, please edit conda-forge.yml to configure the upload channels\n"
"\nRepository created, please edit recipe/conda_build_config.yaml to configure the upload channels\n"
"and afterwards call 'conda smithy register-github'"
)

Expand Down Expand Up @@ -597,50 +597,6 @@ def __call__(self, args):
print(POST_SKELETON_MESSAGE.format(args=args).strip())


class UpdateCB3(Subcommand):
subcommand = "update-cb3"

def __init__(self, parser):
# conda-smithy update-cb3 ./
super(UpdateCB3, self).__init__(
parser, "Update a feedstock for conda-build=3"
)
scp = self.subcommand_parser
scp.add_argument(
"--recipe_directory",
default=os.path.join(os.getcwd(), "recipe"),
help="The path to the source recipe directory.",
)
scp.add_argument(
"--output",
default=None,
help="Filename for the output. No output edits the recipe inplace",
)
scp.add_argument(
"--cbc",
default=None,
help="Path to conda_build_config.yaml. No path will use conda-forge-pinning",
)

def __call__(self, args):
from conda_smithy.update_cb3 import update_cb3
from conda_smithy.configure_feedstock import get_cfp_file_path

recipe_file = os.path.join(args.recipe_directory, "meta.yaml")
output_file = args.output
if output_file is None:
output_file = recipe_file
if args.cbc is None:
cbc, _ = get_cfp_file_path()
else:
cbc = os.path.join(os.getcwd(), args.cbc)
output_content, messages = update_cb3(recipe_file, cbc)
with io.open(output_file, "w") as fh:
fh.write(output_content)
print("List of changes done to the recipe:")
print(messages)


def main():
logging.basicConfig(level=logging.INFO)

Expand Down
113 changes: 90 additions & 23 deletions conda_smithy/configure_feedstock.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
import sys
import subprocess
import textwrap
import time
import yaml
import warnings
from collections import OrderedDict, namedtuple, Counter
import copy
import hashlib
import requests
from pathlib import PurePath
from pathlib import Path, PurePath

# The `requests` lib uses `simplejson` instead of `json` when available.
# In consequence the same JSON library must be used or the `JSONDecodeError`
Expand Down Expand Up @@ -66,6 +67,11 @@
","
)

# Cache lifetime in seconds, default 15min
CONDA_FORGE_PINNING_LIFETIME = int(
os.environ.get("CONDA_FORGE_PINNING_LIFETIME", 15 * 60)
)


def package_key(config, used_loop_vars, subdir):
# get the build string from whatever conda-build makes of the configuration
Expand Down Expand Up @@ -727,6 +733,9 @@ def _render_ci_provider(
if os.path.exists(_recipe_cbc):
os.rename(_recipe_cbc, _recipe_cbc + ".conda.smithy.bak")

channel_sources = migrated_combined_variant_spec.get(
"channel_sources", [""]
)[0].split(",")
metas = conda_build.api.render(
os.path.join(forge_dir, forge_config["recipe_dir"]),
platform=platform,
Expand All @@ -736,9 +745,7 @@ def _render_ci_provider(
permit_undefined_jinja=True,
finalize=False,
bypass_env_check=True,
channel_urls=forge_config.get("channels", {}).get(
"sources", []
),
channel_urls=channel_sources,
)
finally:
if os.path.exists(_recipe_cbc + ".conda.smithy.bak"):
Expand Down Expand Up @@ -1606,11 +1613,23 @@ def render_README(jinja_env, forge_config, forge_dir, render_info=None):

ci_support_path = os.path.join(forge_dir, ".ci_support")
variants = []
channel_targets = []
if os.path.exists(ci_support_path):
for filename in os.listdir(ci_support_path):
if filename.endswith(".yaml"):
variant_name, _ = os.path.splitext(filename)
variants.append(variant_name)
with open(os.path.join(ci_support_path, filename)) as fh:
data = yaml.safe_load(fh)
for channel in data.get("channel_targets", ()):
# channel_targets are in the form of "channel_name label"
channel_targets.append(channel.split(" "))
if not channel_targets:
# default to conda-forge if no channel_targets are specified (shouldn't happen)
channel_targets = ["conda-forge main"]
else:
# de-duplicate in-order
channel_targets = list(dict.fromkeys(channel_targets))

subpackages_metas = OrderedDict((meta.name(), meta) for meta in metas)
subpackages_about = [(package_name, package_about)]
Expand Down Expand Up @@ -1642,6 +1661,7 @@ def render_README(jinja_env, forge_config, forge_dir, render_info=None):
)
)
)
forge_config["channel_targets"] = channel_targets

if forge_config["azure"].get("build_id") is None:

Expand Down Expand Up @@ -1818,10 +1838,6 @@ def _load_forge_config(forge_dir, exclusive_config_file, forge_yml=None):
"max_py_ver": "37",
"min_r_ver": "34",
"max_r_ver": "34",
"channels": {
"sources": ["conda-forge"],
"targets": [["conda-forge", "main"]],
},
"github": {
"user_or_org": "conda-forge",
"repo_name": "",
Expand Down Expand Up @@ -1898,6 +1914,11 @@ def _load_forge_config(forge_dir, exclusive_config_file, forge_yml=None):
"Setting docker image in conda-forge.yml is removed now."
" Use conda_build_config.yaml instead"
)
if file_config.get("channels"):
raise ValueError(
"Setting channels in conda-forge.yml is removed now."
" Use conda_build_config.yaml instead"
)

for plat in ["linux", "osx", "win"]:
if config["azure"]["timeout_minutes"] is not None:
Expand Down Expand Up @@ -2034,17 +2055,20 @@ def _load_forge_config(forge_dir, exclusive_config_file, forge_yml=None):

if config["provider"]["linux_s390x"] in {"default", "native"}:
config["provider"]["linux_s390x"] = ["travis"]

config["remote_ci_setup"] = _santize_remote_ci_setup(
config["remote_ci_setup"]
)
config["remote_ci_setup_names"] = [
MatchSpec(pkg.strip('"').strip("'")).name
for pkg in config["remote_ci_setup"]
]

config["pinned_packages"] = conda_build.utils.ensure_list(
config["pinned_packages"]
)
config["remote_ci_setup"] = _santize_remote_ci_setup(
config["remote_ci_setup"]
)
if config["conda_install_tool"] == "conda":
config["remote_ci_setup_update"] = [
MatchSpec(pkg.strip('"').strip("'")).name
for pkg in config["remote_ci_setup"]
]
else:
config["remote_ci_setup_update"] = config["remote_ci_setup"]

# Older conda-smithy versions supported this with only one
# entry. To avoid breakage, we are converting single elements
Expand Down Expand Up @@ -2187,6 +2211,52 @@ def get_cfp_file_path(temporary_directory):
return cf_pinning_file, cf_pinning_ver


def get_cache_dir():
if sys.platform.startswith("win"):
return Path(os.environ.get("TEMP"))
else:
return Path(os.environ.get("XDG_CACHE_HOME", Path.home() / ".cache"))


def get_cached_cfp_file_path(temporary_directory):
if cache_dir := get_cache_dir():
smithy_cache = cache_dir / "conda-smithy"
smithy_cache.mkdir(parents=True, exist_ok=True)
pinning_version = None
# Do we already have the pinning cached?
if (smithy_cache / "conda-forge-pinng-version").exists():
pinning_version = (
smithy_cache / "conda-forge-pinng-version"
).read_text()

# Check whether we have recently already updated the cache
current_ts = int(time.time())
if (smithy_cache / "conda-forge-pinng-version-ts").exists():
last_ts = int(
(smithy_cache / "conda-forge-pinng-version-ts").read_text()
)
else:
last_ts = 0

if current_ts - last_ts > CONDA_FORGE_PINNING_LIFETIME:
current_pinning_version = get_most_recent_version(
"conda-forge-pinning"
).version
(smithy_cache / "conda-forge-pinng-version-ts").write_text(
str(current_ts)
)
if current_pinning_version != pinning_version:
get_cfp_file_path(smithy_cache)
(smithy_cache / "conda-forge-pinng-version").write_text(
current_pinning_version
)
pinning_version = current_pinning_version

return str(smithy_cache / "conda_build_config.yaml"), pinning_version
else:
return get_cfp_file_path(temporary_directory)


def clear_variants(forge_dir):
"Remove all variant files placed in the .ci_support path"
if os.path.isdir(os.path.join(forge_dir, ".ci_support")):
Expand Down Expand Up @@ -2340,14 +2410,11 @@ def main(
loglevel = os.environ.get("CONDA_SMITHY_LOGLEVEL", "INFO").upper()
logger.setLevel(loglevel)

if check:
if check or not no_check_uptodate:
# Check that conda-smithy is up-to-date
check_version_uptodate("conda-smithy", __version__, True)
return True

error_on_warn = False if no_check_uptodate else True
# Check that conda-smithy is up-to-date
check_version_uptodate("conda-smithy", __version__, error_on_warn)
if check:
return True

forge_dir = os.path.abspath(forge_file_directory)
if exclusive_config_file is not None:
Expand All @@ -2356,7 +2423,7 @@ def main(
raise RuntimeError("Given exclusive-config-file not found.")
cf_pinning_ver = None
else:
exclusive_config_file, cf_pinning_ver = get_cfp_file_path(
exclusive_config_file, cf_pinning_ver = get_cached_cfp_file_path(
temporary_directory
)

Expand Down
Loading

0 comments on commit d7174cc

Please sign in to comment.