Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add how-to for creating an environment #247

Open
munkm wants to merge 11 commits intoscientific-python:main from
munkm:environment-docs
Open

Add how-to for creating an environment #247
munkm wants to merge 11 commits intoscientific-python:main from
munkm:environment-docs

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.

matthewfeickert reacted with rocket emoji
Copy link

netlify bot commented May 12, 2025
edited
Loading

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

munkm reacted with thumbs up emoji
Co-authored-by: Guen Prawiroatmodjo <guenevere.p@gmail.com>
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

@matthewfeickert matthewfeickert May 14, 2025

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

@matthewfeickert matthewfeickert May 14, 2025

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?

matthewfeickert and drammock reacted with thumbs up emoji
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
Copy link

@danielballan danielballan May 14, 2025

Choose a reason for hiding this comment

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

science ❤️

munkm reacted with heart emoji munkm reacted with rocket emoji
Copy link

guenp commented May 14, 2025

Copy link
Contributor

henryiii commented May 14, 2025
edited
Loading

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/.

danielballan reacted with thumbs up emoji guenp reacted with heart emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@danielballan danielballan danielballan left review comments

@drammock drammock Awaiting requested review from drammock

+2 more reviewers

@matthewfeickert matthewfeickert matthewfeickert requested changes

@guenp guenp guenp approved these changes

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /