• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python site.getuserbase函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中site.getuserbase函数的典型用法代码示例。如果您正苦于以下问题:Python getuserbase函数的具体用法?Python getuserbase怎么用?Python getuserbase使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了getuserbase函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_app_dir

def get_app_dir():
    """Get the configured JupyterLab app directory.
    """
    # Default to the override environment variable.
    if os.environ.get('JUPYTERLAB_DIR'):
        return osp.realpath(os.environ['JUPYTERLAB_DIR'])

    # Use the default locations for data_files.
    app_dir = pjoin(sys.prefix, 'share', 'jupyter', 'lab')

    # Check for a user level install.
    # Ensure that USER_BASE is defined
    if hasattr(site, 'getuserbase'):
        site.getuserbase()
    userbase = getattr(site, 'USER_BASE', None)
    if HERE.startswith(userbase) and not app_dir.startswith(userbase):
        app_dir = pjoin(userbase, 'share', 'jupyter', 'lab')

    # Check for a system install in '/usr/local/share'.
    elif (sys.prefix.startswith('/usr') and not
          osp.exists(app_dir) and
          osp.exists('/usr/local/share/jupyter/lab')):
        app_dir = '/usr/local/share/jupyter/lab'

    return osp.realpath(app_dir)
开发者ID:7125messi,项目名称:jupyterlab,代码行数:25,代码来源:commands.py


示例2: run

 def run(self):
     # Workaround that install_data doesn't respect --prefix
     #
     # If prefix is given (via --user or via --prefix), then
     # extract it and add it to the paths in self.data_files;
     # otherwise, default to /usr/local.
     install = self.distribution.command_options.get('install', {})
     if 'user' in install:
         # this means --user was given
         self.prefix = site.getuserbase()
         sysconfigdir = os.path.join(self.prefix, "etc")
     elif 'prefix' in install:
         # this means --prefix was given
         self.prefix = install.get('prefix', (None, None))[1]
         sysconfigdir = os.path.join(self.prefix, 'etc')
     else:
         self.prefix = 'usr'
         sysconfigdir = '/etc'
     new_data_files = []
     for entry in self.data_files:
         dest_path = entry[0].replace('@[email protected]', self.prefix)
         dest_path = entry[0].replace('@[email protected]', sysconfigdir)
         new_data_files.append((dest_path,) + entry[1:])
     self.data_files = new_data_files
     distutils.command.install_data.install_data.run(self)
开发者ID:intel,项目名称:tcf,代码行数:25,代码来源:setupl.py


示例3: excenturyrc_str

def excenturyrc_str():
    """Create the excenturyrc file contents. """
    userbase = site.getuserbase()
    content = append_variable('PATH', '%s/bin' % sys.prefix)
    content += append_variable('PATH', '%s/bin' % userbase)
    # include
    path = pth.abspath(pth.dirname(__file__)+'/../extern/include')
    content += append_variable('C_INCLUDE_PATH', path)
    content += append_variable('CPLUS_INCLUDE_PATH', path)
    # matlab
    path = pth.abspath(pth.dirname(__file__)+'/../extern/matlab')
    content += append_variable('MATLABPATH', path)
    # excentury/bin
    content += append_variable('PATH',
                               '%s/lib/excentury/bin' % userbase)
    # excentury/lib
    content += append_variable('LD_LIBRARY_PATH',
                               '%s/lib/excentury/lib' % userbase)
    # excentury/matlab
    content += append_variable('MATLABPATH',
                               '%s/lib/excentury/matlab' % userbase)
    # excentury/python
    content += append_variable('PYTHONPATH',
                               '%s/lib/excentury/python' % userbase)
    return content
开发者ID:jmlopez-rod,项目名称:excentury,代码行数:25,代码来源:install.py


示例4: test_create_site_dir

def test_create_site_dir():
    site_utils.create_site_dir("test")
    tdir = os.path.join(site.getuserbase(), "test")
    #print "tdir: %s" % str(tdir)
    assert os.path.exists(tdir)
    site_utils._remove_site_dir("test")
    assert not site_utils.site_dir_exists("test")
开发者ID:CospanDesign,项目名称:python,代码行数:7,代码来源:test_site_utils.py


示例5: test_no_home_directory

    def test_no_home_directory(self):
        # bpo-10496: getuserbase() and getusersitepackages() must not fail if
        # the current user has no home directory (if expanduser() returns the
        # path unchanged).
        site.USER_SITE = None
        site.USER_BASE = None

        with EnvironmentVarGuard() as environ, \
             mock.patch('os.path.expanduser', lambda path: path):

            del environ['PYTHONUSERBASE']
            del environ['APPDATA']

            user_base = site.getuserbase()
            self.assertTrue(user_base.startswith('~' + os.sep),
                            user_base)

            user_site = site.getusersitepackages()
            self.assertTrue(user_site.startswith(user_base), user_site)

        with mock.patch('os.path.isdir', return_value=False) as mock_isdir, \
             mock.patch.object(site, 'addsitedir') as mock_addsitedir, \
             support.swap_attr(site, 'ENABLE_USER_SITE', True):

            # addusersitepackages() must not add user_site to sys.path
            # if it is not an existing directory
            known_paths = set()
            site.addusersitepackages(known_paths)

            mock_isdir.assert_called_once_with(user_site)
            mock_addsitedir.assert_not_called()
            self.assertFalse(known_paths)
开发者ID:Victor-Savu,项目名称:cpython,代码行数:32,代码来源:test_site.py


示例6: test_getuserbase

    def test_getuserbase(self):
        site.USER_BASE = None
        user_base = site.getuserbase()

        # the call sets site.USER_BASE
        self.assertEqual(site.USER_BASE, user_base)

        # let's set PYTHONUSERBASE and see if it uses it
        site.USER_BASE = None
        import sysconfig
        sysconfig._CONFIG_VARS = None

        with EnvironmentVarGuard() as environ:
            environ['PYTHONUSERBASE'] = 'xoxo'
            self.assertTrue(site.getuserbase().startswith('xoxo'),
                            site.getuserbase())
开发者ID:pogigroo,项目名称:py3k-__format__,代码行数:16,代码来源:test_site.py


示例7: test_getusersitepackages

    def test_getusersitepackages(self):
        site.USER_SITE = None
        site.USER_BASE = None
        user_site = site.getusersitepackages()

        # the call sets USER_BASE *and* USER_SITE
        self.assertEqual(site.USER_SITE, user_site)
        self.assertTrue(user_site.startswith(site.USER_BASE), user_site)
        self.assertEqual(site.USER_BASE, site.getuserbase())
开发者ID:Victor-Savu,项目名称:cpython,代码行数:9,代码来源:test_site.py


示例8: find_script

def find_script(name):
    user_base = site.getuserbase()
    script_path = find_subdirectory("bin", user_base)
    if script_path is None:
        script_path = find_subdirectory("Scripts", user_base)
    script_path = os.path.join(script_path, name)
    if os.path.isfile(script_path):
        return script_path
    return None
开发者ID:purvigoel,项目名称:Writing3D,代码行数:9,代码来源:install_w3d.py


示例9: do_get_install_prefix

def do_get_install_prefix():
    #special case for "user" installations, ie:
    #$HOME/.local/lib/python2.7/site-packages/xpra/platform/paths.py
    try:
        base = site.getuserbase()
    except:
        base = site.USER_BASE
    if __file__.startswith(base):
        return base
    return sys.prefix
开发者ID:ljmljz,项目名称:xpra,代码行数:10,代码来源:paths.py


示例10: build_cpp

def build_cpp(name, debug=None):
    """Compile a file and place it in bin. """
    root = site.getuserbase()
    if debug is None:
        out = "-o %s/lib/excentury/bin/%s.run" % (root, name)
    else:
        out = "-DDEBUG=%s -o %s/lib/excentury/bin/%s.run%s" % (debug, root, name, debug)
    root = pth.abspath(pth.dirname(__file__) + "/cpp")
    cmd = "g++ -O3 %s %s/%s.cpp" % (out, root, name)
    out, err, _ = exec_cmd(cmd)
    eq_(err, "", "Build Error -->\n%s\n%s" % (cmd, err))
开发者ID:jmlopez-rod,项目名称:excentury,代码行数:11,代码来源:tests.py


示例11: make_dirs

def make_dirs():
    """Creates standard directories to place binaries and libraries
    created by excentury. """
    root = site.getuserbase()
    make_dir(root+'/lib')
    make_dir(root+'/lib/excentury')
    make_dir(root+'/lib/excentury/bin')
    make_dir(root+'/lib/excentury/lib')
    make_dir(root+'/lib/excentury/cpp')
    make_dir(root+'/lib/excentury/matlab')
    make_dir(root+'/lib/excentury/python')
    make_dir(root+'/lib/excentury/tmp')
开发者ID:jmlopez-rod,项目名称:excentury,代码行数:12,代码来源:install.py


示例12: find_db

 def find_db(self):
     name = "library.sqlite"
     dir = os.path.join(site.getuserbase(), "rayopt")
     main = os.path.join(dir, name)
     if not os.path.exists(main):
         base = resource_filename(Requirement.parse("rayopt"), name)
         if not os.path.exists(base):
             base = os.path.join(os.path.split(__file__)[0], name)
         if not os.path.exists(dir):
             os.makedirs(dir)
         shutil.copy(base, main)
     return main
开发者ID:jordens,项目名称:rayopt,代码行数:12,代码来源:library.py


示例13: get_installation_prefix

def get_installation_prefix():
    "Get installation prefix"
    prefix = sys.prefix
    for arg in sys.argv[1:]:
        if "--user" in arg:
            import site
            prefix = site.getuserbase()
            break
        elif arg in ("--prefix", "--home", "--install-base"):
            prefix = sys.argv[sys.argv.index(arg) + 1]
            break
        elif "--prefix=" in arg or "--home=" in arg or "--install-base=" in arg:
            prefix = arg.split("=")[1]
            break

    return os.path.abspath(os.path.expanduser(prefix))
开发者ID:FEniCS,项目名称:ffc,代码行数:16,代码来源:setup.py


示例14: __get_scripts_directory

def __get_scripts_directory():
    import sys
    import platform
    import site

    """Return directory where W3D scripts have been installed

    :warn: This assumes a default installation with user scheme

    :todo: Add fallbacks for alternate installations"""

    if platform.system() in ("Windows",):
        scripts_dir = os.path.join("Python{}{}".format(*(sys.version_info[:2])), "Scripts")
    else:
        scripts_dir = "bin"
    scripts_dir = os.path.join(site.getuserbase(), scripts_dir)
    return scripts_dir
开发者ID:wphicks,项目名称:Writing3D,代码行数:17,代码来源:__init__.py


示例15: run

def run():
    """Run the command. """
    arg = config.CONFIG['arg']
    if arg.path:
        install_dir = arg.path
    elif arg.user:
        install_dir = '%s/lib/lexor' % site.getuserbase()
    else:
        install_dir = '%s/lib/lexor' % sys.prefix

    style_file = arg.style
    if '.py' not in style_file:
        style_file = '%s.py' % style_file
    if os.path.exists(style_file):
        install_style(style_file, install_dir)
        return

    matches = []
    url = 'http://jmlopez-rod.github.io/lexor-lang/lexor-lang.url'
    print '-> Searching in %s' % url
    response = urllib2.urlopen(url)
    for line in response.readlines():
        name, url = line.split(':', 1)
        if arg.style in name:
            matches.append([name.strip(), url.strip()])

    for match in matches:
        doc = urllib2.urlopen(match[1]).read()
        links = re.finditer(r' href="?([^\s^"]+)', doc)
        links = [link.group(1) for link in links if '.zip' in link.group(1)]
        for link in links:
            if 'master' in link:
                path = urllib2.urlparse.urlsplit(match[1])
                style_url = '%s://%s%s' % (path[0], path[1], link)
                local_name = download_file(style_url, '.')
                dirname = unzip_file(local_name)
                # Assuming there is only one python file
                os.chdir(dirname)
                for path in iglob('*.py'):
                    install_style(path, install_dir)
                os.chdir('..')
                os.remove(local_name)
                shutil.rmtree(dirname)
开发者ID:jmlopez-rod,项目名称:lexor,代码行数:43,代码来源:install.py


示例16: loadlib

def loadlib(**libname):
  '''
  Find and load a dynamic library using :any:`ctypes.CDLL`.  For each
  (supported) platform the name of the library should be specified as a keyword
  argument, including the extension, where the keywords should match the
  possible values of :any:`sys.platform`.  In addition to the default
  directories, this function searches :any:`site.PREFIXES` and
  :func:`site.getuserbase()`.

  Example
  -------

  To load the Intel MKL runtime library, write::

      loadlib(linux='libmkl_rt.so', darwin='libmkl_rt.dylib', win32='mkl_rt.dll')
  '''

  if sys.platform not in libname:
    return
  libname = libname[sys.platform]
  try:
    return ctypes.CDLL(libname)
  except (OSError, KeyError):
    pass
  libsubdir = dict(linux='lib', darwin='lib', win32='Library\\bin')[sys.platform]
  prefixes = list(site.PREFIXES)
  if hasattr(site, 'getuserbase'):
    prefixes.append(site.getuserbase())
  for prefix in prefixes:
    libdir = os.path.join(prefix, libsubdir)
    if not os.path.exists(os.path.join(libdir, libname)):
      continue
    if sys.platform == 'win32' and libdir not in os.environ.get('PATH', '').split(';'):
      # Make sure dependencies of `libname` residing in the same directory are
      # found.
      os.environ['PATH'] = os.environ.get('PATH', '').rstrip(';')+';'+libdir
    try:
      return ctypes.CDLL(os.path.join(libdir, libname))
    except (OSError, KeyError):
      pass
开发者ID:CVerhoosel,项目名称:nutils,代码行数:40,代码来源:util.py


示例17: development_deploy

def development_deploy(paths, dependencies=False, scripts=False, inject_setuptools=False):
    """Python packages deployment in development mode."""
    items = list(paths) if isinstance(paths, (list, tuple, set)) else [paths]

    if items:
        original_path = os.getcwd()
        user_base_path = getuserbase()
        user_sites_path = getusersitepackages()
        user_bin_path = os.path.join(user_base_path, 'bin')

        for path in items:
            os.chdir(os.path.dirname(path))

            # Making arguments
            arguments = [path, 'develop']
            arguments.extend(['--install-dir', user_sites_path])
            arguments.extend(['--script-dir', user_bin_path])
            if not dependencies:
                arguments.append('--no-deps')
            if not scripts:
                arguments.append('--exclude-scripts')

            # Processing
            if not inject_setuptools:
                subprocess.Popen([sys.executable] + arguments).wait()
            else:
                handler = open(path, 'rb')
                content = handler.read()
                handler.close()
                # Adding setuptools import
                content = "import setuptools\n" + content
                # Updating arguments, path and executing
                sys.path.insert(0, '.')
                sys.argv = arguments
                exec(content, {'__file__': path})
                sys.path[:] = sys.path[1:]

        # Go back to original path
        os.chdir(original_path)
开发者ID:minhtuev,项目名称:pydev,代码行数:39,代码来源:pydev.py


示例18:

----------------------------------------------------------------
To enable tab completion, add the following to your '~/.bashrc':

  source {0}

----------------------------------------------------------------
""".format(os.path.join(self.install_data,
                        'etc/bash_completion.d',
                        'catkin_tools-completion.bash')))

parser = argparse.ArgumentParser(add_help=False)
parser.add_argument('--user', '--home', action='store_true')
parser.add_argument('--prefix', default=None)

opts, _ = parser.parse_known_args(sys.argv)
userbase = site.getuserbase() if opts.user else None
prefix = userbase or opts.prefix or sys.prefix

setup(
    name='catkin_tools',
    version='0.4.4',
    packages=find_packages(exclude=['tests*', 'docs']),
    package_data={
        'catkin_tools': [
            'notifications/resources/linux/catkin_icon.png',
            'notifications/resources/linux/catkin_icon_red.png',
            'verbs/catkin_shell_verbs.bash',
            'docs/examples',
        ] + osx_notification_resources
    },
    data_files=get_data_files(prefix),
开发者ID:rhaschke,项目名称:catkin_tools,代码行数:31,代码来源:setup.py


示例19: __init__

 def __init__(self, IS_LOCAL, iconset):
     """
     The paths where the icon sets are located depend on where the program 
     is run and on which operating system.
     Each icons set is defined by the name of the folder that contains it.  
     """
     if IS_LOCAL:
         url = '%s/art/icons' % os.getcwd() # work current directory
         self.videomass_icon = "%s/videomass.png" % url
         self.wizard_icon = "%s/videomass_wizard.png" % url
         
     else:
         import sys
         import platform
         OS = platform.system()
         
         if OS == 'Windows':
             #Installed with 'pip install videomass' cmd
             pythonpath = os.path.dirname(sys.executable)
             url = pythonpath + '\\share\\videomass\\icons'
             self.videomass_icon = url + "\\videomass.png" 
             self.wizard_icon = url + "\\videomass_wizard.png"
         else:
             from videomass2.vdms_SYS.whichcraft import which
             binarypath = which('videomass')
             
             if binarypath == '/usr/local/bin/videomass':
                 #usually Linux,MacOs,Unix
                 url = '/usr/local/share/videomass/icons'
                 share = '/usr/local/share/pixmaps'
                 self.videomass_icon = share + '/videomass.png'
                 self.wizard_icon = url + '/videomass_wizard.png'
                 
             elif binarypath == '/usr/bin/videomass':
                 #usually Linux 
                 url = '/usr/share/videomass/icons'
                 share = '/usr/share/pixmaps'
                 self.videomass_icon = share + "/videomass.png"
                 self.wizard_icon = url + "/videomass_wizard.png"
                 
             else: 
                 #installed with 'pip install --user videomass' cmd
                 import site
                 userbase = site.getuserbase()
                 url = userbase + '/share/videomass/icons'
                 share = '/share/pixmaps'
                 self.videomass_icon = userbase+share + "/videomass.png"
                 self.wizard_icon = userbase+url+"/videomass_wizard.png"
                 
     # videomass sign
     if iconset == 'Videomass_Sign_Icons': # default
         self.x36 = '%s/Videomass_Sign_Icons/36x36' % url
         self.x24 = '%s/Videomass_Sign_Icons/24x24' % url
         self.x18 = '%s/Videomass_Sign_Icons/18x18' % url
     # material design black
     if iconset == 'Material_Design_Icons_black':
         self.x36 = '%s/Material_Design_Icons_black/36x36' % url
         self.x24 = '%s/Material_Design_Icons_black/24x24' % url
         self.x18 = '%s/Material_Design_Icons_black/18x18' % url
         self.icons_set()
     # material design white
     elif iconset == 'Material_Design_Icons_white':
         self.x36 = '%s/Material_Design_Icons_white/36x36' % url
         self.x24 = '%s/Material_Design_Icons_black/24x24' % url
         self.x18 = '%s/Material_Design_Icons_black/18x18' % url
         self.icons_set()
     # flat-colours
     elif iconset == 'Flat_Color_Icons':
         self.x36 = '%s/Flat_Color_Icons/36x36' % url
         self.x24 = '%s/Flat_Color_Icons/24x24' % url
         self.x18 = '%s/Flat_Color_Icons/18x18' % url
         self.icons_set()
开发者ID:jeanslack,项目名称:Videomass,代码行数:72,代码来源:appearance.py


示例20: site_dir_exists

def site_dir_exists(dirname):
    udir = os.path.join(site.getuserbase(), dirname)
    return os.path.exists(udir)
开发者ID:CospanDesign,项目名称:python,代码行数:3,代码来源:site_utils.py



注:本文中的site.getuserbase函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python site.getusersitepackages函数代码示例发布时间:2022-05-27
下一篇:
Python site.getsitepackages函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap