Skip to content

Commit

Permalink
Migrate to uv (#570)
Browse files Browse the repository at this point in the history
* Switch to uv

* Use uv in test pypi upload

* Add "explicit" to testpypi

* Use hatchling for building

* Use uv for real pypi publish

* Rework usage/install
  • Loading branch information
PabloLec authored Jan 25, 2025
1 parent 6c7e3f4 commit 8a4f2be
Show file tree
Hide file tree
Showing 7 changed files with 246 additions and 1,460 deletions.
48 changes: 13 additions & 35 deletions .github/workflows/pypi-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,26 @@ name: Release on PyPI

on:
release:
types: [released]
types: [ released ]
workflow_dispatch:
branches: [main]
inputs:
version:
description: 'Version'
required: true
branches: [ main ]

jobs:
pypi_release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Checkout code
uses: actions/checkout@v4

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "${HOME}/.poetry/bin" >> $GITHUB_PATH
- name: Add Poetry to path
run: echo "${HOME}/.poetry/bin" >> $GITHUB_PATH

- name: Install dependencies
run: |
poetry install
sudo apt-get install progress
- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Run tests
run: poetry run pytest
- name: Setup Python
uses: actions/setup-python@v5

- name: Set version based on tag or input
- name: Publish to PyPi
env:
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
if [[ $GITHUB_EVENT_NAME == 'release' ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION=${{ github.event.inputs.version }}
fi
poetry version $VERSION
- name: Configure Poetry
run: poetry config pypi-token.pypi "${{ secrets.PYPI_TOKEN }}"

- name: Publish package
run: poetry publish --build
uv build
uv publish
14 changes: 8 additions & 6 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: tests
name: Run tests

on: [ push, pull_request ]

Expand All @@ -15,6 +15,11 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}

- name: Setup Python
uses: actions/setup-python@v5
with:
Expand All @@ -24,14 +29,11 @@ jobs:
- name: Install dependencies
shell: bash
run: |
python -m pip install poetry && python -m pip install poetry-plugin-export
python -m pip install --upgrade pip
poetry export --dev --without-hashes --output requirements.txt
python -m pip install -r requirements.txt
uv sync
sudo apt install progress -y
- name: Run tests
run: pytest
run: uv run pytest

automerge-dependabot:
runs-on: ubuntu-latest
Expand Down
23 changes: 9 additions & 14 deletions .github/workflows/test-pypi-release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test release upload
name: Test release on PyPI

on:
workflow_dispatch:
Expand All @@ -13,20 +13,15 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Setup Python
uses: actions/setup-python@v5

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "${HOME}/.poetry/bin" >> $GITHUB_PATH
- name: Install dependencies
run: |
poetry install
- name: Setup and Publish to Test PyPi
- name: Publish to Test PyPi
env:
UV_PUBLISH_TOKEN: ${{ secrets.TEST_PYPI_TOKEN }}
run: |
poetry config repositories.testpypi https://test.pypi.org/legacy/
poetry config pypi-token.testpypi ${{ secrets.TEST_PYPI_TOKEN }}
poetry publish --build --repository testpypi --dry-run
uv build
uv publish --index testpypi
60 changes: 31 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@
---

<!--ts-->
* [Demo](#Demo)
* [Installation](#Installation)
* [Dependencies](#dependencies)
* [Run with pipx](#run-with-pipx)
* [Installation from pip](#installation-from-pip)
* [Installation from AUR](#installation-from-aur)
* [Usage](#Usage)
* [Tips](#Tips)
* [Contributing](#Contributing)

* [Demo](#Demo)
* [Installation](#Installation)
* [Dependencies](#dependencies)
* [Run with pipx](#run-with-pipx)
* [Installation from pip](#installation-from-pip)
* [Installation from AUR](#installation-from-aur)
* [Usage](#Usage)
* [Tips](#Tips)
* [Contributing](#Contributing)

<!--te-->

---
Expand All @@ -45,54 +47,51 @@ RecoverPy is a powerful tool that leverages your system capabilities to recover
Unlike others, you can not only recover deleted files but also **overwritten** data.

Every block of your partition will be scanned. You can even find a string in binary files.

## Demo

<p align="center">
<img src="docs/assets/demo.gif">
</p>

## Installation
## Setup

:penguin: RecoverPy is currently only available on Linux systems.
:red_circle: **You must be root or use sudo**.

### Dependencies

**Mandatory:** To list and search through your partitions, recoverpy uses `grep`, `dd`, and `lsblk` commands. Although, if you're running a major Linux distrucition these tools should already be installed.
**Mandatory:** To list and search through your partitions, recoverpy uses `grep`, `dd`, and `lsblk` commands. Although,
if you're running a major Linux distrucition these tools should already be installed.

**Optional:** To display real time grep progress, you can install `progress`.

To install all dependencies:

- Debian-like: `apt install grep coreutils util-linux progress`
- Arch: `pacman -S grep coreutils util-linux progress`
- Fedora: `dnf install grep coreutils util-linux progress`

## Usage

### Run with pipx
### Run with uvx

You can **directly run recoverpy with pipx in an isolated environment** without installing it.
To install pipx, follow the [official documentation](https://pipxproject.github.io/pipx/installation/).
To run recoverpy with pipx, simply run:
`sudo uvx recoverpy`

### Run with pipx

`sudo pipx run recoverpy`

#### Installation from pip
### Installation from pip

`python3 -m pip install recoverpy`

#### Installation from AUR

`yay -S python-recoverpy`

## Usage

```bash
python3 -m recoverpy
```
then run `sudo python3 -m recoverpy`

---

- **Select the system partition** in which your file was. If you are out of luck, you can alternatively search in your home partition, maybe your IDE, text editor, etc. made a backup at some point.
- **Select the system partition** in which your file was. If you are out of luck, you can alternatively search in your
home partition, maybe your IDE, text editor, etc. made a backup at some point.

- **Type a text string to search**. See tips below for better results.

Expand All @@ -102,12 +101,14 @@ python3 -m recoverpy

- Once you have found your precious, **select `Open`**.

- You can now either save this block individually or explore neighboring blocks for the remaining parts of the file. You could then save it all in one file.
- You can now either save this block individually or explore neighboring blocks for the remaining parts of the file. You
could then save it all in one file.

## Tips

- Always do backups! Yes, maybe too late...
- **Unmount your partition before you do anything!** Although you can search with your partition still mounted, it is highly recommended to unmount your partition to avoid any alteration to your file.
- **Unmount your partition before you do anything!** Although you can search with your partition still mounted, it is
highly recommended to unmount your partition to avoid any alteration to your file.

Regarding the searched string:

Expand All @@ -117,7 +118,8 @@ Regarding the searched string:

When you have found your file:

- You might see multiple results. Your system often use different partion blocks to save successive versions of a file. Make sure you've found the last version.
- You might see multiple results. Your system often use different partion blocks to save successive versions of a file.
Make sure you've found the last version.
- Try exploring neighboring blocks to be sure to save your whole file.

## Contributing
Expand Down
Loading

0 comments on commit 8a4f2be

Please sign in to comment.