Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to print version info #309

Merged
merged 10 commits into from
Aug 13, 2024
25 changes: 13 additions & 12 deletions .github/workflows/run-formatter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ jobs:
runs-on: ubuntu-latest
name: Format code
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.lock
timeout-minutes: 5

- name: Checkout code
uses: actions/checkout@v4

- name: Install rye
uses: eifinger/setup-rye@v4

- name: Sync dependencies
run: rye sync

- name: Run black
run: black --check .
run: |
source .venv/bin/activate
black --check .
timeout-minutes: 5
24 changes: 12 additions & 12 deletions .github/workflows/run-linter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ jobs:
runs-on: ubuntu-latest
name: Lint code
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.lock
timeout-minutes: 5
- name: Checkout code
uses: actions/checkout@v4

- name: Install rye
uses: eifinger/setup-rye@v4

- name: Sync dependencies
run: rye sync

- name: Run pylint
run: pylint --exit-zero src/mepo
run: |
source .venv/bin/activate
pylint --exit-zero src/mepo
timeout-minutes: 5
22 changes: 10 additions & 12 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,24 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ['3.9', '3.10', '3.11', '3.12', 'pypy-3.9', 'pypy-3.10']
python-version: ["3.9", "3.10", "3.11", "3.12", "pypy@3.9", "pypy@3.10"]

name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
- name: Install rye
uses: eifinger/setup-rye@v4

- name: Sync dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.lock
timeout-minutes: 5
rye pin ${{ matrix.python-version }}
rye sync
- name: Run tests
run: |
export PYTHONPATH=$(pwd)/src:$PYTHONPATH
source .venv/bin/activate
python tests/test_mepo_commands.py -v
timeout-minutes: 5
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*~
*.pyc
*.egg-info
*.lock
dist
venv

Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added ability to print version info via `mepo --version`

### Changed

## [2.0.0] - 2024-08-09
## [2.0.0] - 2024-08-12

### Fixed

Expand Down
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,42 @@

## Installation

### Using pip

To install `mepo` using `pip`, run the following command:

```
`pip install mepo`
```

### Homebrew

Using Homebrew, you can install `mepo` by installing from the gmao-si-team tap:

```
brew install gmao-si-team/packages/mepo
```

This is equivalent to running:

```
brew tap gmao-si-team/packages
brew install mepo
```

## Transitioning from `mepo` v1.x to v2.x

If you try to use mepo v2.x within a mepo v1.x repository, you will get an warning message:
```
Detected mepo1 style state
Run <mepo update-state> to permanently convert to mepo2 style
```

To update your repository to work with mepo v2.x, you can run the following command:
```
mepo update-state
```
and it will convert the repository from mepo v1 pickle-state to mepo v2 json-state.

## Commands

Expand Down
68 changes: 0 additions & 68 deletions requirements-dev.lock

This file was deleted.

14 changes: 0 additions & 14 deletions requirements.lock

This file was deleted.

7 changes: 7 additions & 0 deletions src/mepo/cmdline/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
from ..utilities import mepoconfig


def get_version():
from importlib import metadata

return metadata.version("mepo")


class MepoArgParser:

__slots__ = ["parser", "subparsers"]
Expand All @@ -16,6 +22,7 @@ def __init__(self):
self.parser = argparse.ArgumentParser(
description="Tool to manage (m)ultiple r(epo)s"
)
self.parser.add_argument("--version", action="version", version=get_version())
self.subparsers = self.parser.add_subparsers()
self.subparsers.title = "mepo commands"
self.subparsers.required = True
Expand Down
4 changes: 4 additions & 0 deletions tests/test_mepo_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import mepo.command.diff as mepo_diff
import mepo.command.whereis as mepo_whereis
import mepo.command.reset as mepo_reset
from mepo.cmdline.parser import get_version as get_mepo_version

# Import commands with dash in the name
mepo_restore_state = importlib.import_module("mepo.command.restore-state")
Expand Down Expand Up @@ -335,6 +336,9 @@ def test_reset(self):
with contextlib.redirect_stdout(io.StringIO()) as output:
self.__class__.__mepo_clone()

def test_mepo_version(self):
self.assertEqual(get_mepo_version(), "2.0.0")

def tearDown(self):
pass

Expand Down
Loading