@@ -39,42 +39,24 @@ Enter the ``dev`` nox session:
39
39
40
40
.. code-block :: python
41
41
42
- import os
43
- import pathlib
44
-
45
42
import nox
46
43
44
+
47
45
# It's a good idea to keep your dev session out of the default list
48
46
# so it's not run twice accidentally
49
- nox.options.sessions = [... ] # Sessions other than 'dev'
50
-
51
- # this VENV_DIR constant specifies the name of the dir that the `dev`
52
- # session will create, containing the virtualenv;
53
- # the `resolve()` makes it portable
54
- VENV_DIR = pathlib.Path(' ./.venv' ).resolve()
55
-
56
- @nox.session
47
+ @nox.session (default = False )
57
48
def dev (session : nox.Session) -> None :
58
49
"""
59
- Sets up a python development environment for the project.
60
-
61
- This session will:
62
- - Create a python virtualenv for the session
63
- - Install the `virtualenv` cli tool into this environment
64
- - Use `virtualenv` to create a global project virtual environment
65
- - Invoke the python interpreter from the global project environment to install
66
- the project and all it's development dependencies.
50
+ Set up a python development environment for the project at ".venv".
67
51
"""
68
52
69
53
session.install(" virtualenv" )
70
- # the VENV_DIR constant is explained above
71
- session.run(" virtualenv" , os.fsdecode(VENV_DIR ), silent = True )
72
54
73
- python = os.fsdecode( VENV_DIR .joinpath( " bin/python " ) )
55
+ session.run( " virtualenv " , " .venv " , silent = True )
74
56
75
57
# Use the venv's interpreter to install the project along with
76
58
# all it's dev dependencies, this ensures it's installed in the right way
77
- session.run(python, " -m " , " pip" , " install" , " -e" , " .[dev]" , external = True )
59
+ session.run(" .venv/bin/ pip" , " install" , " -e" , " .[dev]" , external = True )
78
60
79
61
With this, a user can simply run ``nox -s dev `` and have their entire environment set up automatically!
80
62
0 commit comments