Skip to content

Commit

Permalink
Add uv and pixi. (#464)
Browse files Browse the repository at this point in the history
Resolves #419.

Notably not done, is that I've not updated the tutorial.md to use `uv`
instead of Anaconda. I'd need to use a Windows machine to test the
instructions before I'd feel confident changing the tutorial.

---------

Co-authored-by: Patrick J. Roddy <[email protected]>
Co-authored-by: Matt Graham <[email protected]>
  • Loading branch information
3 people authored Oct 22, 2024
1 parent df14157 commit e309826
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 43 deletions.
46 changes: 11 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,13 @@ We also have a detailed [tutorial](tutorial.md) that has been given in a couple
The tutorial goes into much more pedagogical detail, it both describes using the template to create a package
and how to use the newly created package with some of the tools included.

1. Install [cookiecutter] in a Conda or `venv` environment (commented lines for
Conda example).
1. Install [cookiecutter] in a `uv venv` or `conda` environment (commented lines for
`uv venv` example).

```sh
# conda create --channel conda-forge --name new-env-name
# conda activate new-env-name
# conda install pip
pip install cookiecutter
# uv venv # creates a .venv directory wherever you are
# source ./.venv/bin/activate
uv pip install cookiecutter
```

2. Run cookiecutter in the desired directory
Expand Down Expand Up @@ -114,36 +113,13 @@ and how to use the newly created package with some of the tools included.
package_name [python_template]: PACKAGE_NAME
```

we will get a project folder named `PROJECT_SLUG`, structured like this:

```sh
PROJECT_SLUG
├── ...
├── README.md
├── pyproject.toml
├── src
│ └── PACKAGE_NAME
│ └── __init__.py
└── tests
└── test_dummy.py
```

And the `PROJECT_NAME` will appear in the README.md as the human-readable
name of the project.

```sh
cat PROJECT_SLUG/README.md
# PROJECT_NAME
...
```

5. To work on your project, initialise a Git repository and _install_ it in
editable mode.

```sh
cd PROJECT_SLUG
git init
python -m pip install -e ".[dev]"
uv pip install -e ".[dev]"
```

6. Build your package
Expand Down Expand Up @@ -175,10 +151,10 @@ cd python-tooling
- To create and remove your virtual environment

```sh
conda create -n ptoolingVE pip -c conda-forge
conda activate ptoolingVE
conda deactivate ptoolingVE
conda remove -n ptoolingVE --all
uv venv
source .venv/bin/activate
# do your work
deactivate
```

- To run template in the same path of this repo. We do a test cookiecut of a
Expand All @@ -188,7 +164,7 @@ cd python-tooling
cookiecutter .
cd python-template
git init
python -m pip install -e ".[dev]"
uv pip install -e ".[dev]"
```

- To run cookiecutter using a specific branch of the template:
Expand Down
20 changes: 12 additions & 8 deletions docs/pages/virtual.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@ layout: default

## Virtual environments

| Name | Short description | 🚦 |
| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-: |
| conda-forge [miniforge] | Installs, runs, and updates packages and their dependencies. Uses `conda`, but with community maintained packages from `conda-forge` channel instead of commercially maintained packages. | 🟢 |
| [pipenv] | Automatically creates and manages a virtualenv for your projects. | 🟠 |
| [pyenv] | Lets you easily switch between multiple versions of Python. | 🟠 |
| [virtualenv] | Creates isolated Python environments, and offers more features than venv. | 🟠 |
| [venv] | Creates isolated Python environments. Fewer features than other tools, but very widely used and comes built into Python. | 🟠 |
| [anaconda] | Due to recent [licensing ambiguity][anaconda-problems], we recommend avoiding anaconda and many of the default channels. We recommend installing miniforge and sticking to the `conda-forge` channel. | 🔴 |
| Name | Short description | 🚦 |
| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-: |
| conda-forge [miniforge] | Installs, runs, and updates packages and their dependencies. Uses `conda`, but with community maintained packages from `conda-forge` channel instead of commercially maintained packages. | 🟢 |
| [uv] | Fast dependency (and project) management tool. A drop-in replacement for `venv`. This will probably become our 🟢 tool, but for now we are playing cautious as there are some open bugs and features. If you're comfortable using `venv` syntax we'd recommend this. | 🟠 |
| [pipenv] | Automatically creates and manages a virtualenv for your projects. | 🟠 |
| [pixi] | A fast drop-in replacement for `conda`. | 🟠 |
| [pyenv] | Lets you easily switch between multiple versions of Python. | 🟠 |
| [virtualenv] | Creates isolated Python environments, and offers more features than venv. | 🟠 |
| [venv] | Creates isolated Python environments. Fewer features than other tools, but very widely used and comes built into Python. | 🟠 |
| [anaconda] | Due to recent [licensing ambiguity][anaconda-problems], we recommend avoiding anaconda and many of the default channels. We recommend installing miniforge and sticking to the `conda-forge` channel. | 🔴 |

<!-- links here for a more readable table -->

[miniforge]: https://conda-forge.org/download/
[uv]: https://docs.astral.sh/uv/getting-started/installation/
[pixi]: https://pixi.sh/latest/#installation
[pipenv]: https://pipenv.pypa.io/en/latest/
[pyenv]: https://github.com/pyenv/pyenv
[virtualenv]: https://virtualenv.pypa.io/en/latest/
Expand Down

0 comments on commit e309826

Please sign in to comment.