ACP ACP Conda Build & Distribution 2 — Questions and Answers
Question 1: When uploading a package to Anaconda.org via the CLI, which command is used?
- conda upload
- anaconda upload (Correct answer)
- conda push
- pip upload
Correct answer: anaconda upload
The `anaconda upload` command (from the anaconda-client package) pushes a built .tar.bz2 or .conda file to your Anaconda.org channel.
Question 2: What is the purpose of the `build_number` field in a meta.yaml recipe?
- Sets the Python version for the build
- Distinguishes multiple builds of the same package version (Correct answer)
- Defines the number of parallel build jobs
- Specifies the conda-build version required
Correct answer: Distinguishes multiple builds of the same package version
The `build_number` increments when a recipe is rebuilt without changing the package version, allowing conda to distinguish between different builds of the same release.
Question 3: To install a package from a private Anaconda.org channel owned by user `myorg`, which flag do you add to `conda install`?
- -c myorg (Correct answer)
- --private myorg
- --repo myorg
- --org myorg
Correct answer: -c myorg
The `-c myorg` (or `--channel myorg`) flag tells conda to search the `myorg` channel on Anaconda.org before the default channels.
Question 4: What is a `.conda` file format compared to the older `.tar.bz2` conda package format?
- A zip-based format with separate metadata and data archives for faster extraction (Correct answer)
- A format exclusive to Windows platforms
- An encrypted package for enterprise distribution
- A format that only stores pure-Python packages
Correct answer: A zip-based format with separate metadata and data archives for faster extraction
The `.conda` format is a zip archive containing separate `pkg-*.tar.zst` (data) and `info-*.tar.zst` (metadata) components, enabling faster installs by extracting only needed parts.
Question 5: In a conda recipe, where would you add a `run_test.py` script to verify the package works after installation?
- In the build section of meta.yaml
- In the source section of meta.yaml
- In the test section of meta.yaml or as a run_test.py file in the recipe directory (Correct answer)
- In a separate test-requirements.txt file
Correct answer: In the test section of meta.yaml or as a run_test.py file in the recipe directory
The `test` section in meta.yaml (or a `run_test.py` file alongside the recipe) specifies imports, commands, and scripts that conda-build runs to validate the installed package.
Question 6: Which conda-build feature allows you to build multiple variants of a package (e.g., different Python versions) from a single recipe?
- conda-matrix
- conda_build_config.yaml (Correct answer)
- variant_config.yaml
- build_variants.cfg
Correct answer: conda_build_config.yaml
The `conda_build_config.yaml` file defines variant matrices (e.g., `python: [3.9, 3.10, 3.11]`) so conda-build automatically produces one package per combination.
When uploading a package to Anaconda.org via the CLI, which command is used?