Skip to content

Commit

Permalink
Merge main into develop (#317)
Browse files Browse the repository at this point in the history
* Added ability to print version info (#309)

* Add brew tap installation instructions (#302)

* Add brew tap installation instructions

* Add update-state to readme

* Added ability to print version info

* Updated Changelog

* Testing mepo version against the last release version number

* Removing lock files

We really shouldn't need to version control lock files. Reusing already existing virtualenv
Generating production lockfile: /home/pchakrab/workspace/code/mepo/develop/requirements.lock
Generating dev lockfile: /home/pchakrab/workspace/code/mepo/develop/requirements-dev.lock
Installing dependencies
Found existing installation: mepo 2.0.0
Uninstalling mepo-2.0.0:
  Successfully uninstalled mepo-2.0.0
Looking in indexes: https://pypi.org/simple/
Obtaining file:///. (from -r /home/pchakrab/tmp/tmpatm5q2yh (line 1))
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Checking if build backend supports build_editable: started
  Checking if build backend supports build_editable: finished with status 'done'
  Getting requirements to build editable: started
  Getting requirements to build editable: finished with status 'done'
  Installing backend dependencies: started
  Installing backend dependencies: finished with status 'done'
  Preparing editable metadata (pyproject.toml): started
  Preparing editable metadata (pyproject.toml): finished with status 'done'
Building wheels for collected packages: mepo
  Building editable for mepo (pyproject.toml): started
  Building editable for mepo (pyproject.toml): finished with status 'done'
  Created wheel for mepo: filename=mepo-2.0.0-py3-none-any.whl size=11085 sha256=758e0b5ae11be1d887f2598e6c04fc09648e00a736ffbe8ae47fbad802e2978f
  Stored in directory: /home/pchakrab/tmp/pip-ephem-wheel-cache-5f1wnqzn/wheels/97/54/f5/d849319cdfa096e074df352654ee2e7c919da8951f090690c6
Successfully built mepo
Installing collected packages: mepo
Successfully installed mepo-2.0.0
Done! will generate them from

* Removing lock files

Merging the changes from main brought in the lock files again

* Using rye for Python and package management

* Minor cleanup of workflows

---------

Co-authored-by: Matt Thompson <[email protected]>

* Add spack install instructions (#310)

* Update README (#315)

* Store complete remote url in state file (#316)

* Added pytest as a dev dependency to pyproject.toml

Now we can run tests via 'rye test'

* Store full remote path of every repo in state file

* Moved logic to apply style to local path to a separate function

* Remote URL is not relative anymore

* Added pytests for Registry and MepoComponent classes

* Running 'rye test' to run all tests

* Generate default __eq__() method in MepoComponent to (rich) compare two instances of this class

* Updated test_component for the case when remote is an https url instead of ssh

* Switched to https protocol

* bug fix

* Remote was of a different repo. Fixed now.

* Removed MepoState dependence of git.py

The state file (state.json) stores the relative local path to each repo. However, during reading of the state, MepoState converts it to an absolute path, and every instantiation of GitRepository uses an absolute local path. So we don't need to call get_root_dir() from GitRepository

* Added explicit init of MepoComponent

* update-state writes compelete remote url

* Removed unnecessary, and wrong, check for local path

* Bumped the minor version number

* Moved pytest from being a dependency to a dev-dependency. Fixed test that checks for version

* Completion working now

---------

Co-authored-by: Matt Thompson <[email protected]>
  • Loading branch information
pchakraborty and mathomp4 authored Oct 2, 2024
1 parent 1b379a0 commit 08d71bd
Show file tree
Hide file tree
Showing 18 changed files with 252 additions and 241 deletions.
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
23 changes: 10 additions & 13 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,23 @@ 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
python tests/test_mepo_commands.py -v
rye test -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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ 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-12
Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# mepo [![Actions Status](https://github.com/pchakraborty/mepo/workflows/Unit%20testing%20of%20mepo/badge.svg)](https://github.com/pchakraborty/mepo/actions) [![DOI](https://zenodo.org/badge/215067850.svg)](https://zenodo.org/badge/latestdoi/215067850) [![Rye](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/rye/main/artwork/badge.json)](https://rye-up.com)

`mepo` is a tool, written in Python3 (3.9.0+), to manage (m)ultiple git r(epo)sitories, by attempting to create an illusion of a 'single repository' for multi-repository projects. Please see the [Wiki](../../wiki) for examples of `mepo` workflows.
`mepo` is a tool, written in Python3, to manage (m)ultiple git r(epo)sitories, by attempting to create an illusion of a 'single repository' for multi-repository projects. Please see the [Wiki](../../wiki) for examples of `mepo` workflows.


## Installation

Expand All @@ -9,7 +10,7 @@
To install `mepo` using `pip`, run the following command:

```
`pip install mepo`
pip install mepo
```

### Homebrew
Expand All @@ -27,6 +28,14 @@ brew tap gmao-si-team/packages
brew install mepo
```

### Spack

Mepo is also available via spack as a package. To install mepo using spack, run the following command:

```
spack 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:
Expand Down
19 changes: 9 additions & 10 deletions etc/mepo-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

# complete -W "init clone status checkout branch diff where whereis history" mepo

# SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
SCRIPT_DIR=$(dirname $(realpath $0))

_get_mepo_commands() {
local mepo_cmd_list=""
if [[ "$OSTYPE" == "darwin"* ]]
then
local mepodir=$(dirname $(readlink $(which mepo)))
else
local mepodir=$(dirname $(readlink -f $(which mepo)))
fi
for mydir in $(ls -d ${mepodir}/mepo.d/command/*/); do
if [[ $mydir != *"__pycache__"* ]]; then
mepo_cmd_list+=" $(basename $mydir)"
fi
local mepo_dir=$(python3 $SCRIPT_DIR/mepo-path.py)
for pyfile in $(ls ${mepo_dir}/command/*.py*); do
command=${pyfile##*/} # remove path
command=${command%.*} # remove extension
command=$(echo $command | cut -d _ -f 1)
mepo_cmd_list+=" $command"
done
echo ${mepo_cmd_list}
}
Expand Down
3 changes: 3 additions & 0 deletions etc/mepo-path.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import os, mepo

print(os.path.dirname(mepo.__file__))
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "mepo"
version = "2.0.0"
version = "2.1.0"
description = "A tool for managing (m)ultiple r(epo)s"
authors = [{name="GMAO SI Team", email="[email protected]"}]
dependencies = [
Expand All @@ -23,6 +23,7 @@ dev-dependencies = [
"flake8>=7.0.0",
"pre-commit>=3.7.1",
"mdutils>=1.6.0",
"pytest>=8.2.1",
]

[build-system]
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
6 changes: 6 additions & 0 deletions src/mepo/command/update-state.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"""Permanently convert mepo1 state to mepo2 state"""

from urllib.parse import urljoin

from ..state import MepoState
from ..git import get_current_remote_url


def run(_):
Expand All @@ -9,6 +12,9 @@ def run(_):
# mepo2 style does not exist
allcomps = MepoState.read_state()
MepoState.mepo1_patch_undo()
for comp in allcomps:
if comp.remote.startswith("../"):
comp.remote = urljoin(get_current_remote_url() + "/", comp.remote)
# Write new state
MepoState.write_state(allcomps)
print("\nConverted mepo1 state to mepo2\n")
Expand Down
Loading

0 comments on commit 08d71bd

Please sign in to comment.