Skip to content

Commit 03c0afd

Browse files
committed
Move most important takeaway to the top
1 parent d1cd2de commit 03c0afd

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

_overviews/scala3-book/scala-for-python-devs.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,25 +1293,25 @@ Follow the links below for more details:
12931293

12941294
## How to setup a virtual environnement in Scala?
12951295

1296-
By default Python and Python modules are installed at system-wide directories or user-wide directories. Virtual environments are a way of obtaining an isolated environment on a per-project basis. Typical flow to configure the virtual environment using for example `venv` module in Python might be something like so
1296+
In Scala there is no need to explicitly setup an equivalent of Python's virtual environnement. By default, build tools manage project's dependencies such that user does not have to think about site directories. For example using `sbt` build tool we specify dependencies inside `build.sbt` file under `libraryDependencies` setting, then executing
12971297

12981298
```
12991299
cd myapp
1300-
python3 -m venv myapp-env
1301-
source myapp-env/bin/activate
1302-
pip install -r requirements.txt
1300+
sbt compile
13031301
```
13041302

1305-
This installs all the dependencies under project's directory `myapp/myapp-env` and alters the shell environmental variable `PATH` to look up dependencies from `myapp-env`.
1303+
would automatically resolve all dependencies for that particular project. The location of downloaded dependencies is largely an implementation detail of the build tool that users do not interact with directly. For example, if we were to delete the whole sbt dependencies cache, one the next compilation of the project, sbt will simply re-resolve automatically all the required dependencies.
13061304

1307-
In Scala there is no need to explicitly setup an equivalent of Python's virtual environnement. By default, build tools manage project's dependencies such that user does not have to explicitly think about site directories. For example using `sbt` build tool we specify dependencies inside `build.sbt` file under `libraryDependencies` setting, then executing
1305+
This differs from Python were by default dependencies are installed at system-wide or user-wide directories, so to obtain an isolated environment on a per-project basis we have to create a corresponding virtual environment. For example, using `venv` module we might create one for a particular project like so
13081306

13091307
```
13101308
cd myapp
1311-
sbt compile
1309+
python3 -m venv myapp-env
1310+
source myapp-env/bin/activate
1311+
pip install -r requirements.txt
13121312
```
13131313

1314-
would automatically resolve all dependencies for that particular project. The location of downloaded dependencies is largely an implementation detail of the build tool that users do not interact with directly. For example, if were to delete the whole sbt dependencies cache, one next compilation of the project, sbt will simply re-resolve automatically all the required dependencies.
1314+
This installs all the dependencies under project's directory `myapp/myapp-env` and alters the shell environmental variable `PATH` to look up dependencies from `myapp-env`.
13151315

13161316

13171317
[collections-classes]: {% link _overviews/scala3-book/collections-classes.md %}

0 commit comments

Comments
 (0)