-
Notifications
You must be signed in to change notification settings - Fork 38
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
docs: add documentation about virtual environment and requirements.txt #122
base: main
Are you sure you want to change the base?
Conversation
jklare
commented
Apr 6, 2023
- to allow easier installation and establishment of a stable environment, while tracking the required ansible version and additional dependencies (like netaddr), it is useful to have a requirements.txt with all currently working python dependencies in the root of the repository
- add documentation on how to use the new requirements.txt to install a python3 venv with all current dependencies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, adding virtual environments for this is a great step towards portability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor comments
```bash | ||
python3 -m venv maas-ansible-venv | ||
source maas-ansible-venv/bin/activate | ||
pip install -r requirements.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest python3 -m pip install [stuff]
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by [stuff]
? The idea behind this command ist to showcase how to install the full python environment from the requirements.txt file included in this repository.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replacing pip install
with python3 -m pip install
is what I was suggesting, to avoid issues with multiple pythons/pips/other mess that occasionally occurs on people's systems. Leaving the rest of the line as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, i like the idea to avoid any mess ups on peoples systems :)
I am not sure however if the additional python3 -m pip install
is needed here, since the path of pip
should be explicitly defined after sourcing (activating) the virtual environment. Are there a specific example where you have seen this fail or to cause issues?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not specifically in venv (not something I use often)- however using python3 -m pip install
syntax is both consistent with use of pip outside of venv and consistent with the docs if I'm not mistaken- hence I prefer it over pip install
@@ -0,0 +1,12 @@ | |||
ansible==7.4.0 | |||
ansible-core==2.14.4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe requiring ansible-core separately is unnecessary, as it's already included in and installed with the current version of ansible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The requirements.txt was auto generated by running pip freeze
after installing the latest available ansible version. There are other ways to generate the requirements.txt (including manual or template based ones (e.g. https://github.com/jazzband/pip-tools)), but i think to get started here it is the easiest to just go with a currently stable environment including all python dependencies.
* to allow easier installation and establishment of a stable environment, while tracking the required ansible version and additional dependencies (like netaddr), it is useful to have a requirements.txt with all currently working python dependencies in the root of the repository * add documentation on how to use the new requirements.txt to install a python3 venv with all current dependencies Signed-off-by: Jan Klare <jan.klare@bisdn.de>
* when using Mac OS, you need to additionally install the python module passlib to not run into the error: ``` crypt.crypt not supported on Mac OS X/Darwin, install passlib python module. ``` * add passlib as dependency to requirements.txt Signed-off-by: Jan Klare <jan.klare@bisdn.de>