How to use sitepackages method in tox

Best Python code snippet using tox_python

common_utils.py

Source:common_utils.py Github

copy

Full Screen

...95 # if 'virtualenv' package is used, `site` has not attr getsitepackages, so we will instead use VIRTUAL_ENV96 # Note that conda venv will not have VIRTUAL_ENV97 python_dir = os.getenv('VIRTUAL_ENV')98 else:99 python_sitepackage = site.getsitepackages()[0]100 # If system-wide python is used, we will give priority to using `local sitepackage`--"usersitepackages()" given101 # that nni exists there102 if python_sitepackage.startswith('/usr') or python_sitepackage.startswith('/Library'):103 python_dir = try_installation_path_sequentially(site.getusersitepackages(), site.getsitepackages()[0])104 else:105 python_dir = try_installation_path_sequentially(site.getsitepackages()[0], site.getusersitepackages())106 if python_dir:107 entry_file = os.path.join(python_dir, 'nni', 'main.js')108 if os.path.isfile(entry_file):109 return os.path.join(python_dir, 'nni')110 print_error('Fail to find nni under python library')...

Full Screen

Full Screen

preferences.py

Source:preferences.py Github

copy

Full Screen

1import os2import sys3import bpy4class BrignetPrefs(bpy.types.AddonPreferences):5 bl_idname = __package__6 @staticmethod7 def append_modules():8 env_path = bpy.context.preferences.addons[__package__].preferences.modules_path9 if not os.path.isdir(env_path):10 return False11 12 if sys.platform.startswith("linux"):13 lib_path = os.path.join(env_path, 'lib')14 sitepackages = os.path.join(lib_path, 'python3.7', 'site-packages')15 else:16 lib_path = os.path.join(env_path, 'Lib')17 sitepackages = os.path.join(lib_path, 'site-packages')18 if not os.path.isdir(sitepackages):19 # not a python path, but the user might be still typing20 return False21 platformpath = os.path.join(sitepackages, sys.platform)22 platformlibs = os.path.join(platformpath, 'lib')23 mod_paths = [lib_path, sitepackages, platformpath, platformlibs]24 if sys.platform.startswith("win"):25 mod_paths.append(os.path.join(env_path, 'DLLs'))26 mod_paths.append(os.path.join(sitepackages, 'Pythonwin'))27 for mod_path in mod_paths:28 if not os.path.isdir(mod_path):29 # TODO: warning30 continue31 if mod_path not in sys.path:32 sys.path.append(mod_path)33 sys.path.append(env_path)34 return True35 @staticmethod36 def append_rignet():37 rignet_path = bpy.context.preferences.addons[__package__].preferences.rignet_path38 if not os.path.isdir(rignet_path):39 return False40 if not os.path.isdir(os.path.join(rignet_path, "utils")):41 # not the rignet path, but the user might still be typing42 return False43 if not rignet_path in sys.path:44 sys.path.append(rignet_path)45 return True46 def update_modules(self, context):47 self.append_modules()48 def update_rignet(self, context):49 self.append_rignet()50 modules_path: bpy.props.StringProperty(51 name='RigNet environment path',52 description='Path to Conda RignetEnvironment',53 subtype='DIR_PATH',54 update=update_modules55 )56 rignet_path: bpy.props.StringProperty(57 name='RigNet path',58 description='Path to RigNet code',59 subtype='DIR_PATH',60 default=os.path.dirname(__file__),61 update=update_rignet62 )63 model_path: bpy.props.StringProperty(64 name='Model path',65 description='Path to RigNet code',66 subtype='DIR_PATH',67 # default=os.path.join(os.path.join(os.path.dirname(__file__)), 'RigNet', 'checkpoints')68 )69 def draw(self, context):70 layout = self.layout71 column = layout.column()72 box = column.box()73 # first stage74 col = box.column()75 # row = col.row()76 # row.prop(self, 'modules_path', text='Modules Path')77 row = col.row()78 row.prop(self, 'rignet_path', text='RigNet Path')79 # row = col.row()80 # row.prop(self, 'model_path', text='Model Path')81 # row = layout.row()...

Full Screen

Full Screen

boot.py

Source:boot.py Github

copy

Full Screen

1import sys2from os.path import dirname, abspath, join, exists3PROJECT_DIR = dirname(dirname(abspath(__file__)))4SITEPACKAGES_DIR = join(PROJECT_DIR, "sitepackages")5DEV_SITEPACKAGES_DIR = join(SITEPACKAGES_DIR, "dev")6PROD_SITEPACKAGES_DIR = join(SITEPACKAGES_DIR, "prod")7APPENGINE_DIR = join(DEV_SITEPACKAGES_DIR, "google_appengine")8def fix_path(include_dev_libs_path=False):9 """ Insert libs folder(s) and SDK into sys.path. The one(s) inserted last take priority. """10 if include_dev_libs_path:11 if exists(APPENGINE_DIR) and APPENGINE_DIR not in sys.path:12 sys.path.insert(1, APPENGINE_DIR)13 if DEV_SITEPACKAGES_DIR not in sys.path:14 sys.path.insert(1, DEV_SITEPACKAGES_DIR)15 if SITEPACKAGES_DIR not in sys.path:16 sys.path.insert(1, PROD_SITEPACKAGES_DIR)17def get_app_config():18 """Returns the application configuration, creating it if necessary."""19 from django.utils.crypto import get_random_string20 from google.appengine.ext import ndb21 class Config(ndb.Model):22 """A simple key-value store for application configuration settings."""23 secret_key = ndb.StringProperty()24 # Create a random SECRET_KEY25 chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'26 @ndb.transactional()27 def txn():28 # Get or create the Config in a transaction, so that if it doesn't exist we don't get 229 # threads creating a Config object and one overwriting the other30 key = ndb.Key(Config, 'config')31 entity = key.get()32 if not entity:33 entity = Config(key=key)34 entity.secret_key = get_random_string(50, chars)35 entity.put()36 return entity37 return txn()38def register_custom_checks():39 from . import checks40 from django.core.checks import register, Tags41 register(checks.check_csp_sources_not_unsafe, Tags.security, deploy=True)42 register(checks.check_session_csrf_enabled, Tags.security)43 register(checks.check_csp_is_not_report_only, Tags.security)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tox automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful