项目作者: Valassis-Digital-Media

项目描述 :
Mirror upstream conda channels
高级语言: Python
项目地址: git://github.com/Valassis-Digital-Media/conda-mirror.git
创建时间: 2016-10-20T18:35:17Z
项目社区:https://github.com/Valassis-Digital-Media/conda-mirror

开源协议:BSD 3-Clause "New" or "Revised" License

下载


conda-mirror

Project Status: Inactive – The project has reached a stable, usable state but is no longer being actively developed; support/maintenance will be provided as time allows.
Build Status
PyPI version
codecov

Mirrors an upstream conda channel to a local directory.

Install

conda-mirror is available on PyPI and conda-forge.

Install with:

pip install conda-mirror

or:

conda install conda-mirror -c conda-forge

Compatibility

conda-mirror is intentionally a py3 only package

CLI

CLI interface for conda-mirror.py

  1. usage: conda-mirror [-h] [--upstream-channel UPSTREAM_CHANNEL]
  2. [--target-directory TARGET_DIRECTORY]
  3. [--temp-directory TEMP_DIRECTORY] [--platform PLATFORM]
  4. [-v] [--config CONFIG] [--pdb] [--num-threads NUM_THREADS]
  5. [--version] [--dry-run] [--no-validate-target]
  6. [--minimum-free-space MINIMUM_FREE_SPACE]
  7. CLI interface for conda-mirror.py
  8. optional arguments:
  9. -h, --help show this help message and exit
  10. --upstream-channel UPSTREAM_CHANNEL
  11. The target channel to mirror. Can be a channel on
  12. anaconda.org like "conda-forge" or a full qualified
  13. channel like "https://repo.continuum.io/pkgs/free/"
  14. --target-directory TARGET_DIRECTORY
  15. The place where packages should be mirrored to
  16. --temp-directory TEMP_DIRECTORY
  17. Temporary download location for the packages. Defaults
  18. to a randomly selected temporary directory. Note that
  19. you might need to specify a different location if your
  20. default temp directory has less available space than
  21. your mirroring target
  22. --platform PLATFORM The OS platform(s) to mirror. one of: {'linux-64',
  23. 'linux-32','osx-64', 'win-32', 'win-64'}
  24. -v, --verbose logging defaults to error/exception only. Takes up to
  25. three '-v' flags. '-v': warning. '-vv': info. '-vvv':
  26. debug.
  27. --config CONFIG Path to the yaml config file
  28. --pdb Enable PDB debugging on exception
  29. --num-threads NUM_THREADS
  30. Num of threads for validation. 1: Serial mode. 0: All
  31. available.
  32. --version Print version and quit
  33. --dry-run Show what will be downloaded and what will be removed.
  34. Will not validate existing packages
  35. --no-validate-target Skip validation of files already present in target-
  36. directory
  37. --minimum-free-space MINIMUM_FREE_SPACE
  38. Threshold for free diskspace. Given in megabytes.

Example Usage

WARNING: Invoking this command will pull ~10GB and take at least an hour

conda-mirror --upstream-channel conda-forge --target-directory local_mirror --platform linux-64

More Details

blacklist/whitelist configuration

example-conf.yaml:

  1. blacklist:
  2. - license: "*agpl*"
  3. - license: None
  4. - license: ""
  5. whitelist:
  6. - name: system

blacklist removes package(s) that match the condition(s) listed from the
upstream repodata.

whitelist re-includes any package(s) from blacklist that match the
whitelist conditions.

blacklist and whitelist both take lists of dictionaries. The keys in the
dictionary need to be values in the repodata.json metadata. The values are
(unix) globs to match on. Go here for the full repodata of the upstream
“defaults” channel:
http://conda.anaconda.org/anaconda/linux-64/repodata.json

Here are the contents of one of the entries in repodata[‘packages’]

  1. {'botocore-1.4.10-py34_0.tar.bz2': {'arch': 'x86_64',
  2. 'binstar': {'channel': 'main',
  3. 'owner_id': '55fc8527d3234d09d4951c71',
  4. 'package_id': '56b88ea1be1cc95a362b218e'},
  5. 'build': 'py34_0',
  6. 'build_number': 0,
  7. 'date': '2016-04-11',
  8. 'depends': ['docutils >=0.10',
  9. 'jmespath >=0.7.1,<1.0.0',
  10. 'python 3.4*',
  11. 'python-dateutil >=2.1,<3.0.0'],
  12. 'license': 'Apache',
  13. 'md5': 'b35a5c1240ba672e0d9d1296141e383c',
  14. 'name': 'botocore',
  15. 'platform': 'linux',
  16. 'requires': [],
  17. 'size': 1831799,
  18. 'version': '1.4.10'}}

See implementation details in the conda_mirror:match function for more
information.

Common usage patterns

Mirror only one specific package

If you wanted to match exactly the botocore package listed above with your
config, then you could use the following configuration to first blacklist
all packages and then include just the botocore packages:

  1. blacklist:
  2. - name: "*"
  3. whitelist:
  4. - name: botocore
  5. version: 1.4.10
  6. build: py34_0
Mirror everything but agpl licenses
  1. blacklist:
  2. - license: "*agpl*"
Mirror only python 3 packages
  1. blacklist:
  2. - name: "*"
  3. whitelist:
  4. - build: "*py3*"

Testing

Install test requirements

Note: Will install packages from pip

  1. $ pip install -r test-requirements.txt
  2. Requirement already satisfied: pytest in /home/edill/miniconda/lib/python3.5/site-packages (from -r test-requirements.txt (line 1))
  3. Requirement already satisfied: coverage in /home/edill/miniconda/lib/python3.5/site-packages (from -r test-requirements.txt (line 2))
  4. Requirement already satisfied: pytest-ordering in /home/edill/miniconda/lib/python3.5/site-packages (from -r test-requirements.txt (line 3))
  5. Requirement already satisfied: py>=1.4.29 in /home/edill/miniconda/lib/python3.5/site-packages (from pytest->-r test-requirements.txt (line 1))

Run the tests, invoking with the coverage tool.

  1. $ coverage run run_tests.py
  2. sys.argv=['run_tests.py']
  3. ========================================= test session starts ==========================================
  4. platform linux -- Python 3.5.3, pytest-3.0.6, py-1.4.31, pluggy-0.4.0 -- /home/edill/miniconda/bin/python
  5. cachedir: .cache
  6. rootdir: /home/edill/dev/maxpoint/github/conda-mirror, inifile:
  7. plugins: xonsh-0.5.2, ordering-0.4
  8. collected 4 items
  9. test/test_conda_mirror.py::test_match PASSED
  10. test/test_conda_mirror.py::test_cli[https://repo.continuum.io/pkgs/free-linux-64] PASSED
  11. test/test_conda_mirror.py::test_cli[conda-forge-linux-64] PASSED
  12. test/test_conda_mirror.py::test_handling_bad_package PASSED
  13. ======================================= 4 passed in 4.41 seconds =======================================

Show the coverage statistics

  1. $ coverage report -m
  2. Name Stmts Miss Cover Missing
  3. ------------------------------------------------------------
  4. conda_mirror/__init__.py 3 0 100%
  5. conda_mirror/conda_mirror.py 236 20 92% 203-205, 209-210, 214, 240, 249-254, 262-264, 303, 366, 497, 542-543, 629
  6. ------------------------------------------------------------
  7. TOTAL 239 20 92%

Other

After a new contributor makes a pull-request that is approved, we will reach out
and invite you to be a maintainer of the project.

Releasing

To release you need three things

  1. Commit rights to conda-mirror
  2. A github token
  3. The version number that you want to use for the new tag

After you have all three of these things, run the release.sh script (on a unix machine) and
pass it the tag that you want to use and your github token:

  1. GITHUB_TOKEN=<github_token> ./release.sh <tag>