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

Add uv and pixi. #464

Merged
merged 8 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
50 changes: 13 additions & 37 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. stall [cookiecutter] in a `uv venv` or `conda` environment (commented lines for
paddyroddy marked this conversation as resolved.
Show resolved Hide resolved
`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,39 +113,16 @@ 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
5. work on your project, initialise a Git repository and _install_ it in
paddyroddy marked this conversation as resolved.
Show resolved Hide resolved
editable mode.

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

6. Build your package
6. ild your package
paddyroddy marked this conversation as resolved.
Show resolved Hide resolved

```sh
python -m build
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 dependecy (and project) management tool. A drop-in replacement for `venv`. This will probably become our 🟢 tool, but for now we play cautious as there are some open bugs and features. If you're comfortable using `venv` syntax we'd recommend this. | 🟠 |
samcunliffe marked this conversation as resolved.
Show resolved Hide resolved
| [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