11import argparse
2+ import io
23import os
34import shutil
45import subprocess
5- import requests
66import zipfile
7- import io
7+
8+ import requests
89
910
1011def init_project (args : argparse .Namespace ) -> None :
@@ -35,7 +36,9 @@ def create_android_project(project_name: str, destination: str) -> None:
3536 :param project_name: The name of the project.
3637 :param destination: The directory where the project will be created.
3738 """
38- android_template_url = "https://github.com/owenthcarey/pythonnative-workspace/blob/main/libs/templates/android_template.zip?raw=true"
39+ android_template_url = (
40+ "https://github.com/owenthcarey/pythonnative-workspace/blob/main/libs/templates/android_template.zip?raw=true"
41+ )
3942
4043 # Download and extract the Android template project
4144 download_template_project (android_template_url , destination )
@@ -48,7 +51,9 @@ def create_ios_project(project_name: str, destination: str) -> None:
4851 :param project_name: The name of the project.
4952 :param destination: The directory where the project will be created.
5053 """
51- ios_template_url = "https://github.com/owenthcarey/pythonnative-workspace/blob/main/libs/templates/ios_template.zip?raw=true"
54+ ios_template_url = (
55+ "https://github.com/owenthcarey/pythonnative-workspace/blob/main/libs/templates/ios_template.zip?raw=true"
56+ )
5257
5358 # Download and extract the iOS template project
5459 download_template_project (ios_template_url , destination )
@@ -78,21 +83,18 @@ def run_project(args: argparse.Namespace) -> None:
7883
7984 # Adjust the destination directory for Android project
8085 if platform == "android" :
81- dest_dir : str = os .path .join (
82- build_dir , "android_template" , "app" , "src" , "main" , "python" , "app"
83- )
84- elif platform == "ios" :
85- dest_dir : str = os .path .join (
86- build_dir , "app"
87- ) # Adjust this based on your iOS project structure
86+ dest_dir : str = os .path .join (build_dir , "android_template" , "app" , "src" , "main" , "python" , "app" )
87+ else :
88+ dest_dir = os .path .join (build_dir , "app" ) # Adjust this based on your iOS project structure
8889
8990 # Create the destination directory if it doesn't exist
9091 os .makedirs (dest_dir , exist_ok = True )
9192 shutil .copytree (src_dir , dest_dir , dirs_exist_ok = True )
9293
9394 # Install any necessary Python packages into the project environment
94- requirements_file : str = os .path .join (os .getcwd (), "requirements.txt" )
95- # TODO: Fill in with actual commands for installing Python packages
95+ requirements_path = os .path .join (os .getcwd (), "requirements.txt" )
96+ if os .path .exists (requirements_path ):
97+ subprocess .run (["pip" , "install" , "-r" , requirements_path ], check = False )
9698
9799 # Run the project
98100 if platform == "android" :
@@ -105,9 +107,7 @@ def run_project(args: argparse.Namespace) -> None:
105107 os .chmod (gradlew_path , 0o755 ) # this makes the file executable for the user
106108
107109 # Build the Android project and install it on the device
108- jdk_path : str = (
109- subprocess .check_output (["brew" , "--prefix" , "openjdk@17" ]).decode ().strip ()
110- )
110+ jdk_path : str = subprocess .check_output (["brew" , "--prefix" , "openjdk@17" ]).decode ().strip ()
111111 env : dict [str , str ] = os .environ .copy ()
112112 env ["JAVA_HOME" ] = jdk_path
113113 subprocess .run (["./gradlew" , "installDebug" ], check = True , env = env )
0 commit comments