Issue8772
Created on 2010-05-20 00:37 by srid, last changed 2010-11-26 02:08 by eric.araujo.
| Messages (8) | |||
|---|---|---|---|
| msg106122 - (view) | Author: Sridhar Ratnakumar (srid) | Date: 2010-05-20 00:37 | |
Currently there is no way to get the default scheme for *current* platform other than plainly *assuming* that that is os.name unless it is posix, in which case it becomes posix_prefix. PyPM needs to know this. But I am slightly reluctant to hardcode it. I would rather use the _get_default_scheme() .. but only if it is known to be maintained for backward compat. Thoughts? |
|||
| msg106123 - (view) | Author: Sridhar Ratnakumar (srid) | Date: 2010-05-20 00:49 | |
Ideally I like to have a function like this:
def get_current_scheme(usersite=False):
scheme = os.name
if usersite:
scheme += '_user'
elif scheme == 'posix':
scheme = 'posix_prefix'
This would make it very easy to find the scheme for current Python installation - be it the global site-packages, or virtualenv or user site directory.
Though, generally it can take into consideration other "sub schemes" as well - prefix, home and user:
def get_current_scheme(subscheme=oneof('default', 'home', 'user')):
|
|||
| msg106136 - (view) | Author: Tarek Ziadé (tarek) * ![]() |
Date: 2010-05-20 09:45 | |
Its a good idea to have that API.
Now for the subscheme,
def get_current_scheme(subscheme=oneof('default', 'home', 'user')):
This doesn't work because the installed Python has already chosen a scheme between default or home.
So I'd rather have two APIs answering to that:
- get_current_scheme() : what's the default scheme for this python installation ?
- get_current_user_scheme() : what's the default user scheme for his python installation
Next, if you want to browse the various available schemes for the platform, we could change "get_scheme_names()" and add a new parameter, saying that we want only the scheme for the current OS:
get_scheme_names(current_platform=False)
(removing 2.7 as a target -- it's too late)
|
|||
| msg106161 - (view) | Author: Sridhar Ratnakumar (srid) | Date: 2010-05-20 16:07 | |
On 2010-05-20, at 2:45 AM, Tarek Ziadé wrote: > So I'd rather have two APIs answering to that: > > - get_current_scheme() : what's the default scheme for this python installation ? > - get_current_user_scheme() : what's the default user scheme for his python installation +1 > Next, if you want to browse the various available schemes for the platform, we could change "get_scheme_names()" and add a new parameter, saying that we want only the scheme for the current OS: > > get_scheme_names(current_platform=False) +1 as well. Perhaps `get_scheme_names(all=True)`? This seems like it can be done for 2.7, if found to be worthy of implementation. |
|||
| msg106163 - (view) | Author: Sridhar Ratnakumar (srid) | Date: 2010-05-20 16:23 | |
> removing 2.7 as a target -- it's too late
If contribute a patch to `get_current_scheme` and `get_current_user_scheme`, will be accepted as part of 2.7?
Roughly I would do something like this:
scheme = os.name
if usersite: # get_current_user_scheme
if sys.platform == 'darwin':
scheme = 'osx_framework_user'
else:
scheme += '_user'
elif scheme == 'posix':
scheme = 'posix_prefix'
return scheme
|
|||
| msg106165 - (view) | Author: Sridhar Ratnakumar (srid) | Date: 2010-05-20 16:26 | |
Here it is:
def get_current_scheme():
scheme = os.name
if scheme == 'posix':
scheme = 'posix_prefix'
return scheme
def get_current_user_scheme():
scheme = os.name
if sys.platform == 'darwin':
scheme = 'osx_framework_user'
else:
scheme += '_user'
return scheme
What do you think?
|
|||
| msg106182 - (view) | Author: Tarek Ziadé (tarek) * ![]() |
Date: 2010-05-20 19:02 | |
No sorry, no API change for 2.7 at this point. We are in beta stage. Now for the implementation, it's going to be a little more complex. We need to look at variables like PYTHONFRAMEWORK for instance. |
|||
| msg115752 - (view) | Author: Éric Araujo (eric.araujo) * ![]() |
Date: 2010-09-07 12:51 | |
I wonder if the scheme names could be made more consistent, removing the need for a function. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2010-11-26 02:08:01 | eric.araujo | set | nosy:
tarek, eric.araujo, srid components: + Library (Lib), - Distutils |
| 2010-09-07 12:51:50 | eric.araujo | set | messages: + msg115752 |
| 2010-08-21 20:22:28 | eric.araujo | set | nosy:
+ eric.araujo |
| 2010-05-20 19:02:06 | tarek | set | messages: + msg106182 |
| 2010-05-20 16:26:42 | srid | set | messages: + msg106165 |
| 2010-05-20 16:23:38 | srid | set | messages: + msg106163 |
| 2010-05-20 16:07:51 | srid | set | messages: + msg106161 |
| 2010-05-20 09:45:09 | tarek | set | messages:
+ msg106136 versions: - Python 2.7 |
| 2010-05-20 00:49:01 | srid | set | messages: + msg106123 |
| 2010-05-20 00:37:09 | srid | create | |
