- This repository provides two scripts for patching Conda repodata in your Cloudsmith repository.
- It is inspired by the bioconda-repodata-patches repository, which is based on conda-forge-repository-patches.
- Special thanks to the contributors of conda-forge, bioconda and conda. This repository uses the BSD-3 license to reflect their contributions.
- Fork this repository to your organization.
- Initialize (or create) a python environment. To install the required dependencies use
pip install -r requirements.txt
. - Copy the
.env.example
template into a.env
file and initialize the variables with the organization, repository and token/key you'd like to use. Ensure that the token is linked to a user/service account that has write access to the repository. Once complete (if running locally), runsource .env
in order for the variables to be used by child processes (e.g. the python scripts).
- In the
gen_patch_json.py
file add the subdirectories (the list of Conda architectures) that currently exist in your cloudsmith repository to theSUBDIRS
variable. - Within the
_gen_new_index
method, add the patch. See the first example (Replace pin with test-conda
) within this method for how to do this. Note that this is a very basic example, you are free to use the existing helper methods (or create your own!) to create a more complex patch. - To test that the patch produces the changes you desire, run the
show_diff.py
script. This outputs the changes that the patch instructions will make to therepodata.json
(index) persubdir
for your repository.
- After verifying the changes, run the
gen_patch_json.py
script. This generates apatch_instructions.json
file for each subdirectory in thepatches
directory. - The
patch_instructions.json
file will follow this exact format, with the package modifications stored within thepackages
key:{ "packages": {}, "patch_instructions_version": 1, "remove": [], "revoke": [] }
- Once you are content with the instructions, run
python submit_patch.py
. This sends a PUT request for each of the newly generated patch instructions persubdir
to your repository. - The next time the
repodata.json
is retrieved from Cloudsmith, the index should have the patches applied.
- We encourage you to fork this repository and push all your patches to your forked repository.
- An ideal setup:
- Require pull request reviews for your repository.
- To submit a patch, open a PR with your patch added to the
gen_patch_json.py
file. Create a CI/CD job which outputs thediff
(from theshow_diff.py
script) whenever a PR is opened. - Create another CI/CD job which runs on merges to
main
. This should run thegen_patch_json.py
script. - This job could also run the
submit_patch.py
script to update the patch instructions for the specified Cloudsmith repository andsubdir
.
- The
patch_instructions.json
does support removals and revocations (remove
andrevoke
). However, we recommend that users do not populate these keys. Instead, please either delete or quarantine the package within your Cloudsmith repository. If an attempt is made to submit patch instructions to Cloudsmith with either of these keys populated you will receive a validation error. - We welcome contributions and ideas for this repository, please open an issue or PR if you'd like to make a change! :)