You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/users-guide/modelsetup.rst
+87-32Lines changed: 87 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -139,7 +139,7 @@ Install UV
139
139
We recommend installing UV as an independent tool on your machine, separate from any existing package managers you may have such as conda or pip.
140
140
141
141
For Windows users, run the following command in PowerShell to install *uv*. It does not require administrator privileges and installs *uv* for the current user only.
142
-
By default, uv is installed to `~/.local/bin` directory. Usually, this is `C:/Users/<username>/.local/bin`.
142
+
By default, uv is installed to ``~/.local/bin`` directory. Usually, this is ``C:/Users/<username>/.local/bin``.
143
143
144
144
::
145
145
@@ -153,11 +153,11 @@ If an agency wants to install *uv* globally for all users on Windows, run PowerS
153
153
154
154
::
155
155
156
-
# Run the installer with a custom install directory
For more instructions on installing *uv* on Windows, MacOS, or Linux, please visit https://docs.astral.sh/uv/getting-started/installation/.
163
163
@@ -221,16 +221,16 @@ Open Command Prompt (not Anaconda Prompt), and run the following commands.
221
221
# add ActivitySim package from the latest release on PyPI
222
222
uv add activitysim
223
223
224
-
*uv* will create a new virtual environment within the `asim_project` project folder
224
+
*uv* will create a new virtual environment within the ``asim_project`` project folder
225
225
and install ActivitySim and its dependencies. The virtual environment is a hidden folder
226
-
within the `asim_project` directory called `.venv` and operates the same way as Python's classic *venv*. You will notice
227
-
two new files created in the `asim_project` directory: `pyproject.toml` and `uv.lock`. These files
228
-
are automatically created, updated, and used by *uv* to manage your `asim_project` project and its dependencies.
229
-
You can share these files with others to recreate the same environment for your `asim_project` project. For more guidance on sharing your working environment,
226
+
within the ``asim_project`` directory called ``.venv`` and operates the same way as Python's classic *venv*. You will notice
227
+
two new files created in the ``asim_project`` directory: ``pyproject.toml`` and ``uv.lock``. These files
228
+
are automatically created, updated, and used by *uv* to manage your ``asim_project`` project and its dependencies.
229
+
You can share these files with others to recreate the same environment for your ``asim_project`` project. For more guidance on sharing your working environment,
230
230
see the Common Q&A :ref:`How to share my working environment with others?` section below.
231
231
232
-
By running the command `uv add activitysim`, you install the official release of ActivitySim from PyPI and its direct dependencies
233
-
listed in ActivitySim's `pyproject.toml` file. This approach is the quickest
232
+
By running the command ``uv add activitysim``, you install the official release of ActivitySim from PyPI and its direct dependencies
233
+
listed in ActivitySim's ``pyproject.toml`` file. This approach is the quickest
234
234
for getting started but it does not rely on ActivitySim's own lockfile to install deep dependencies so you may
235
235
end up with different versions of deep dependencies than those tested by ActivitySim developers.
236
236
If you want to ensure exact versions of ActivitySim's deep dependencies, you should install ActivitySim using Option 2: From Source with Lockfile.
@@ -247,10 +247,10 @@ instructions can be found `here <https://git-scm.com/downloads>`_.)
Run the `uv sync --locked` command to create a virtual environment using the lockfile. It will initialize a virtual environment within the `activitysim` directory
251
-
and install ActivitySim and all its dependencies exactly as specified in the `uv.lock` file.
250
+
Run the ``uv sync --locked`` command to create a virtual environment using the lockfile. It will initialize a virtual environment within the ``activitysim`` directory
251
+
and install ActivitySim and all its dependencies exactly as specified in the ``uv.lock`` file.
252
252
The virtual environment is a hidden folder within the current directory called
253
-
`.venv` and operates the same way as Python's classic *venv*.
253
+
``.venv`` and operates the same way as Python's classic *venv*.
254
254
255
255
::
256
256
@@ -259,16 +259,16 @@ The virtual environment is a hidden folder within the current directory called
259
259
260
260
It is worth pointing out that by default, *uv* installs projects in
261
261
editable mode, such that changes to the source code are immediately reflected
262
-
in the environment. `uv sync` accepts a `--no-editable`
262
+
in the environment. ``uv sync`` accepts a ``--no-editable``
263
263
flag, which instructs *uv* to install the project in non-editable mode,
264
264
removing any dependency on the source code.
265
265
266
-
Also, `uv sync` automatically installs the dependencies listed in `pyproject.toml`
267
-
under `dependencies` under `[project]`, and it also installs those listed
268
-
under `dev` under `[dependency-groups]`. If you want to
266
+
Also, ``uv sync`` automatically installs the dependencies listed in ``pyproject.toml``
267
+
under ``dependencies`` under ``[project]``, and it also installs those listed
268
+
under ``dev`` under ``[dependency-groups]``. If you want to
269
269
skip the dependency groups entirely with a *uv* install (and only install those
270
-
that would install via `pip` from 'pypi`), use the `--no-default-groups` flag
271
-
with `uv sync`.
270
+
that would install via ``pip`` from ``pypi``), use the ``--no-default-groups`` flag
271
+
with ``uv sync``.
272
272
273
273
274
274
Which Option Should I Use?
@@ -305,7 +305,7 @@ Activate the virtual environment created by *uv*. This option is similar to usin
305
305
# Activate the virtual environment
306
306
.venv\Scripts\activate
307
307
308
-
Once the virtual environment is activated, you can run ActivitySim commands directly using the `activitysim` command.
308
+
Once the virtual environment is activated, you can run ActivitySim commands directly using the ``activitysim`` command.
309
309
For example, run the ActivitySim commandline using the following. More information about the commandline interface is available in
310
310
the :ref:`Ways to Run the Model` section.
311
311
@@ -323,7 +323,7 @@ Common Q&A
323
323
^^^^^^^^^^^^^^^^
324
324
My travel demand model requires additional Python packages not included with ActivitySim. How do I add them?
You can add additional packages to your *uv* project by using the `uv add` command. For example, to add the `geopandas` package,
326
+
You can add additional packages to your *uv* project by using the ``uv add`` command. For example, to add the ``geopandas`` package,
327
327
run the following command within your existing *uv* project directory.
328
328
329
329
::
@@ -334,7 +334,7 @@ run the following command within your existing *uv* project directory.
334
334
# Add geopandas package
335
335
uv add geopandas
336
336
337
-
This will add the package to your virtual environment and update the `pyproject.toml` and the `uv.lock` file to include the new package and its dependencies.
337
+
This will add the package to your virtual environment and update the ``pyproject.toml`` and the ``uv.lock`` file to include the new package and its dependencies.
338
338
339
339
If you envision having a version of Python packages that is different from the one used by ActivitySim, e.g., you need pandas 1.x for visualization (for some reason),
340
340
we recommend creating a separate *uv* project for your custom packages and managing them independently from ActivitySim.
@@ -358,11 +358,23 @@ In such cases, we also recommend creating a separate *uv* project for the commer
358
358
uv init --python 2.7
359
359
# Then copy the emme.pth file (provides EMME API handshakes) from the Emme installation directory to emme_project/.venv/Lib/site-packages/
360
360
361
+
When having multiple *uv* projects, you can switch between them by activating the respective virtual environments.
362
+
363
+
::
364
+
365
+
# Activate visualization project
366
+
# Open Command Prompt
367
+
cd path\to\viz_project
368
+
.venv\Scripts\activate
369
+
370
+
# Deactivate visualization project
371
+
deactivate
372
+
361
373
How to share my working environment with others?
362
374
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
363
-
You can share your working environment with others by sharing the `uv.lock` file and the `pyproject.toml` file located in your project directory.
364
-
The `uv.lock` file contains the exact versions of all packages and dependencies used in your project.
365
-
Others can recreate the same environment by running the `uv sync --locked` command in a new project directory containing the shared files.
375
+
You can share your working environment with others by sharing the ``uv.lock`` file and the ``pyproject.toml`` file located in your project directory (and ``.python-version`` file if it exists).
376
+
The ``uv.lock`` file contains the exact versions of all packages and dependencies used in your project.
377
+
Others can recreate the same environment by running the ``uv sync --locked`` command in a new project directory containing the shared files.
366
378
367
379
::
368
380
@@ -380,19 +392,62 @@ Others can recreate the same environment by running the `uv sync --locked` comma
380
392
# Recreate the same environment
381
393
uv sync --locked
382
394
395
+
Can other users on the same server or machine use my already created virtual environment?
This is doable but it requires additional setup and admin rights - therefore we do not generally recommend it. We recommend following the practice in :ref:`How to share my working environment with others?`.
398
+
399
+
If you'd still like to proceed, here are the recommended steps to follow (proceed with caution!):
400
+
401
+
1. Ensure that you installed UV globally (requires admin rights) on the server/machine for all users. :ref:`Install UV` section above provides instructions on how to do this.
402
+
403
+
2. Assuming you installed UV globally in ``C:\shared\uv\``, ensure that all users have read and execute permissions to this directory.
404
+
405
+
3. Create a directory under ``C:\shared\uv\`` to install Python globally for UV. For example, open Command Prompt, create a directory named ``uv_python`` under ``C:\shared\uv\``.
406
+
407
+
::
408
+
409
+
cd C:\shared\uv\
410
+
mkdir uv_python
411
+
412
+
4. Under Environment Variables > System variables (requires Admin), create a new system environment variable named ``UV_PYTHON_INSTALL_DIR`` and set its value to the Python directory created in step 3 ``C:\shared\uv\uv_python\``.
413
+
414
+
5. Run the following command to install Python globally for UV. This should install Python executables globally in the ``UV_PYTHON_INSTALL_DIR`` directory.
415
+
416
+
::
417
+
418
+
uv python install 3.10
419
+
420
+
6. Under Environment Variables > System variables (requires Admin), create a new system environment variable named ``UV_PYTHON`` and set its value to the ``python.exe`` created in step 5.
421
+
422
+
7. Create a directory to host UV projects under ``C:\shared\uv\``
423
+
424
+
::
425
+
426
+
cd C:\shared\uv\
427
+
mkdir uv_projects
428
+
cd uv_projects
429
+
430
+
8. Create a new *uv* project and install ActivitySim using either :ref:`Option 1: From PyPI` or :ref:`Option 2: From Source with Lockfile` as described above.
431
+
432
+
9. Ensure that all users have read and execute permissions to the shared uv directory.
433
+
434
+
::
435
+
436
+
icacls C:\shared\uv /reset /T
437
+
383
438
If I use the From PyPI option to install ActivitySim, would I run into dependency issues?
Using the :ref:`Option 1: From PyPI` option to install ActivitySim may result in different versions of deep dependencies than those tested by ActivitySim developers.
386
-
This is because the :ref:`Option 1: From PyPI` option installs only the direct dependencies listed in ActivitySim's `pyproject.toml` file,
441
+
This is because the :ref:`Option 1: From PyPI` option installs only the direct dependencies listed in ActivitySim's ``pyproject.toml`` file,
387
442
and relies on *uv* to resolve and install the deep dependencies. It is likely that a newer version of ActivitySim deep dependencies
388
-
may cause compatibility issues. For example, see this recent update with `numexpr`: https://github.com/pydata/numexpr/issues/540
443
+
may cause compatibility issues. For example, see this recent update with ``numexpr``: https://github.com/pydata/numexpr/issues/540
389
444
390
445
When that happens, we recommend using the :ref:`Option 2: From Source with Lockfile` option to install ActivitySim, which ensures that
391
446
you are using the exact same deep dependencies as those tested by ActivitySim developers. In the meantime, you can also
392
447
report the compatibility issues to the ActivitySim development team via GitHub Issues, so that they can address them in future releases.
393
448
394
-
If I want to use `uv run` to run ActivitySim commands, do I still need to activate the virtual environment?
449
+
If I want to use ``uv run`` to run ActivitySim commands, do I still need to activate the virtual environment?
0 commit comments