Skip to content

Commit 140ea62

Browse files
committed
Move create_venv.py to script folder and make it more robust.
1 parent 7b2be88 commit 140ea62

5 files changed

Lines changed: 12 additions & 9 deletions

File tree

check_quality.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ setlocal enabledelayedexpansion
33

44
cd %~dp0
55

6-
python create_venv.py --extra_requirements "development"
6+
py script/create_venv.py --extra_requirements "development"
77
if not !ERRORLEVEL! == 0 echo "Something went wrong creating the venv." && exit /b !ERRORLEVEL!
88

99
call .\venv\Scripts\activate.bat

create_docs.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ setlocal enabledelayedexpansion
33

44
cd %~dp0
55

6-
python create_venv.py --extra_requirements "docs"
6+
py script/create_venv.py --extra_requirements "docs"
77
if not !ERRORLEVEL! == 0 echo "Something went wrong creating the venv." && exit /b !ERRORLEVEL!
88

99
call .\venv\Scripts\activate.bat

doc/contributing.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ After implementing (with tests and documentation) create a PR on Github and let
1010

1111
Virtual Environment
1212
-------------------
13-
Create a virtual environment by double-clicking ``create_venv.py`` or by running the following command.
14-
This will install all ``development``, ``test`` and ``doc`` dependencies from ``pyproject.toml``, install
13+
Create a virtual environment by double-clicking ``script/create_venv.py`` or by running the following command.
14+
This will install all ``development``, ``test`` and ``docs`` dependencies from ``pyproject.toml``, install
1515
*DFetch* as `editable package <https://pip.pypa.io/en/stable/cli/pip_wheel/?highlight=editable#cmdoption-e>`_
1616
and install all runtime dependencies from ``pyproject.toml``.
1717

1818
.. code-block:: bash
1919
20-
python create_venv.py
20+
script/create_venv.py
2121
2222
.. important :: *dfetch* is primarily developed with python 3.12
2323

create_venv.py renamed to script/create_venv.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
#!python3.12
1+
#!/usr/bin/env python3.12
22
"""Script to setup a venv."""
33

44
import argparse
5+
import pathlib
56
import subprocess # nosec
67
import venv
78
from typing import Any
@@ -54,12 +55,14 @@ def pip_install(context: Any, *args: Any) -> None:
5455
if __name__ == "__main__":
5556
PARSER = argparse.ArgumentParser()
5657
PARSER.add_argument(
57-
"-e", "--extra_requirements", type=str, default="development,test,doc"
58+
"-e", "--extra_requirements", type=str, default="development,test,docs"
5859
)
5960
ARGS = PARSER.parse_args()
6061

62+
project_root = pathlib.Path(__file__).resolve().parent.parent
63+
6164
MyEnvBuilder(
6265
clear=False,
6366
with_pip=True,
6467
extra_requirements=ARGS.extra_requirements,
65-
).create("venv")
68+
).create(str(project_root / "venv"))

tests/run_tests.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ setlocal enabledelayedexpansion
33

44
cd %~dp0..
55

6-
python create_venv.py --extra_requirements "test"
6+
py script/create_venv.py --extra_requirements "test"
77
if not !ERRORLEVEL! == 0 echo "Something went wrong creating the venv." && exit /b !ERRORLEVEL!
88

99
call .\venv\Scripts\activate.bat

0 commit comments

Comments
 (0)