Skip to content

Add how-to for creating an environment #247

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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

munkm
Copy link
Member

@munkm munkm commented May 12, 2025

Here I'm adding a how-to that includes creating an environment, installing some scientific python tools in the environment, and also installing dependencies from a file. This guide covers basic commands for venv,

I didn't modify https://github.com/scientific-python/learn.scientific-python.org/blob/main/content/contributors/setup/install.md to link to this at first, but depending on review I can do that here or open a new PR.

Copy link

netlify bot commented May 12, 2025

Deploy Preview for learn-scientific-python-org ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit ba8e25d
🔍 Latest deploy log https://app.netlify.com/projects/learn-scientific-python-org/deploys/682517aad9098700084ef429
😎 Deploy Preview https://deploy-preview-247--learn-scientific-python-org.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100
Accessibility: 97
Best Practices: 100
SEO: 100
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

@guenp guenp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, just one nit

Copy link
Member

@matthewfeickert matthewfeickert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@munkm Thanks for this work and the PR! I've got some style change suggestions, small error corrections, and possible syntax revisions (but those could depend on what workflow you're trying to show).

Let me know if you have any questions!

Comment on lines 167 to 168
cd <path/to/science/>
source .venv/bin/activate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cd <path/to/science/>
source .venv/bin/activate
source science/bin/activate

Following pip example syntax

Comment on lines +195 to +200
Remember to re-activate your environment when you re-open a terminal. Navigate to
the science folder, and execute:

```shell
pixi shell
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it is worth mentioning that both Pixi and uv have run options that allow for you to execute operations inside the virtual environment without explicitly activating them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! I was having trouble when constructing this document deciding how broad (or narrow) to construct this document. I do think this is a useful tip. Do folks here think it should be included?

Copy link

@danielballan danielballan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great addition! One structural suggestion to consider: The environment managers are covered in chronological order. It might be helpful to move uv up to after pip. Once you know pip, you mostly know uv. Likewise, once you know conda, you mostly know mamba. It could be helpful to emphasize that uv and mamba intentionally hem very close to the pip and conda interfaces respectively.

Then, by way of transitioning to the discussion on pixi, this comparison guide may be a good resource for readers.

- pixi

In each of these examples we'll create a new virtual environment related to our
project called `science` (you can use whichever name you prefer!). We'll activate

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

science ❤️

@guenp
Copy link

guenp commented May 14, 2025

@henryiii
Copy link
Contributor

henryiii commented May 14, 2025

Longer term, I think it makes sense to try to put these in tabs. Most users don't want to learn 4 package managers at the same time, generally they learn one at a time. This could also be used to display the structure: native PyPI tools are pip and uv pip, native conda tools are conda and mamba/micromamba, all-in-one Conda is pixi, and all-in-one PyPI is uv (which I think is missing here). pip and uv pip could be inline tabs, since they are nearly the same. Same with conda/mamba (mamba and micromamba are the same these days, just different linkages when building). While there could also be page-wide tabs could be these four.

Something like this:

  ┌──────┐┌──────┐┌──────┐┌──────┐
  │pip   ││conda ││pixi  ││uv    │
  │      ╰┴──────┴┴──────┴┴──────┴────────────╮
  │                                           │
  │  ┌──────┐┌────────┐                       │
  │  │pip   ││uv pip  │                       │
  │  │      ╰┴────────┴───────────────────╮   │
  │  │                                    │   │
  │  │  python -m venv .venv              │   │
  │  │                                    │   │
  │  ╰────────────────────────────────────╯   │
  │   ...                                     │
  ╰───────────────────────────────────────────╯

I would recommend calling the virtual environment .venv. That's the default in uv, it gets picked up by the Python launcher for Unix, by VSCode, and is ignored in most repository gitignore's.

This overlaps a little with https://learn.scientific-python.org/development/tutorials/dev-environment/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants