# clone-repos
a basic git repo clone script, with special support for pip and/or editable installs, using [reorder_editable](https://github.com/seanbreckenridge/reorder_editable)
This supports running a preinstall (after cloning) or postinstall step (a shell command) as well
For examples of a `clone-repos.yaml` file this expects at `~/.config/clone-repos.yaml`, see:
- [clone-repos](https://sean.fish/d/clone-repos.yaml?redirect)
- [computer-clone-repos](https://sean.fish/d/computer-clone-repos.yaml?redirect)
- [hpi-clone-repos](https://sean.fish/d/hpi-clone-repos.yaml?redirect)
I also use this to install plugins/addons for things like [ranger](https://ranger.github.io/) or [todotxt](https://github.com/todotxt/todo.txt-cli):
- [ranger-plugins](https://sean.fish/d/ranger-plugins.yaml?redirect)
- [todotxt-actions](https://sean.fish/d/todotxt-actions.yaml?redirect)
## Installation
Requires `python3.9+`
To install with pip, run:
pip install cl-repos
## Usage
```
Usage: clone-repos [OPTIONS] CONFIG_FILE
Clones and sets up your repos.
Can provide a CONFIG_FILE instead of using the default
Options:
-b, --base-repos DIRECTORY base repository directory to clone repos into
[env var: REPOS; required]
-P, --parse-config test parsing the config file instead of running
clone
-B, --break-system-packages pass the --break-system-packages flag to pip
--help Show this message and exit.
```
The full format for a repo is:
```yaml
"url to repository":
base: path # overwrite base-path for this repo
dirname: directory_name # directory name to clone into
symlink_to: directory_name # the parent directory to symlink the cloned repo to
pip: how # 'install', 'editable' or 'editable_system'
preinstall:
- "shell command 1"
- "shell command 2"
postinstall: "shell command here"
pipefail: false # if true, stops multiple preinstall/postinstall if any command fails
```
The `preinstall` and `postinstall` scripts can either be one command (a string), or multiple (a list)
For `pip`, `editable` by default uses the `--user` flag, if you know what you're doing and want to install in your system lib directory, use `editable_system` (Note that this only works in particular python installations. In a lot of cases, pip will still default to installing into your `--user` directory instead). See [reorder_editable](https://github.com/seanbreckenridge/reorder_editable) for context.
This expects a `$REPOS` environment variable to be set, which is the base directory to clone into, e.g. in your shell config set:
```bash
export REPOS="${HOME}/Repos"
```
... or you can provide the `--base-repos` flag when running
To clone, run `clone-repos` or `python3 -m clone_repos`
To run this quickly on new machines, I setup an alias in my dotfiles like:
`alias cr="python3 -m pip install --break-system-packages 'git+https://github.com/seanbreckenridge/clone-repos' && clone-repos -B"`
### Tests
```bash
git clone 'https://github.com/seanbreckenridge/clone-repos'
cd ./clone-repos
pip install '.[testing]'
flake8 ./clone-repos
mypy ./clone-repos
```
Raw data
{
"_id": null,
"home_page": "https://github.com/seanbreckenridge/clone_repos",
"name": "cl-repos",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "",
"keywords": "git,github,clone",
"author": "Sean Breckenridge",
"author_email": "\"seanbrecke@gmail.com\"",
"download_url": "https://files.pythonhosted.org/packages/ba/6b/5af320525aa8d9dd250b744cc1725f51ee500ecba35cc0c66259d922bff0/cl_repos-0.1.1.tar.gz",
"platform": null,
"description": "# clone-repos\n\na basic git repo clone script, with special support for pip and/or editable installs, using [reorder_editable](https://github.com/seanbreckenridge/reorder_editable)\n\nThis supports running a preinstall (after cloning) or postinstall step (a shell command) as well\n\nFor examples of a `clone-repos.yaml` file this expects at `~/.config/clone-repos.yaml`, see:\n\n- [clone-repos](https://sean.fish/d/clone-repos.yaml?redirect)\n- [computer-clone-repos](https://sean.fish/d/computer-clone-repos.yaml?redirect)\n- [hpi-clone-repos](https://sean.fish/d/hpi-clone-repos.yaml?redirect)\n\nI also use this to install plugins/addons for things like [ranger](https://ranger.github.io/) or [todotxt](https://github.com/todotxt/todo.txt-cli):\n\n- [ranger-plugins](https://sean.fish/d/ranger-plugins.yaml?redirect)\n- [todotxt-actions](https://sean.fish/d/todotxt-actions.yaml?redirect)\n\n## Installation\n\nRequires `python3.9+`\n\nTo install with pip, run:\n\n pip install cl-repos\n\n## Usage\n\n```\nUsage: clone-repos [OPTIONS] CONFIG_FILE\n\n Clones and sets up your repos.\n\n Can provide a CONFIG_FILE instead of using the default\n\nOptions:\n -b, --base-repos DIRECTORY base repository directory to clone repos into\n [env var: REPOS; required]\n -P, --parse-config test parsing the config file instead of running\n clone\n -B, --break-system-packages pass the --break-system-packages flag to pip\n --help Show this message and exit.\n```\n\nThe full format for a repo is:\n\n```yaml\n\"url to repository\":\n base: path # overwrite base-path for this repo\n dirname: directory_name # directory name to clone into\n symlink_to: directory_name # the parent directory to symlink the cloned repo to\n pip: how # 'install', 'editable' or 'editable_system'\n preinstall:\n - \"shell command 1\"\n - \"shell command 2\"\n postinstall: \"shell command here\"\n pipefail: false # if true, stops multiple preinstall/postinstall if any command fails\n```\n\nThe `preinstall` and `postinstall` scripts can either be one command (a string), or multiple (a list)\n\nFor `pip`, `editable` by default uses the `--user` flag, if you know what you're doing and want to install in your system lib directory, use `editable_system` (Note that this only works in particular python installations. In a lot of cases, pip will still default to installing into your `--user` directory instead). See [reorder_editable](https://github.com/seanbreckenridge/reorder_editable) for context.\n\nThis expects a `$REPOS` environment variable to be set, which is the base directory to clone into, e.g. in your shell config set:\n\n```bash\nexport REPOS=\"${HOME}/Repos\"\n```\n\n... or you can provide the `--base-repos` flag when running\n\nTo clone, run `clone-repos` or `python3 -m clone_repos`\n\nTo run this quickly on new machines, I setup an alias in my dotfiles like:\n\n`alias cr=\"python3 -m pip install --break-system-packages 'git+https://github.com/seanbreckenridge/clone-repos' && clone-repos -B\"`\n\n### Tests\n\n```bash\ngit clone 'https://github.com/seanbreckenridge/clone-repos'\ncd ./clone-repos\npip install '.[testing]'\nflake8 ./clone-repos\nmypy ./clone-repos\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "a basic git repo clone script",
"version": "0.1.1",
"project_urls": {
"Homepage": "https://github.com/seanbreckenridge/clone_repos"
},
"split_keywords": [
"git",
"github",
"clone"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "43bd3aa1fbe00f8e0acd62b2b6b0e273857274ea59af93aaa5fdca190c5b1414",
"md5": "158dd18bb8e5e66d03903aefa97c902c",
"sha256": "5cb6eb68712bcc6aa7d4687e571bc674e8bf73624dc09f18d438b3805b8529d4"
},
"downloads": -1,
"filename": "cl_repos-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "158dd18bb8e5e66d03903aefa97c902c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 7712,
"upload_time": "2023-11-01T17:11:43",
"upload_time_iso_8601": "2023-11-01T17:11:43.584031Z",
"url": "https://files.pythonhosted.org/packages/43/bd/3aa1fbe00f8e0acd62b2b6b0e273857274ea59af93aaa5fdca190c5b1414/cl_repos-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ba6b5af320525aa8d9dd250b744cc1725f51ee500ecba35cc0c66259d922bff0",
"md5": "a99c6435bf275e9760d580247835c2ab",
"sha256": "d07c76a40016d338ac11c831a1a370ed7f8759cf69035c649f04bba3dc81fe59"
},
"downloads": -1,
"filename": "cl_repos-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "a99c6435bf275e9760d580247835c2ab",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 7668,
"upload_time": "2023-11-01T17:11:45",
"upload_time_iso_8601": "2023-11-01T17:11:45.576670Z",
"url": "https://files.pythonhosted.org/packages/ba/6b/5af320525aa8d9dd250b744cc1725f51ee500ecba35cc0c66259d922bff0/cl_repos-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-01 17:11:45",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "seanbreckenridge",
"github_project": "clone_repos",
"github_not_found": true,
"lcname": "cl-repos"
}