Skip to content

Commit

Permalink
Merge branch 'main' of github.com:conda/constructor into uninstall-st…
Browse files Browse the repository at this point in the history
…andalone
  • Loading branch information
marcoesters committed Nov 25, 2024
2 parents 837a741 + d4ac85f commit af2fcad
Show file tree
Hide file tree
Showing 32 changed files with 615 additions and 709 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check CLA
uses: conda/actions/check-cla@15f883f14f4232f83658e3609c3316d58905138f # v24.8.0
uses: conda/actions/check-cla@6e72e0db87e72f0020e493aeb02f864363bd9258 # v24.11.1
with:
# [required]
# A token with ability to comment, label, and modify the commit status
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:
pytest -vv --cov=constructor --cov-branch tests/ -m "not examples"
coverage run --branch --append -m constructor -V
coverage json
- uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
- uses: codecov/codecov-action@5c47607acb93fed5485fdbf7232e8a31425f672a # v5.0.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unit
Expand All @@ -155,7 +155,7 @@ jobs:
pytest -vv --cov=constructor --cov-branch tests/test_examples.py
coverage run --branch --append -m constructor -V
coverage json
- uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
- uses: codecov/codecov-action@5c47607acb93fed5485fdbf7232e8a31425f672a # v5.0.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: integration
Expand Down Expand Up @@ -226,7 +226,7 @@ jobs:
clean: true
fetch-depth: 0
- name: Create and upload canary build
uses: conda/actions/canary-release@15f883f14f4232f83658e3609c3316d58905138f # v24.8.0
uses: conda/actions/canary-release@6e72e0db87e72f0020e493aeb02f864363bd9258 # v24.11.1
with:
package-name: ${{ github.event.repository.name }}
subdir: ${{ matrix.subdir }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
days-before-issue-stale: 90
days-before-issue-close: 21
steps:
- uses: conda/actions/read-yaml@15f883f14f4232f83658e3609c3316d58905138f # v24.8.0
- uses: conda/actions/read-yaml@6e72e0db87e72f0020e493aeb02f864363bd9258 # v24.11.1
id: read_yaml
with:
path: https://raw.githubusercontent.com/conda/infra/main/.github/messages.yml
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ jobs:
git config --global user.name 'Conda Bot'
git config --global user.email '[email protected]'
- uses: conda/actions/combine-durations@15f883f14f4232f83658e3609c3316d58905138f # v24.8.0
- uses: conda/actions/combine-durations@6e72e0db87e72f0020e493aeb02f864363bd9258 # v24.11.1
id: durations
continue-on-error: true

- uses: conda/actions/template-files@15f883f14f4232f83658e3609c3316d58905138f # v24.8.0
- uses: conda/actions/template-files@6e72e0db87e72f0020e493aeb02f864363bd9258 # v24.11.1
id: templates
continue-on-error: true

Expand Down
2 changes: 2 additions & 0 deletions CONSTRUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,8 @@ Allowed keys are:
- `info.json`: The internal `info` object, serialized to JSON. Takes no options.
- `pkgs_list`: The list of packages contained in a given environment. Options:
- `env` (optional, default=`base`): Name of an environment in `extra_envs` to export.
- `lockfile`: An `@EXPLICIT` lockfile for a given environment. Options:
- `env` (optional, default=`base`): Name of an environment in `extra_envs` to export.
- `licenses`: Generate a JSON file with the licensing details of all included packages. Options:
- `include_text` (optional bool, default=`False`): Whether to dump the license text in the JSON.
If false, only the path will be included.
Expand Down
39 changes: 39 additions & 0 deletions constructor/build_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
from collections import defaultdict
from pathlib import Path

from conda.base.constants import UNKNOWN_CHANNEL
from conda.common.url import remove_auth, split_anaconda_token
from conda.core.prefix_data import PrefixGraph

from . import __version__

logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -86,6 +92,38 @@ def dump_packages_list(info, env="base"):
return os.path.abspath(outpath)


def dump_lockfile(info, env="base"):
if env == "base":
records = info["_records"]
elif env in info["_extra_envs_info"]:
records = info["_extra_envs_info"][env]["_records"]
else:
raise ValueError(f"env='{env}' is not a valid env name.")
lines = [
"# This file may be used to create an environment using:",
"# $ conda create --name <env> --file <this file>",
f"# installer-name: {info['name']}",
f"# installer-version: {info['version']}",
f"# env-name: {env}",
f"# platform: {info['_platform']}",
f"# created-by: constructor {__version__}",
"@EXPLICIT"
]
for record in PrefixGraph(records).graph:
url = record.get("url")
if not url or url.startswith(UNKNOWN_CHANNEL):
print("# no URL for: {}".format(record["fn"]))
continue
url = remove_auth(split_anaconda_token(url)[0])
hash_value = record.get("md5")
lines.append(url + (f"#{hash_value}" if hash_value else ""))

outpath = os.path.join(info["_output_dir"], f'lockfile.{env}.txt')
with open(outpath, 'w') as f:
f.write("\n".join(lines))
return os.path.abspath(outpath)


def dump_licenses(info, include_text=False, text_errors=None):
"""
Create a JSON document with a mapping with schema:
Expand Down Expand Up @@ -140,5 +178,6 @@ def dump_licenses(info, include_text=False, text_errors=None):
"hash": dump_hash,
"info.json": dump_info,
"pkgs_list": dump_packages_list,
"lockfile": dump_lockfile,
"licenses": dump_licenses,
}
6 changes: 4 additions & 2 deletions constructor/construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,8 @@
- `info.json`: The internal `info` object, serialized to JSON. Takes no options.
- `pkgs_list`: The list of packages contained in a given environment. Options:
- `env` (optional, default=`base`): Name of an environment in `extra_envs` to export.
- `lockfile`: An `@EXPLICIT` lockfile for a given environment. Options:
- `env` (optional, default=`base`): Name of an environment in `extra_envs` to export.
- `licenses`: Generate a JSON file with the licensing details of all included packages. Options:
- `include_text` (optional bool, default=`False`): Whether to dump the license text in the JSON.
If false, only the path will be included.
Expand Down Expand Up @@ -751,10 +753,10 @@ def yamlize(data, directory, content_filter):
if ('{{' not in data) and ('{%' not in data):
raise UnableToParse(original=e)
try:
from constructor.jinja import render_jinja
from constructor.jinja import render_jinja_for_input_file
except ImportError as ex:
raise UnableToParseMissingJinja2(original=ex)
data = render_jinja(data, directory, content_filter)
data = render_jinja_for_input_file(data, directory, content_filter)
return yaml.load(data)


Expand Down
15 changes: 9 additions & 6 deletions constructor/fcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def _main(name, version, download_dir, platform, channel_urls=(), channels_remap
env_pc_recs, env_urls, env_dists, _ = _fetch_precs(
env_precs, download_dir, transmute_file_type=transmute_file_type
)
extra_envs_data[env_name] = {"_urls": env_urls, "_dists": env_dists}
extra_envs_data[env_name] = {"_urls": env_urls, "_dists": env_dists, "_records": env_precs}
all_pc_recs += env_pc_recs

duplicate_files = "warn" if ignore_duplicate_files else "error"
Expand All @@ -418,6 +418,7 @@ def _main(name, version, download_dir, platform, channel_urls=(), channels_remap

return (
all_pc_recs,
precs,
_urls,
dists,
approx_tarballs_size,
Expand Down Expand Up @@ -466,8 +467,9 @@ def main(info, verbose=True, dry_run=False, conda_exe="conda.exe"):

(
pkg_records,
_urls,
dists,
_base_env_records,
_base_env_urls,
_base_env_dists,
approx_tarballs_size,
approx_pkgs_size,
has_conda,
Expand Down Expand Up @@ -495,10 +497,11 @@ def main(info, verbose=True, dry_run=False, conda_exe="conda.exe"):
)

info["_all_pkg_records"] = pkg_records # full PackageRecord objects
info["_urls"] = _urls # needed to mock the repodata cache
info["_dists"] = dists # needed to tell conda what to install
info["_urls"] = _base_env_urls # needed to mock the repodata cache
info["_dists"] = _base_env_dists # needed to tell conda what to install
info["_records"] = _base_env_records # needed to generate optional lockfile
info["_approx_tarballs_size"] = approx_tarballs_size
info["_approx_pkgs_size"] = approx_pkgs_size
info["_has_conda"] = has_conda
# contains {env_name: [_dists, _urls]} for each extra environment
# contains {env_name: [_dists, _urls, _records]} for each extra environment
info["_extra_envs_info"] = extra_envs_info
Loading

0 comments on commit af2fcad

Please sign in to comment.