Skip to content

Commit

Permalink
Merge pull request #72 from seapagan/convert-to-uv
Browse files Browse the repository at this point in the history
  • Loading branch information
seapagan authored Nov 13, 2024
2 parents 3f12281 + f93e450 commit 5f29fcd
Show file tree
Hide file tree
Showing 19 changed files with 2,069 additions and 2,392 deletions.
10 changes: 0 additions & 10 deletions .github/dependabot.yml

This file was deleted.

18 changes: 18 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended"
],
"labels": [
"dependencies"
],
"gitIgnoredAuthors": [
"66853113+pre-commit-ci[bot]@users.noreply.github.com"
],
"enabled": true,
"enabledManagers": [
"pep621",
"github-actions"
],
"ignoreDeps": []
}
13 changes: 11 additions & 2 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
name: Linting
on: [push, pull_request]

on: [push, pull_request, workflow_dispatch]

jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
- name: Linting
uses: chartboost/ruff-action@v1
with:
args: check
- name: Check Formatting
uses: chartboost/ruff-action@v1
with:
args: format --check
24 changes: 13 additions & 11 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@ on: [push, pull_request, workflow_dispatch]
jobs:
mypy:
# uncomment the line before to disable this job if needed.
if: false
# if: false
name: mypy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create MyPy Cache Directory
run: mkdir -p ${{ runner.workspace }}/.mypy_cache
- name: Mypy
uses: jpetrucciani/mypy-check@master

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
path: "."
mypy_flags:
"--install-types --non-interactive --config-file pyproject.toml
--ignore-missing-imports --strict"
requirements_file: "requirements-dev.txt"
python_version: "3.9"
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Set up Python
run: uv python install 3.12

- name: Run mypy
run: uv run --all-extras mypy . --strict
60 changes: 18 additions & 42 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,37 @@ name: Tests

on:
push:
branches: ["main"]
branches: ["main", "develop"]
pull_request:
branches: ["main"]
branches: ["main", "develop"]
workflow_dispatch:

jobs:
build:
test:
runs-on: ubuntu-latest
env:
SKIP_COVERAGE_UPLOAD: false
strategy:
fail-fast: false
max-parallel: 4
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v4

# ---------------------------------------------------------------------- #
# install and configure poetry #
# ---------------------------------------------------------------------- #
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
# ---------------------------------------------------------------------- #
# load cached venv if cache exists #
# ---------------------------------------------------------------------- #
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
path: .venv
key:
venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version
}}-${{ hashFiles('**/poetry.lock') }}
# ---------------------------------------------------------------------- #
# install dependencies if cache does not exist #
# ---------------------------------------------------------------------- #
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Run tests
# For example, using `pytest`
run: uv run -p ${{ matrix.python-version }} pytest --cov-report=xml

# ---------------------------------------------------------------------- #
# run Pytest #
# ---------------------------------------------------------------------- #
- name: Test with pytest
run: |
poetry run pytest --cov-report=xml
- name: Run codacy-coverage-reporter
env:
CODACY_CONFIGURED: ${{ secrets.CODACY_PROJECT_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ build
site/
api-test.py
repopack-output.txt
.envrc
67 changes: 28 additions & 39 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ci:
autofix_commit_msg: "[pre-commit.ci] auto fixes from pre-commit.com hooks [dependabot skip]"
autofix_commit_msg: "[pre-commit.ci] auto fixes from pre-commit.com hooks"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-yaml
args: [--unsafe]
Expand All @@ -11,59 +11,48 @@ repos:
- id: check-merge-conflict
- id: end-of-file-fixer

- repo: https://github.com/renovatebot/pre-commit-hooks
rev: 39.7.1
hooks:
- id: renovate-config-validator
files: ^renovate\.json$

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.4
rev: v0.7.2
hooks:
- id: ruff
name: "lint with ruff"
- id: ruff-format
name: "format with ruff"

# - repo: https://github.com/jackdewinter/pymarkdown
# rev: v0.9.22
# hooks:
# - id: pymarkdown
# name: "check markdown"
# exclude: ^.github/|CHANGELOG|README
# args: [-d, "MD046", scan]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.11.2" # Use the sha / tag you want to point at
rev: "v1.13.0" # Use the sha / tag you want to point at
hooks:
- id: mypy
name: "run mypy"
additional_dependencies:
- pydantic

- repo: https://github.com/python-poetry/poetry
rev: "1.8.0"
hooks:
- id: poetry-check
name: "check poetry files"
# - id: poetry-lock

- repo: https://github.com/python-poetry/poetry-plugin-export
rev: "1.8.0"
- repo: https://github.com/astral-sh/uv-pre-commit
# uv version.
rev: 0.4.30
hooks:
- id: poetry-export
name: "export production dependencies"
# Update the uv lockfile
- id: uv-lock
- id: uv-export
name: "Export dependencies to 'requirements.txt'"
args:
[
"--without-hashes",
"-f",
"requirements.txt",
"-o",
"requirements.txt",
"--without",
"dev",
"--no-hashes",
"--no-dev",
"--no-emit-project",
"--output-file=requirements.txt",
]
- id: poetry-export
name: "export development dependencies"
- id: uv-export
name: "Export dev dependencies to 'requirements-dev.txt'"
args:
[
"--without-hashes",
"-f",
"requirements.txt",
"-o",
"requirements-dev.txt",
"--with",
"dev",
"--no-hashes",
"--no-emit-project",
"--output-file=requirements-dev.txt",
]
28 changes: 21 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,25 @@ Python installations, the
Mac OS X. For Windows, you can use the
[pyenv-win](https://github.com/pyenv-win/pyenv-win) port. See
[here](https://github.com/pyenv-win/pyenv-win#installation ) for installation
instructions.
instructions. If you use `uv` (recommended and described below), it can install
Python for you, much quicker and easier than using `pyenv`.

- This project requires **Python 3.9** or higher.

- We also use [Poetry](https://python-poetry.org/) to manage our dependencies. You
should have this installed as well. You can install Poetry by following the
instructions on the [Poetry
website](https://python-poetry.org/docs/#installation).
- We use [uv](https://docs.astral.sh/uv/) to manage our dependencies. You should
have this installed as well. You can install `uv` by following the instructions
on their [website](https://docs.astral.sh/uv/getting-started/installation/).

`uv` can be used to actually install Python, even if you do not have it
installed locally (either by system, pyenv or similar).

For example, to install Python 3.12 using `uv`, you can run the following command:

```console
uv python install 3.12
```

If you already have a Python version installed, uv will use this.

## Getting Started

Expand All @@ -54,13 +65,16 @@ To get started, follow these steps:
Run the following command to install the required dependencies:

```console
poetry install
uv sync
```

The `.venv` folder is already in the `.gitignore` file so will not be committed
to the repository. This is where the virtual environment will be created.

You then need to activate the virtual environment:

```console
poetry shell
source .venv/bin/activate
```

From here you can start working on the project. If you are using an IDE such as
Expand Down
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Lice generates license files. No more hunting down licenses from other projects.
- [Config File](#config-file)
- [Integrate into your projects](#integrate-into-your-projects)
- [Integration with other tools](#integration-with-other-tools)
- [Contribute to the Development](#contribute-to-the-development)
- [Changelog](#changelog)

## Changes from the original 'Lice' project
Expand All @@ -33,7 +34,7 @@ features:
- Can read from a config file for default values.
- Can optionally copy the license to the clipboard automatically.
- Converted from 'argparse' to 'Typer' for CLI handling.
- It now uses [Poetry](https://python-poetry.org/) for dependency management.
- It now uses [uv](https://docs.astral.sh/uv/) for dependency management.
- Fixes the issue where extra spaces and newlines were added to the generated
license text. This was considered a bug by at least several users, so it was
fixed in version `0.10.0`. However, if you want to generate a license with the
Expand All @@ -42,7 +43,7 @@ features:
- The code has been modernized and cleaned up, all type-hinting has been
added.
- It passes strict linting with the latest 'Ruff' and 'mypy'.
- GitHub actions set up for linting, `Dependabot` and `Dependency Review`.
- GitHub actions set up for linting, `Renovate` and `Dependency Review`.
- Can output a list of licenses and languages in JSON format for integration
with other tools.

Expand Down Expand Up @@ -290,6 +291,23 @@ that can be parsed.

For more fine-grained control, you can use the API above (but only in Python)

## Contribute to the Development

If you want to help with development of this project or just hack on the code,
you can clone the repository and install the development dependencies with the
following command:

```console
uv sync
```

We use [uv](https://docs.astral.sh/uv/) to manage the virtual environment and
dependencies. See [Contributing](CONTRIBUTING.md) and the relevant section on
the [website](https://seapagan.github.io/lice2/) for details

All contributions are welcome, and I will try to respond to issues and PR's as
soon as possible.

## Changelog

See the [CHANGELOG.md](CHANGELOG.md) file for details for this fork, and the
Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ features:
- Can read from a config file for default values.
- Can optionally copy the license to the clipboard automatically.
- Converted from 'argparse' to 'Typer' for CLI handling.
- It now uses [Poetry](https://python-poetry.org/){:target="_blank"} for
- It now uses [uv](https://docs.astral.sh/uv/){:target="_blank"} for
dependency management.
- Fixes the issue where extra spaces and newlines were added to the generated
license text. This was considered a bug by at least several users, so it was
Expand All @@ -29,7 +29,7 @@ features:
- The code has been modernized and cleaned up, all type-hinting has been
added.
- It passes strict linting with the latest 'Ruff' and 'mypy'.
- GitHub actions set up for linting, `Dependabot` and `Dependency Review`.
- GitHub actions set up for linting, `Renovate` and `Dependency Review`.
- Can output a list of licenses and languages in JSON format for integration
with other tools.

Expand Down
Loading

0 comments on commit 5f29fcd

Please sign in to comment.