-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Update docs for os.platform() to enumerate the return values and conditions #25769
Comments
I kind of memorised it long ago but yes i agree it should be documented 👍 |
PR? :-) |
@jasnell If you're asking me why I haven't submitted a PR, the answer is: I don't have the information. As I suggest in the ticket, in order for the documentation to be useful it has to be completely accurate. I don't have the skills necessary to maintain the nodejs apps, let alone on the various platforms, and therefore I don't have the skills necessary to enumerate the possible values or discern what are the conditions under which each will be returned. You'll have to find someone else to do the work. |
|
I will update the ticket with accurate information if @joshgav and others post their findings in these comments. |
_Note_ from
/cc @tomprogers |
@hertzg Thanks! Is solaris the only exception to the "*nix == |
I've updated my comment @tomprogers The default value for |
So Only question remaining is where gyp gets the OS value from and if there are potential values other than At the very least our docs could match gyp's and say "Common values for platform() are darwin, win32, sunos, and linux." |
Digging deeper showed some more information
def GetFlavor(params):
"""Returns |params.flavor| if it's set, the system's default flavor else."""
flavors = {
'cygwin': 'win',
'win32': 'win',
'darwin': 'mac',
}
if 'flavor' in params:
return params['flavor']
if sys.platform in flavors:
return flavors[sys.platform]
if sys.platform.startswith('sunos'):
return 'solaris'
if sys.platform.startswith('freebsd'):
return 'freebsd'
if sys.platform.startswith('openbsd'):
return 'openbsd'
if sys.platform.startswith('aix'):
return 'aix'
return 'linux' Pythons documentation of To sum it all up
/cc @jasnell _UPDATE_: parser.add_option('--dest-os',
action='store',
dest='dest_os',
help='operating system to build for. Valid values are: '
'win, mac, solaris, freebsd, openbsd, linux, android')
# ....
def configure_node(o):
if options.dest_os == 'android':
o['variables']['OS'] = 'android'
# ....
# determine the "flavor" (operating system) we're building for,
# leveraging gyp's GetFlavor function
flavor_params = {}
if (options.dest_os):
flavor_params['flavor'] = options.dest_os
flavor = GetFlavor(flavor_params) |
@hertzg ... excellent detail and very helpful. /cc @misterdjules |
The entry for
os.arch()
lists all the possible return values, and it's clear under what conditions each applies.Please do the same thing for
os.platform()
. It's not convenient to execute an exploratoryconsole.log(os.platform())
on each OS a developer wishes to support.Perhaps something like this is appropriate (note: data invented for illustration purposes -- this list is a wild guess!):
"win32"
"win32"
[sic]"win32"
[sic]"darwin"
"linux"
Even a more general enumeration would be very helpful, if it's completely accurate (again, I don't know if any of the details are true):
I think there is interest in this information. See e.g. this Stack Overflow question, and note how many upvotes comments have received for providing just one of the needed datapoints.
I think it's reasonable for the project to maintain documentation for these values, assuming the project also maintains the nodejs implementation of
os.platform()
on each of the platforms.The text was updated successfully, but these errors were encountered: