Skip to content
This repository has been archived by the owner on Feb 23, 2019. It is now read-only.

Commit

Permalink
Merge pull request #6 from kk6/feature_yaml
Browse files Browse the repository at this point in the history
Feature yaml
  • Loading branch information
kk6 committed Nov 22, 2015
2 parents 38df2f3 + 286273d commit 88884c6
Show file tree
Hide file tree
Showing 30 changed files with 846 additions and 233 deletions.
1 change: 1 addition & 0 deletions .coveragerc
@@ -1,6 +1,7 @@
[run]
omit =
snakepit/__main__.py
snakepit/_compat.py

[report]
exclude_lines =
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Expand Up @@ -58,6 +58,3 @@ target/

# Wheel
wheelhouse/

# Project Repository
requirements.in
187 changes: 157 additions & 30 deletions README.md
Expand Up @@ -7,65 +7,192 @@
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://raw.githubusercontent.com/kk6/snake-pit/master/LICENSE)
[![PyPI](https://img.shields.io/pypi/v/snake-pit.svg?style=flat-square)](https://pypi.python.org/pypi/snake-pit)

Depending on the installation or uninstall packages, and then edit the requirements file.
*It's Five O'clock Somewhere*

## Install snake-pit
## Introduction

### Design Concepts

I'm using ordinary [pip-tools](https://github.com/nvie/pip-tools) . pip-tools is great, but the package of installation, is to edit the `requirements.in` file every time the uninstall in the editor it was somewhat cumbersome. So, I have developed a snake-pit. snake-pit, which takes you by writing automatically package name to `requirements.in` After the installation of the package is successful. Even when the uninstall, will remove the automatically package name from requirements.in.

### Stand-alone

snake-pit is desirable to use in combination with a pip-tools, but it does not mean that its never dependent to pip-tools. snake-pit is available in stand-alone. It is a good idea to use instead of `pip freeze> requirements.txt`.

## Installation

### Using pip

snake-pit is possible to install pip.

```console

$ pip install snake-pit

```
### Get the Code

It is also possible to get the source code from Github.

```console

$ git clone git@github.com:kk6/snake-pit.git

```

You may want to install in the pip editable mode.

```console

$ pip install -e .

```

## Usage

### install
### Installing Packages

To install the Python package using the snake-pit, do the following. It is only different character and if you use a pip.

```console

$ pit install flask

```

Unlike pip, snake-pit will write the package name to automatically requirements file. Once you have successfully installed the package.

### Requirements Files

Although I mentioned earlier, snake-pit has been designed to be aware of the combination of the pip-tools. Therefore, the **Requirements file** to say here, as that term is pip-tools, is a file, such as a specified to `requirements.in` to pip-tools's `pip-compile` command.

As below, it is possible to specify a file path to reference `--requirements, in -r` option. This is priority than the set of configuration files, which will be described later.

```console

$ pit install pytest -r dev-requirements.in

```

### Configuration Files

If the `--requirements` option is not specified, snake-pit uses the configuration file to search for the requirements file.

Config file is intended to be managed by a name in the path to the requirements file. Please describe in YAML format file.In hash it will describe as `<name of the file path> : <path to file>`. The only required key is `default`. This is referred to by default when `--name, -n` option is not specified.

If there is no configuration file, or if the configuration file can not be read, the default configuration is used. By default, it will read and write `requirements.in`.

For example, you are managing by dividing the requirements file as follows:

```
requirements
├── base.in
└── dev
├── base.in
└── mysql.in
```

As follows, It is troublesome to specify the long file path for each installation.

```console

$ pit install mycli -r requirements/dev/mysql.in

```

So, we will use the configuration file. Let's described as follows:

```yaml

default:
requirements/base.in
dev:
requirements/dev/base.in
mysql:
requirements/dev/mysql.in

```

Save as `pit.yml`. By default, snake-pit enforce this file name, but this can be changed by setting environment variables (see below).

Now you need only to specify the name to `--name` option.

```console
$ echo '#requirements.in' > requirements.in

$ pit install flask pytest
$ pit install mycli -n mysql
...
Successfully installed Jinja2-2.8 MarkupSafe-0.23 Werkzeug-0.11.1 flask-0.10.1 itsdangerous-0.24 py-1.4.30 pytest-2.8.2
Append the following packages in requirements.in: flask, pytest
Successfully installed PyMySQL-0.6.7 Pygments-2.0.2 configobj-5.0.6 mycli-1.5.2 prompt-toolkit-0.46 pycrypto-2.6.1 six-1.10.0 sqlparse-0.1.18 wcwidth-0.1.5
Append the following packages in requirements/dev/mysql.in: mycli
requirements/dev/mysql.in has been updated as follows:
# requirements.mysql.in
mycli

$ cat requirements.in
#requirements.in
flask
pytest
```

### uninstall
### Default Configuration

If the configuration file fails to load or did not exist, the default configuration is used. By default, this is as follows.

```yaml

default:
requirements.in

```

### Set the configuration file name in the environment variable

It is possible to set the path to the configuration file in the environment variable `PIT_CONFIG_PATH`. If this environment variable is set, snake-pit looks for a there instead of `pit.yml` immediately below.

```console

$ mv pit.yml .pitrc
$ export PIT_CONFIG_PATH=.pitrc

```

### Uninstall Packages

Uninstall Packages also, is almost the same as the installation.

```console
$ cat requirements.in
#requirements.in
requests
nose

$ pit uninstall nose
Do you want to continue? [y/N]: y
Uninstalling nose-1.3.7:
Successfully uninstalled nose-1.3.7
Remove the following packages from requirements.in: nose

$ cat requirements.in
#requirements.in
requests
```

## Aliases
As well as the installation, `--requirements, -r` and ` --name, -n` options are available.

```console
$ pit i django # install django
$ pit u django # uninstall django

$ pit uninstall pytest -n test

```

## Develop
Further, by using the `--auto, -a` options, of all the packages to the specified package depends, is possible to remove at once what is unnecessary.

### Update README
```console
$ pit uninstall bpython httpie --auto
Specified package and becomes unnecessary by which they are removed, it will remove the following packages:

curtsies
httpie
greenlet
blessings
bpython

Are you sure? [y/N]:
```

## Aliases

snake-pit You can also use the alias of sub-command.

```console
$ pandoc -f markdown -t rst README.md > README.rst
$ pit i django # install django
$ pit u django # uninstall django
```

## License
MIT

Licensed under the MIT, see `LICENSE`.

0 comments on commit 88884c6

Please sign in to comment.