diff --git a/.github/workflows/run-formatter.yaml b/.github/workflows/run-formatter.yaml index 2d42054..a061e61 100644 --- a/.github/workflows/run-formatter.yaml +++ b/.github/workflows/run-formatter.yaml @@ -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 diff --git a/.github/workflows/run-linter.yaml b/.github/workflows/run-linter.yaml index 0607441..a3251c6 100644 --- a/.github/workflows/run-linter.yaml +++ b/.github/workflows/run-linter.yaml @@ -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 diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index bbddc13..ae2a7bb 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -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 diff --git a/.gitignore b/.gitignore index 07e88d2..5f155ed 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *~ *.pyc *.egg-info +*.lock dist venv diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f0d8d4..9a21fec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 5bf8a88..588388e 100644 --- a/README.md +++ b/README.md @@ -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 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 diff --git a/requirements-dev.lock b/requirements-dev.lock deleted file mode 100644 index 15f19a7..0000000 --- a/requirements-dev.lock +++ /dev/null @@ -1,68 +0,0 @@ -# generated by rye -# use `rye lock` or `rye sync` to update this lockfile -# -# last locked with the following flags: -# pre: false -# features: [] -# all-features: false -# with-sources: false - --e file:. -astroid==3.2.1 - # via pylint -black==24.4.2 -cfgv==3.4.0 - # via pre-commit -click==8.1.7 - # via black -colorama==0.4.6 - # via mepo -dill==0.3.8 - # via pylint -distlib==0.3.8 - # via virtualenv -filelock==3.14.0 - # via virtualenv -flake8==7.0.0 -identify==2.5.36 - # via pre-commit -isort==5.13.2 - # via pylint -mccabe==0.7.0 - # via flake8 - # via pylint -mdutils==1.6.0 -mypy-extensions==1.0.0 - # via black -nodeenv==1.8.0 - # via pre-commit -packaging==24.0 - # via black -pathspec==0.12.1 - # via black -platformdirs==4.2.2 - # via black - # via pylint - # via virtualenv -pre-commit==3.7.1 -pycodestyle==2.11.1 - # via flake8 -pyflakes==3.2.0 - # via flake8 -pylint==3.2.0 -pyyaml==6.0.1 - # via mepo - # via pre-commit -setuptools==70.0.0 - # via nodeenv -tomli==2.0.1 - # via black - # via pylint -tomlkit==0.12.5 - # via pylint -typing-extensions==4.11.0 - # via astroid - # via black - # via pylint -virtualenv==20.26.2 - # via pre-commit diff --git a/requirements.lock b/requirements.lock deleted file mode 100644 index 7cecfb7..0000000 --- a/requirements.lock +++ /dev/null @@ -1,14 +0,0 @@ -# generated by rye -# use `rye lock` or `rye sync` to update this lockfile -# -# last locked with the following flags: -# pre: false -# features: [] -# all-features: false -# with-sources: false - --e file:. -colorama==0.4.6 - # via mepo -pyyaml==6.0.1 - # via mepo diff --git a/src/mepo/cmdline/parser.py b/src/mepo/cmdline/parser.py index cddd3f2..4cee79d 100644 --- a/src/mepo/cmdline/parser.py +++ b/src/mepo/cmdline/parser.py @@ -8,6 +8,12 @@ from ..utilities import mepoconfig +def get_version(): + from importlib import metadata + + return metadata.version("mepo") + + class MepoArgParser: __slots__ = ["parser", "subparsers"] @@ -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 diff --git a/tests/test_mepo_commands.py b/tests/test_mepo_commands.py index b610f82..19966da 100644 --- a/tests/test_mepo_commands.py +++ b/tests/test_mepo_commands.py @@ -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") @@ -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