@@ -21,54 +21,48 @@ def download_template_project(template_url: str, destination: str) -> None:
2121 :param template_url: The URL of the template project.
2222 :param destination: The directory where the project will be created.
2323 """
24- response = requests .get (template_url , stream = True )
24+ response : requests . Response = requests .get (template_url , stream = True )
2525
2626 if response .status_code == 200 :
2727 with zipfile .ZipFile (io .BytesIO (response .content )) as z :
2828 z .extractall (destination )
2929
3030
31- def create_android_project (project_name : str , destination : str ) -> bool :
31+ def create_android_project (project_name : str , destination : str ) -> None :
3232 """
3333 Create a new Android project using a template.
3434
3535 :param project_name: The name of the project.
3636 :param destination: The directory where the project will be created.
37- :return: True if the project was created successfully, False otherwise.
3837 """
39- android_template_url = "https://github.com/owenthcarey/pythonnative-workspace/blob/main/apps /templates/android_template.zip?raw=true"
38+ android_template_url = "https://github.com/owenthcarey/pythonnative-workspace/blob/main/libs /templates/android_template.zip?raw=true"
4039
4140 # Download and extract the Android template project
4241 download_template_project (android_template_url , destination )
4342
44- return True
4543
46-
47- def create_ios_project (project_name : str , destination : str ) -> bool :
44+ def create_ios_project (project_name : str , destination : str ) -> None :
4845 """
4946 Create a new iOS project using a template.
5047
5148 :param project_name: The name of the project.
5249 :param destination: The directory where the project will be created.
53- :return: True if the project was created successfully, False otherwise.
5450 """
55- ios_template_url = "https://github.com/owenthcarey/pythonnative-workspace/blob/main/apps /templates/ios_template.zip?raw=true"
51+ ios_template_url = "https://github.com/owenthcarey/pythonnative-workspace/blob/main/libs /templates/ios_template.zip?raw=true"
5652
5753 # Download and extract the iOS template project
5854 download_template_project (ios_template_url , destination )
5955
60- return True
61-
6256
6357def run_project (args : argparse .Namespace ) -> None :
6458 """
6559 Run the specified project.
6660 """
6761 # Determine the platform
68- platform = args .platform
62+ platform : str = args .platform
6963
7064 # Define the build directory
71- build_dir = os .path .join (os .getcwd (), "build" , platform )
65+ build_dir : str = os .path .join (os .getcwd (), "build" , platform )
7266
7367 # Create the build directory if it doesn't exist
7468 os .makedirs (build_dir , exist_ok = True )
@@ -80,54 +74,66 @@ def run_project(args: argparse.Namespace) -> None:
8074 create_ios_project ("MyApp" , build_dir )
8175
8276 # Copy the user's Python code into the project
83- src_dir = os .path .join (os .getcwd (), "app" )
77+ src_dir : str = os .path .join (os .getcwd (), "app" )
8478
8579 # Adjust the destination directory for Android project
8680 if platform == "android" :
87- dest_dir = os .path .join (build_dir , "android_template" , "app" , "src" , "main" , "python" , "app" )
81+ dest_dir : str = os .path .join (
82+ build_dir , "android_template" , "app" , "src" , "main" , "python" , "app"
83+ )
8884 elif platform == "ios" :
89- dest_dir = os .path .join (build_dir , "app" ) # Adjust this based on your iOS project structure
85+ dest_dir : str = os .path .join (
86+ build_dir , "app"
87+ ) # Adjust this based on your iOS project structure
9088
9189 # Create the destination directory if it doesn't exist
9290 os .makedirs (dest_dir , exist_ok = True )
9391 shutil .copytree (src_dir , dest_dir , dirs_exist_ok = True )
9492
9593 # Install any necessary Python packages into the project environment
96- requirements_file = os .path .join (os .getcwd (), "requirements.txt" )
94+ requirements_file : str = os .path .join (os .getcwd (), "requirements.txt" )
9795 # TODO: Fill in with actual commands for installing Python packages
9896
9997 # Run the project
10098 if platform == "android" :
10199 # Change to the Android project directory
102- android_project_dir = os .path .join (build_dir , "android_template" )
100+ android_project_dir : str = os .path .join (build_dir , "android_template" )
103101 os .chdir (android_project_dir )
104102
105103 # Add executable permissions to the gradlew script
106- gradlew_path = os .path .join (android_project_dir , "gradlew" )
107- os .chmod (gradlew_path ,
108- 0o755 ) # this makes the file executable for the user
104+ gradlew_path : str = os .path .join (android_project_dir , "gradlew" )
105+ os .chmod (gradlew_path , 0o755 ) # this makes the file executable for the user
109106
110107 # Build the Android project and install it on the device
111- jdk_path = subprocess .check_output (
112- ["brew" , "--prefix" , "openjdk@17" ]).decode ().strip ()
113- env = os .environ .copy ()
108+ jdk_path : str = (
109+ subprocess .check_output (["brew" , "--prefix" , "openjdk@17" ]).decode ().strip ()
110+ )
111+ env : dict [str , str ] = os .environ .copy ()
114112 env ["JAVA_HOME" ] = jdk_path
115113 subprocess .run (["./gradlew" , "installDebug" ], check = True , env = env )
116114
117115 # Run the Android app
118116 # Assumes that the package name of your app is "com.example.myapp" and the main activity is "MainActivity"
119117 # Replace "com.example.myapp" and ".MainActivity" with your actual package name and main activity
120- subprocess .run (["adb" , "shell" , "am" , "start" , "-n" ,
121- "com.pythonnative.android_template/.MainActivity" ],
122- check = True )
118+ subprocess .run (
119+ [
120+ "adb" ,
121+ "shell" ,
122+ "am" ,
123+ "start" ,
124+ "-n" ,
125+ "com.pythonnative.android_template/.MainActivity" ,
126+ ],
127+ check = True ,
128+ )
123129
124130
125131def clean_project (args : argparse .Namespace ) -> None :
126132 """
127133 Clean the specified project.
128134 """
129135 # Define the build directory
130- build_dir = os .path .join (os .getcwd (), "build" )
136+ build_dir : str = os .path .join (os .getcwd (), "build" )
131137
132138 # Check if the build directory exists
133139 if os .path .exists (build_dir ):
0 commit comments