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

Android compatibility #843

Closed
wants to merge 1 commit into from
Closed

Conversation

Rudloff
Copy link

@Rudloff Rudloff commented Jun 22, 2016

Hello,

Here is a patch that allows psutil to build on Android (with Termux).
However it does not passes all the tests.

ifaddrs.h does not exist on Android, so I included it from here: https://github.com/morristech/android-ifaddrs

@@ -77,6 +77,8 @@ def write(self, s):
if platform.release() == '5.10':
posix_extension.sources.append('psutil/arch/solaris/v10/ifaddrs.c')
posix_extension.define_macros.append(('PSUTIL_SUNOS10', 1))
if 'ANDROID_ROOT' in os.environ:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish there was a cleaner way but sys.platform returns linux on Android.

@giampaolo
Copy link
Owner

This is very interesting. Some comments:

  • did you try to run tests? Do they all pass?
  • how does this differ from net_if_addrs() on Linux?
  • the C code needs some styling adjustments such as lines max 80 chars and:
if condition {
}

instead of

if condition
{
}

@Rudloff
Copy link
Author

Rudloff commented Jun 23, 2016

{'wlan0': [snic(family=<AddressFamily.AF_INET: 2>, address='10.0.242.196', netmask='255.255.255.0', broadcast='10.0.242.255', ptp=None), snic(family=<AddressFamily.AF_INET6: 10>, address='2a00:5881:8118:500:e151:2cc9:8a84:a418', netmask='ffff:ffff:ffff:ffff::', broadcast=None, ptp=None), snic(family=<AddressFamily.AF_INET6: 10>, address='2a00:5881:8118:500:86cf:bfff:fe89:4f06', netmask='ffff:ffff:ffff:ffff::', broadcast=None, ptp=None), snic(family=<AddressFamily.AF_INET6: 10>, address='fe80::86cf:bfff:fe89:4f06%wlan0', netmask='ffff:ffff:ffff:ffff::', broadcast=None, ptp=None), snic(family=<AddressFamily.AF_PACKET: 17>, address='84:cf:bf:89:4f:06', netmask=None, broadcast='ff:ff:ff:ff:ff:ff', ptp=None)], 'dummy0': [snic(family=<AddressFamily.AF_PACKET: 17>, address='2e:42:bf:cb:c8:9d', netmask=None, broadcast='ff:ff:ff:ff:ff:ff', ptp=None)], 'sit0': [snic(family=<AddressFamily.AF_PACKET: 17>, address='00:00:00:00:00:00', netmask=None, broadcast=None, ptp=None)], 'rmnet_usb0': [snic(family=<AddressFamily.AF_PACKET: 17>, address='be:ae:92:8b:0b:a4', netmask=None, broadcast='ff:ff:ff:ff:ff:ff', ptp=None)], 'rev_rmnet1': [snic(family=<AddressFamily.AF_PACKET: 17>, address='16:18:0e:93:01:62', netmask=None, broadcast='ff:ff:ff:ff:ff:ff', ptp=None)], 'rev_rmnet0': [snic(family=<AddressFamily.AF_PACKET: 17>, address='86:37:6b:10:9b:02', netmask=None, broadcast='ff:ff:ff:ff:ff:ff', ptp=None)], 'rev_rmnet3': [snic(family=<AddressFamily.AF_PACKET: 17>, address='62:7b:e4:87:c0:6e', netmask=None, broadcast='ff:ff:ff:ff:ff:ff', ptp=None)], 'rev_rmnet2': [snic(family=<AddressFamily.AF_PACKET: 17>, address='ce:6a:7d:43:20:ee', netmask=None, broadcast='ff:ff:ff:ff:ff:ff', ptp=None)], 'rev_rmnet5': [snic(family=<AddressFamily.AF_PACKET: 17>, address='ca:c6:29:23:8b:c8', netmask=None, broadcast='ff:ff:ff:ff:ff:ff', ptp=None)], 'rev_rmnet4': [snic(family=<AddressFamily.AF_PACKET: 17>, address='c2:71:78:ca:b1:00', netmask=None, broadcast='ff:ff:ff:ff:ff:ff', ptp=None)], 'rev_rmnet7': [snic(family=<AddressFamily.AF_PACKET: 17>, address='8a:47:b4:c3:8a:d6', netmask=None, broadcast='ff:ff:ff:ff:ff:ff', ptp=None)], 'rev_rmnet6': [snic(family=<AddressFamily.AF_PACKET: 17>, address='ee:1a:4c:b4:ac:4d', netmask=None, broadcast='ff:ff:ff:ff:ff:ff', ptp=None)], 'rev_rmnet8': [snic(family=<AddressFamily.AF_PACKET: 17>, address='36:af:31:bb:95:5c', netmask=None, broadcast='ff:ff:ff:ff:ff:ff', ptp=None)], 'lo': [snic(family=<AddressFamily.AF_INET: 2>, address='127.0.0.1', netmask='255.0.0.0', broadcast=None, ptp=None), snic(family=<AddressFamily.AF_INET6: 10>, address='::1%2181038467', netmask='ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff%25368064', broadcast=None, ptp=None), snic(family=<AddressFamily.AF_PACKET: 17>, address='00:00:00:00:00:00', netmask=None, broadcast=None, ptp=None)], 'p2p0': [snic(family=<AddressFamily.AF_PACKET: 17>, address='86:cf:bf:89:4f:06', netmask=None, broadcast='ff:ff:ff:ff:ff:ff', ptp=None)]}
  • I have updated the code structures and cut some long lines, but like I said this is not my code and I'm not really familiar with C coding standards. Is there some kind of linter I could use to check the code?

@giampaolo giampaolo mentioned this pull request Sep 22, 2016
@giampaolo giampaolo mentioned this pull request Oct 9, 2016
@giampaolo
Copy link
Owner

So, getting back to this. I bumped into:
https://github.com/driftyco/ionic-box
...which AFAIU it lets you run Android on VirtualBox / Vagrant.
I installed and run this on Linux and psutil works just fine out of the box as this (ionic box) basically looks like a Linux Ubuntu distro, so I'm not entirely sure what I'm doing here.
Is this Android in the first place? If this is then it looks like your PR is not necessary.
What am I missing here?

@Rudloff
Copy link
Author

Rudloff commented Apr 6, 2017

Ionic Box is not and Android image. It is a Linux image that helps you build Android apps easily.
However thanks to termux/termux-packages#338 being fixed, some parts of my patch are not needed anymore. I will try to update it.

@giampaolo
Copy link
Owner

OK, as I thought I clearly lack some important pieces of this whole android picture. Can you perhaps tell me what I should do in order to set up an Android image so that I can experiment with this?
I'm on Linux btw.

@Rudloff
Copy link
Author

Rudloff commented Apr 6, 2017

It seems that my patch is not needed at all anymore, which is great news, so I'm closing this issue.

AFAIK the easiest way to run Android on Linux is to use the official emulator.

@Rudloff Rudloff closed this Apr 6, 2017
@Rudloff Rudloff deleted the feature/android branch April 6, 2017 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants