Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d41903b
commit 634f982
Showing
746 changed files
with
456,413 additions
and
0 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,10 @@ | ||
|
||
.DS_Store | ||
|
||
*.xcuserstate | ||
|
||
python-ios.xcworkspace/xcuserdata/fancyzero.xcuserdatad/UserInterfaceState.xcuserstate | ||
|
||
*.xcbkptlist | ||
|
||
python-ios.xcworkspace/xcuserdata/fancyzero.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist |
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,19 @@ | ||
Goto Python-2.7.5, and "./configure" this will config for mac OSX plaform, but still can make next of your steps easier. | ||
|
||
Create a static library project, then add all python file into project with directory structure. | ||
|
||
while( build_not_successed ) | ||
{ | ||
Try to build it, and you will found some source file are not for iOS platform, remove these files, and some other files | ||
failed to compile because missing other 3rd party libs, remove it from the project , or provide the libs. | ||
} | ||
|
||
you will get a python interpet with some useful builtin modules. | ||
|
||
manually edit the Modules/config.c to register built-in modules, you see how, when you open the config.c it's easy to understand | ||
module "zlib" must be registered in order to import for a zip file. | ||
|
||
and in python/libs/site.py there comment line "known_paths = addusersitepackages(known_paths)" , that depends a module called "_sysconfigdata", this module is generated when you make python in commandline, so this funciton call should be disabled | ||
|
||
that's all I remember... | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
Python-iOS/Python-iOS-app.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,19 @@ | ||
// | ||
// AppDelegate.h | ||
// Python-iOS-app | ||
// | ||
// Created by Fancyzero on 13-8-21. | ||
// Copyright (c) 2013年 Fancyzero. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@class ViewController; | ||
|
||
@interface AppDelegate : UIResponder <UIApplicationDelegate> | ||
|
||
@property (strong, nonatomic) UIWindow *window; | ||
|
||
@property (strong, nonatomic) ViewController *viewController; | ||
|
||
@end |
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,87 @@ | ||
// | ||
// AppDelegate.m | ||
// Python-iOS-app | ||
// | ||
// Created by Fancyzero on 13-8-21. | ||
// Copyright (c) 2013年 Fancyzero. All rights reserved. | ||
// | ||
|
||
#import "AppDelegate.h" | ||
|
||
#import "ViewController.h" | ||
#include "Python.h" | ||
|
||
@implementation AppDelegate | ||
|
||
- (void)dealloc | ||
{ | ||
[_window release]; | ||
[_viewController release]; | ||
[super dealloc]; | ||
} | ||
|
||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | ||
{ | ||
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; | ||
// Override point for customization after application launch. | ||
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { | ||
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil] autorelease]; | ||
} else { | ||
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil] autorelease]; | ||
} | ||
self.window.rootViewController = self.viewController; | ||
[self.window makeKeyAndVisible]; | ||
|
||
//init python | ||
//get python lib path and set this path as python home directory | ||
NSString* fullpath = [[NSBundle mainBundle] pathForResource:@"python" ofType:nil inDirectory:nil]; | ||
char home[1024]; | ||
strcpy(home, [fullpath UTF8String]); | ||
|
||
Py_SetPythonHome(home); | ||
Py_Initialize(); | ||
//执行python语句 | ||
PyRun_SimpleString("print 'hello'");//say hello see debug output :) | ||
|
||
dispatch_queue_t queue = dispatch_queue_create(0, DISPATCH_QUEUE_CONCURRENT); | ||
dispatch_async(queue, ^{ | ||
//执行python脚本 | ||
NSString *scriptPath = [[NSBundle mainBundle] pathForResource:@"server" ofType:@"py"]; | ||
|
||
FILE *mainFile = fopen([scriptPath UTF8String], "r"); | ||
|
||
PyRun_SimpleFile(mainFile, (char *)[[scriptPath lastPathComponent] UTF8String]) ; | ||
|
||
}); | ||
|
||
return YES; | ||
} | ||
|
||
- (void)applicationWillResignActive:(UIApplication *)application | ||
{ | ||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. | ||
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. | ||
} | ||
|
||
- (void)applicationDidEnterBackground:(UIApplication *)application | ||
{ | ||
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. | ||
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. | ||
} | ||
|
||
- (void)applicationWillEnterForeground:(UIApplication *)application | ||
{ | ||
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. | ||
} | ||
|
||
- (void)applicationDidBecomeActive:(UIApplication *)application | ||
{ | ||
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. | ||
} | ||
|
||
- (void)applicationWillTerminate:(UIApplication *)application | ||
{ | ||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. | ||
} | ||
|
||
@end |
Oops, something went wrong.