Skip to content
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

Use a Python virtual env (venv) of a parent folder? #2424

Closed
andrejpk opened this issue Feb 4, 2021 · 4 comments
Closed

Use a Python virtual env (venv) of a parent folder? #2424

andrejpk opened this issue Feb 4, 2021 · 4 comments

Comments

@andrejpk
Copy link

andrejpk commented Feb 4, 2021

I'd like to use a slightly different structure than the standard Python folder structure for functions.

 <project_root>/
| - .venv/
| - .vscode/
| - src/ 
| | - my_first_function/
| | | - __init__.py
| | | - function.json
| | | - example.py
| | - my_second_function/
| | | - __init__.py
| | | - function.json
| | - shared_code/
| | | - __init__.py
| | | - my_first_helper_function.py
| | | - my_second_helper_function.py
| | - .funcignore
| | - host.json
| | - local.settings.json
| | - requirements.txt
| - tests/
| | - test_my_second_function.py
| - Dockerfile

The difference here is that the functions code is in a /src folder, a folder deeper than the .venv. This works fine except in VSCode when I'm testing, func host start doesn't find the .venv because it's in the parent folder. It works in a command prompt when I start the virtual env manually then enter src/ and run func host start.

I want to keep tests separate so they don't ship with my production code and the structure mirrors the layout we'd like to use elsewhere in our Monorepo.

Is there either a way when running func host start to specify a path for my virtual env or the root path of my function app?

@apawast
Copy link

apawast commented Feb 9, 2021

@ejizba could please help with this?

@ejizba
Copy link
Contributor

ejizba commented Feb 9, 2021

@andrejpk I think you can get it to work if you set azureFunctions.pythonVenv to ../.venv in your .vscode/settings.json file. Here's a sample project that might be helpful: https://github.com/anthonychu/functions-python-durable-image-classifier

We also have a few issues tracking general python folder structure improvments:
microsoft/vscode-azurefunctions#1970
microsoft/vscode-azurefunctions#2041

@andrejpk
Copy link
Author

I'll try it out, thanks!

@ghost
Copy link

ghost commented Feb 15, 2021

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@ghost ghost closed this as completed Feb 18, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Mar 20, 2021
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants