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

πŸ“ change pipx for UV #107

Merged
merged 4 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,20 @@ Table of Contents

It is highly recommended to use a python version manager like [Pyenv] and this project is set to use [Poetry] >= 1.8 to manage the dependencies and the environment.

**Note:** [Poetry] >= 1.8 should always be installed in a dedicated virtual environment to isolate it from the rest of your system. [why?](https://python-poetry.org/docs/#installation)
**Note:** [Poetry] >= 1.8 should always be installed in a dedicated virtual environment to isolate it from the rest of your system. [why?](https://python-poetry.org/docs/#installation), I recommend using [UV] to install poetry in an isolated environment.

```bash

🌟 Check how to setup your environment: <https://joserzapata.github.io/data-science-project-template/local_setup/>

### πŸͺπŸ₯‡ Via [Cruft] - **recommended**

```bash title="install cruft"
pip install --user cruft # Install `cruft` on your path for easy access

# Or Install with UV

uv tool install cruft # Install cruft in a isolated environment
```

```shell title="create project"
Expand All @@ -74,6 +80,10 @@ cruft create https://github.com/JoseRZapata/data-science-project-template

```shell title="install cookiecutter"
pip install --user cookiecutter # Install `cookiecutter` on your path for easy access

# Or Install with UV

uv tool install cookiecutter # Install cruft in a isolated environment
```

```shell title="create project"
Expand Down Expand Up @@ -343,3 +353,4 @@ test Test the code with pytest and coverage
[Pytest]: https://docs.pytest.org/en/latest/
[pyupgrade]: https://github.com/asottile/pyupgrade
[Ruff]: https://docs.astral.sh/ruff/
[UV]: https://docs.astral.sh/uv/
38 changes: 16 additions & 22 deletions docs/local_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,37 @@ I setup my local development environment using the following steps:
- Linux: `curl https://pyenv.run | bash`
- MAC: `brew install pyenv`
- **Check the installation version** executing in terminal: `pyenv --version` for help go to [pyenv installation help](https://github.com/pyenv/pyenv?tab=readme-ov-file#set-up-your-shell-environment-for-pyenv)
4. Install [Python] using [Pyenv] , at this time I am using Python 3.11
4. Install [Python] using [Pyenv], at this time I am using Python 3.11
(In the future, I recommend using [UV] to manage Python versions. UV is a faster,
more efficient alternative to traditional package managers and virtual environments.)
- `pyenv install 3.11` # Install Python 3.11 in computer
- `pyenv global 3.11` # Set Python 3.11 as global version
- **Check the installation version** executing in terminal: `python --version`
5. Install locally [Pipx] to Install and Run Python Applications in Isolated Environments
5. Install locally [UV] to Install and Run Python Applications in Isolated Environments
JoseRZapata marked this conversation as resolved.
Show resolved Hide resolved
- Linux:

```bash title="Install pipx in Linux"
pip install --user pipx
python3 -m pipx ensurepath
```bash title="Install uv in Linux or MACOS"
curl -LsSf https://astral.sh/uv/install.sh | sh
```

- Check the installation version executing in terminal: `pipx --version`

- MAC:

JoseRZapata marked this conversation as resolved.
Show resolved Hide resolved
```bash title="Install pipx in Mac os"
brew install pipx
pipx ensurepath
```

- Check the installation version executing in terminal: `pipx --version`
- Check the installation version executing in terminal: `uv version`

## 🐍 General Python tools

General Tools that I use to develop Python projects, The most important is [Poetry] and all this tools are installed using [Pipx] to have this tools in isolated environments, because applications runs in its own virtual environment to avoid dependencies conflicts and they are available everywhere.
General Tools that I use to develop Python projects, The most important is [Poetry] and all this tools are installed using [UV] to have this tools in isolated environments, because applications runs in its own virtual environment to avoid dependencies conflicts and they are available everywhere.

[When pipx is typically used?](https://python.land/virtual-environments/pipx#When_pipx_is_typically_used)
[UV Highligths](https://github.com/astral-sh/uv?tab=readme-ov-file#highlights)

1. [Poetry] to manage the dependencies and the virtual environment of the project.
- `pipx install poetry`
- `uv tool install poetry`
2. [Cruft] allows you to maintain all the necessary boilerplate for packaging and building projects separate from the code you intentionally write. Fully compatible with existing Cookiecutter templates.
- `pipx install cruft`
- `uv tool install cruft`
3. (optional) [Pip-audit] to local check the security of the dependencies of the project.
- `pipx install pip-audit`
- `uv tool install pip-audit`
4. (optional) [Actionlint] to check the syntax of the GitHub Actions configuration files of the project.
- `pipx install actionlint`
- `uv tool install actionlint`

**Note:** [UV] is a tool that wants to replace the need of [Pyenv], [Poetry] and other ones. So is very possible that in the future I will use [UV] to manage the python versions, environments and dependencies.

## πŸ“ Start a new data science project

Expand Down Expand Up @@ -83,8 +77,8 @@ General Tools that I use to develop Python projects, The most important is [Poet
[Git]: https://git-scm.com/
[Make]: https://www.gnu.org/software/make/manual/make.html
[Pip-audit]: https://github.com/pypa/pip-audit
[Pipx]: https://pipx.pypa.io/stable/
[Poetry]: https://python-poetry.org/docs/
[Pyenv]: https://github.com/pyenv/pyenv?tab=readme-ov-file#installation
[Python]: https://www.python.org/downloads/
[UV]: https://docs.astral.sh/uv/
[WSL]: https://docs.microsoft.com/en-us/windows/wsl/install