Skip to content

Commit

Permalink
✨ use pip-tools cli
Browse files Browse the repository at this point in the history
  • Loading branch information
juftin committed Nov 10, 2023
1 parent d6ae8b9 commit 9fb971d
Show file tree
Hide file tree
Showing 5 changed files with 382 additions and 123 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publishing

on:
release:
types:
- published

jobs:
pypi-publish:
name: PyPI
if: github.repository_owner == 'juftin'
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install Hatch
run: |
python -m pip install --upgrade pip
python -m pip install -q hatch pre-commit
hatch --version
- name: Build package
run: |
hatch build
- name: Publish package on PyPI
uses: pypa/gh-action-pypi-publish@v1.8.10
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
114 changes: 114 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,125 @@

hatch plugin to use pip-compile to manage project dependencies

[![PyPI](https://img.shields.io/pypi/v/hatch-pip-compile?color=blue&label=🔨%20hatch-pip-compile)](https://github.com/juftin/hatch-pip-compile)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/hatch-pip-compile)](https://pypi.python.org/pypi/hatch-pip-compile/)
[![GitHub License](https://img.shields.io/github/license/juftin/hatch-pip-compile?color=blue&label=License)](https://github.com/juftin/hatch-pip-compile/blob/main/LICENSE)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-lightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![Gitmoji](https://img.shields.io/badge/gitmoji-%20😜%20😍-FFDD67.svg)](https://gitmoji.dev)

## Installation

```shell
pip install hatch-pip-compile
```

### pipx

Personally, I use [pipx](https://github.com/pypa/pipx) to install and use hatch. If you do too,
you will need to inject the `hatch-pip-compile` plugin into the hatch environment.

```shell
pipx install hatch
pipx inject hatch hatch-pip-compile
```

## Usage

The `hatch-pip-compile` plugin will automatically run `pip-compile` whenever your
environment needs to be updated. Behind the scenes, this plugin creates a lockfile
at `.hatch/<ENV_NAME>.lock`. Alongside `pip-compile`, this plugin also uses
`pip-sync` to install the dependencies from the lockfile into your environment.

## Configuration

The [environment plugin](https://hatch.pypa.io/latest/plugins/environment/) name is `pip-compile`.

- **_pyproject.toml_**

```toml
[tool.hatch.envs.<ENV_NAME>]
type = "pip-compile"
```

- **_hatch.toml_**

```toml
[envs.<ENV_NAME>]
type = "pip-compile"
```

### lock-directory

The directory where the lockfiles will be stored. Defaults to `.hatch`.

- **_pyproject.toml_**

```toml
[tool.hatch.envs.<ENV_NAME>]
type = "pip-compile"
lock-directory = "requirements"
```

- **_hatch.toml_**

```toml
[envs.<ENV_NAME>]
type = "pip-compile"
lock-directory = "requirements"
```

### pip-compile-hashes

Whether or not to use hashes in the lockfile. Defaults to `true`.

- **_pyproject.toml_**

```toml
[tool.hatch.envs.<ENV_NAME>]
type = "pip-compile"
pip-compile-hashes = true
```

- **_hatch.toml_**

```toml
[envs.<ENV_NAME>]
type = "pip-compile"
pip-compile-hashes = true
```

### pip-compile-args

Extra arguments to pass to `pip-compile`. Defaults to None.

- **_pyproject.toml_**

```toml
[tool.hatch.envs.<ENV_NAME>]
type = "pip-compile"
pip-compile-args = [
"--index-url",
"https://pypi.org/simple",
]
```

- **_hatch.toml_**

```toml
[envs.<ENV_NAME>]
type = "pip-compile"
pip-compile-args = [
"--index-url",
"https://pypi.org/simple",
]
```

---

---

#### Check Out the [Docs](https://juftin.github.io/hatch-pip-compile/)

#### Looking to contribute? See the [Contributing Guide](https://juftin.github.io/hatch-pip-compile/contributing)
Expand Down
118 changes: 118 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,125 @@

hatch plugin to use pip-compile to manage project dependencies

[![PyPI](https://img.shields.io/pypi/v/hatch-pip-compile?color=blue&label=🔨%20hatch-pip-compile)](https://github.com/juftin/hatch-pip-compile)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/hatch-pip-compile)](https://pypi.python.org/pypi/hatch-pip-compile/)
[![GitHub License](https://img.shields.io/github/license/juftin/hatch-pip-compile?color=blue&label=License)](https://github.com/juftin/hatch-pip-compile/blob/main/LICENSE)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-lightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![Gitmoji](https://img.shields.io/badge/gitmoji-%20😜%20😍-FFDD67.svg)](https://gitmoji.dev)

## Installation

```shell
pip install hatch-pip-compile
```

### pipx

Personally, I use [pipx](https://github.com/pypa/pipx) to install and use hatch. If you do too,
you will need to inject the `hatch-pip-compile` plugin into the hatch environment.

```shell
pipx install hatch
pipx inject hatch hatch-pip-compile
```

## Usage

The `hatch-pip-compile` plugin will automatically run `pip-compile` whenever your
environment needs to be updated. Behind the scenes, this plugin creates a lockfile
at `.hatch/<ENV_NAME>.lock`. Alongside `pip-compile`, this plugin also uses
`pip-sync` to install the dependencies from the lockfile into your environment.

## Configuration

The [environment plugin](https://hatch.pypa.io/latest/plugins/environment/) name is `pip-compile`.

- **_pyproject.toml_**

```toml
[tool.hatch.envs.<ENV_NAME>]
type = "pip-compile"
```

- **_hatch.toml_**

```toml
[envs.<ENV_NAME>]
type = "pip-compile"
```

### lock-directory

The directory where the lockfiles will be stored. Defaults to `.hatch`.

- **_pyproject.toml_**

```toml
[tool.hatch.envs.<ENV_NAME>]
type = "pip-compile"
lock-directory = "requirements"
```

- **_hatch.toml_**

```toml
[envs.<ENV_NAME>]
type = "pip-compile"
lock-directory = "requirements"
```

### pip-compile-hashes

Whether or not to use hashes in the lockfile. Defaults to `true`.

- **_pyproject.toml_**

```toml
[tool.hatch.envs.<ENV_NAME>]
type = "pip-compile"
pip-compile-hashes = true
```

- **_hatch.toml_**

```toml
[envs.<ENV_NAME>]
type = "pip-compile"
pip-compile-hashes = true
```

### pip-compile-args

Extra arguments to pass to `pip-compile`. Defaults to None.

- **_pyproject.toml_**

```toml
[tool.hatch.envs.<ENV_NAME>]
type = "pip-compile"
pip-compile-args = [
"--index-url",
"https://pypi.org/simple",
]
```

- **_hatch.toml_**

```toml
[envs.<ENV_NAME>]
type = "pip-compile"
pip-compile-args = [
"--index-url",
"https://pypi.org/simple",
]
```

---

---

<br/>

<p align="center"><a href="https://github.com/juftin"><img src="https://raw.githubusercontent.com/juftin/juftin/main/static/juftin.png" width="120" height="120" alt="logo"></p>
Loading

0 comments on commit 9fb971d

Please sign in to comment.