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 a recipe for setting up a virtualenv #5

Merged
merged 4 commits into from
Feb 28, 2021
Merged

Conversation

mwichmann
Copy link
Contributor

Signed-off-by: Mats Wichmann [email protected]

@mwichmann mwichmann requested a review from bdbaddog February 5, 2021 16:42
@mwichmann
Copy link
Contributor Author

Is it important to include an equivalent log of doing on Windows, btw?


$ cd Work
$ python -m venv myvenv
$ cd myvenv
Copy link
Contributor

Choose a reason for hiding this comment

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

You shouldn't need to cd into myenv to source bin/activate

For windows you use scripts/activate.bat or activate.ps1(for powershell)

$ python -m venv myvenv
$ cd myvenv
$ source bin/activate
(myvenv) $ python -m pip list --outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Only time I use python -m pip is on windows to upgrade pip itself

I'd just use pip here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can change that; if the virtualenv is active, pip indeed will be "the correct one", I just usually use this form when showing people stuff in order to cultivate good habits. People get itno a lot of trouble just running pip, and then "why won't Python find my module".

setuptools 41.6.0 53.0.0 wheel
WARNING: You are using pip version 19.3.1; however, version 21.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(myvenv) $ python -m pip install --upgrade pip setuptools scons
Copy link
Contributor

Choose a reason for hiding this comment

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

But not here, and maybe include a comment about why.. though pip install -U pip works on non-windows, it fails on windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Took a moment to parse this. Anyway, I have the equivalent Windows log from the same time, just wasn't sure if it needed to be added to the recipe.

C:\Users\mats>cd Work

C:\Users\mats\Work>py -m venv myvenv

C:\Users\mats\Work>cd myvenv

C:\Users\mats\Work\myvenv>.\Scripts\activate

(myvenv) C:\Users\mats\Work\myvenv>python -m pip list --outdated
Package    Version Latest Type
---------- ------- ------ -----
pip        20.2.3  21.0.1 wheel
setuptools 49.2.1  53.0.0 wheel
WARNING: You are using pip version 20.2.3; however, version 21.0.1 is available.You should consider upgrading via the 'C:\Users\mats\Work\myvenv\Scripts\python.exe -m pip install --upgrade pip' command.

(myvenv) C:\Users\mats\Work\myvenv>python -m pip install --upgrade pip setuptools scons
Collecting pip
  Using cached pip-21.0.1-py3-none-any.whl (1.5 MB)
Collecting setuptools
  Using cached setuptools-53.0.0-py3-none-any.whl (784 kB)
Collecting scons
  Using cached SCons-4.1.0.post1-py3-none-any.whl (4.1 MB)
Installing collected packages: pip, setuptools, scons
  Attempting uninstall: pip
    Found existing installation: pip 20.2.3
    Uninstalling pip-20.2.3:
      Successfully uninstalled pip-20.2.3
  Attempting uninstall: setuptools
    Found existing installation: setuptools 49.2.1
    Uninstalling setuptools-49.2.1:
      Successfully uninstalled setuptools-49.2.1
Successfully installed pip-21.0.1 scons-4.1.0.post1 setuptools-53.0.0

(myvenv) C:\Users\mats\Work\myvenv>scons --version
SCons by Steven Knight et al.:
        SCons: v4.1.0.post1.dc58c175da659d6c0bb3e049ba56fb42e77546cd, 2021-01-20 04:32:28, by bdbaddog on ProDog2020
        SCons path: ['c:\\users\\mats\\work\\myvenv\\lib\\site-packages\\SCons']
Copyright (c) 2001 - 2021 The SCons Foundation

(myvenv) C:\Users\mats\Work\myvenv>

@bdbaddog
Copy link
Contributor

bdbaddog commented Feb 7, 2021

I'd replace all the python -m pip's with pip except for upgrading pip itself.

Signed-off-by: Mats Wichmann <[email protected]>

.. code:: shell

$ cd Work
$ python -m venv myvenv
$ cd myvenv
$ source bin/activate
Copy link
Contributor

Choose a reason for hiding this comment

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

source myvenv/bin/activate

Copy link
Contributor

Choose a reason for hiding this comment

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

and actually . myvenv/bin/activate should also work. (that's what I typically do, less typing.. )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, hand-editing logs never works out right

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can trim these further if you want - just trying to figure out what still needs doing here to complete this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup. If you can fix that, then we're good to go.

@bdbaddog
Copy link
Contributor

bdbaddog commented Feb 9, 2021

A thought.. perhaps a TL:DR section at the top with just

python -m venv myenv
. bin/activate
pip install SCons
scons --version

Then the current text as an expanded info below?

@mwichmann
Copy link
Contributor Author

I see I forgot to make a new branch for this PR, is it still going to be okay, or should I start over?

An earlier fix removed the cd to the created venv, but
the session startup capture wasn't updated to reflect that we're
not in the env when activating.  Activate call updated.

Signed-off-by: Mats Wichmann <[email protected]>
The correct type for Sphinx to markup a Bash-type shell session
is "console" or "shell-session", for a DOS shell it's "doscon".
(FYI, for a PowerShell session it's "ps1con")

Signed-off-by: Mats Wichmann <[email protected]>
@bdbaddog bdbaddog merged commit c5966b2 into SCons:master Feb 28, 2021
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.

2 participants