-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from Never-Over/more-flexible-python-build
Support poetry, Pipenv dependencies
- Loading branch information
Showing
6 changed files
with
93 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# [Generated by Bridge] | ||
import os | ||
import subprocess | ||
|
||
|
||
def install_dependencies(): | ||
# Check for requirements.txt and install using pip | ||
if os.path.exists("requirements.txt"): | ||
print("requirements.txt found. Installing dependencies...") | ||
subprocess.run(["pip", "install", "-r", "requirements.txt"], check=True) | ||
|
||
# Check for Pipfile.lock and install using Pipenv | ||
elif os.path.exists("Pipfile.lock"): | ||
print("Pipfile.lock found. Installing Pipenv and dependencies...") | ||
subprocess.run(["pip", "install", "pipx"], check=True) | ||
subprocess.run(["pipx", "install", "pipenv"], check=True) | ||
subprocess.run(["pipenv", "sync"], check=True) | ||
|
||
# Check for poetry.lock and install using Poetry | ||
elif os.path.exists("poetry.lock"): | ||
print("poetry.lock found. Installing Poetry and dependencies...") | ||
subprocess.run(["pip", "install", "pipx"], check=True) | ||
subprocess.run(["pipx", "install", "poetry"], check=True) | ||
subprocess.run(["poetry", "install"], check=True) | ||
|
||
else: | ||
print( | ||
"No dependency file found." | ||
" Please make sure you have a" | ||
" requirements.txt, Pipfile.lock, or poetry.lock file in the root of your project" | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
install_dependencies() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
tests/django/django_bridge/bridge-django-render/install_deps.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# [Generated by Bridge] | ||
import os | ||
import subprocess | ||
|
||
|
||
def install_dependencies(): | ||
# Check for requirements.txt and install using pip | ||
if os.path.exists("requirements.txt"): | ||
print("requirements.txt found. Installing dependencies...") | ||
subprocess.run(["pip", "install", "-r", "requirements.txt"], check=True) | ||
|
||
# Check for Pipfile.lock and install using Pipenv | ||
elif os.path.exists("Pipfile.lock"): | ||
print("Pipfile.lock found. Installing Pipenv and dependencies...") | ||
subprocess.run(["pip", "install", "pipx"], check=True) | ||
subprocess.run(["pipx", "install", "pipenv"], check=True) | ||
subprocess.run(["pipenv", "sync"], check=True) | ||
|
||
# Check for poetry.lock and install using Poetry | ||
elif os.path.exists("poetry.lock"): | ||
print("poetry.lock found. Installing Poetry and dependencies...") | ||
subprocess.run(["pip", "install", "pipx"], check=True) | ||
subprocess.run(["pipx", "install", "poetry"], check=True) | ||
subprocess.run(["poetry", "install"], check=True) | ||
|
||
else: | ||
print( | ||
"No dependency file found." | ||
"Please ensure your dependency file is in the current directory." | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
install_dependencies() |