Python setuptools.py31compat.TemporaryDirectory() Examples
The following are 12
code examples of setuptools.py31compat.TemporaryDirectory().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
setuptools.py31compat
, or try the search function
.
Example #1
Source File: svn_utils.py From pledgeservice with Apache License 2.0 | 6 votes |
def get_svn_version(): # Temp config directory should be enough to check for repository # This is needed because .svn always creates .subversion and # some operating systems do not handle dot directory correctly. # Real queries in real svn repos with be concerned with it creation with TemporaryDirectory() as tempdir: code, data = _run_command(['svn', '--config-dir', tempdir, '--version', '--quiet']) if code == 0 and data: return data.strip() else: return '' #svnversion return values (previous implementations return max revision) # 4123:4168 mixed revision working copy # 4168M modified working copy # 4123S switched working copy # 4123:4168MS mixed revision, modified, switched working copy
Example #2
Source File: build_meta.py From ironpython2 with Apache License 2.0 | 6 votes |
def _build_with_temp_dir(self, setup_command, result_extension, result_directory, config_settings): config_settings = self._fix_config(config_settings) result_directory = os.path.abspath(result_directory) # Build in a temporary directory, then copy to the target. makedirs(result_directory, exist_ok=True) with TemporaryDirectory(dir=result_directory) as tmp_dist_dir: sys.argv = (sys.argv[:1] + setup_command + ['--dist-dir', tmp_dist_dir] + config_settings["--global-option"]) self.run_setup() result_basename = _file_with_extension(tmp_dist_dir, result_extension) result_path = os.path.join(result_directory, result_basename) if os.path.exists(result_path): # os.rename will fail overwriting on non-Unix. os.remove(result_path) os.rename(os.path.join(tmp_dist_dir, result_basename), result_path) return result_basename
Example #3
Source File: svn_utils.py From oss-ftp with MIT License | 6 votes |
def get_svn_version(): # Temp config directory should be enough to check for repository # This is needed because .svn always creates .subversion and # some operating systems do not handle dot directory correctly. # Real queries in real svn repos with be concerned with it creation with TemporaryDirectory() as tempdir: code, data = _run_command(['svn', '--config-dir', tempdir, '--version', '--quiet']) if code == 0 and data: return data.strip() else: return '' #svnversion return values (previous implementations return max revision) # 4123:4168 mixed revision working copy # 4168M modified working copy # 4123S switched working copy # 4123:4168MS mixed revision, modified, switched working copy
Example #4
Source File: build_meta.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def build_wheel(self, wheel_directory, config_settings=None, metadata_directory=None): config_settings = self._fix_config(config_settings) wheel_directory = os.path.abspath(wheel_directory) # Build the wheel in a temporary directory, then copy to the target with TemporaryDirectory(dir=wheel_directory) as tmp_dist_dir: sys.argv = (sys.argv[:1] + ['bdist_wheel', '--dist-dir', tmp_dist_dir] + config_settings["--global-option"]) self.run_setup() wheel_basename = _file_with_extension(tmp_dist_dir, '.whl') wheel_path = os.path.join(wheel_directory, wheel_basename) if os.path.exists(wheel_path): # os.rename will fail overwriting on non-unix env os.remove(wheel_path) os.rename(os.path.join(tmp_dist_dir, wheel_basename), wheel_path) return wheel_basename
Example #5
Source File: build_meta.py From scylla with Apache License 2.0 | 6 votes |
def build_wheel(self, wheel_directory, config_settings=None, metadata_directory=None): config_settings = self._fix_config(config_settings) wheel_directory = os.path.abspath(wheel_directory) # Build the wheel in a temporary directory, then copy to the target with TemporaryDirectory(dir=wheel_directory) as tmp_dist_dir: sys.argv = (sys.argv[:1] + ['bdist_wheel', '--dist-dir', tmp_dist_dir] + config_settings["--global-option"]) self.run_setup() wheel_basename = _file_with_extension(tmp_dist_dir, '.whl') wheel_path = os.path.join(wheel_directory, wheel_basename) if os.path.exists(wheel_path): # os.rename will fail overwriting on non-unix env os.remove(wheel_path) os.rename(os.path.join(tmp_dist_dir, wheel_basename), wheel_path) return wheel_basename
Example #6
Source File: test_django.py From django-gcloud-storage with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_http_upload(self, client): """ :type client: django.test.Client """ with TemporaryDirectory() as tmpdir: for filename in [self.TEST_FILE_NAME, self.TEST_FILE_NAME_UNICODE]: with open(os.path.join(tmpdir, filename), 'w+b') as testfile: testfile.write(self.TEST_FILE_CONTENT) testfile.seek(0) r = client.post('/upload', {'file': testfile}) assert 302 == r.status_code assert ModelWithFileField.objects.count() == 2
Example #7
Source File: build_meta.py From rules_pip with MIT License | 6 votes |
def _build_with_temp_dir(self, setup_command, result_extension, result_directory, config_settings): config_settings = self._fix_config(config_settings) result_directory = os.path.abspath(result_directory) # Build in a temporary directory, then copy to the target. makedirs(result_directory, exist_ok=True) with TemporaryDirectory(dir=result_directory) as tmp_dist_dir: sys.argv = (sys.argv[:1] + setup_command + ['--dist-dir', tmp_dist_dir] + config_settings["--global-option"]) self.run_setup() result_basename = _file_with_extension(tmp_dist_dir, result_extension) result_path = os.path.join(result_directory, result_basename) if os.path.exists(result_path): # os.rename will fail overwriting on non-Unix. os.remove(result_path) os.rename(os.path.join(tmp_dist_dir, result_basename), result_path) return result_basename
Example #8
Source File: build_meta.py From setuptools with MIT License | 6 votes |
def _build_with_temp_dir(self, setup_command, result_extension, result_directory, config_settings): config_settings = self._fix_config(config_settings) result_directory = os.path.abspath(result_directory) # Build in a temporary directory, then copy to the target. os.makedirs(result_directory, exist_ok=True) with TemporaryDirectory(dir=result_directory) as tmp_dist_dir: sys.argv = (sys.argv[:1] + setup_command + ['--dist-dir', tmp_dist_dir] + config_settings["--global-option"]) self.run_setup() result_basename = _file_with_extension( tmp_dist_dir, result_extension) result_path = os.path.join(result_directory, result_basename) if os.path.exists(result_path): # os.rename will fail overwriting on non-Unix. os.remove(result_path) os.rename(os.path.join(tmp_dist_dir, result_basename), result_path) return result_basename
Example #9
Source File: build_meta.py From coffeegrindsize with MIT License | 6 votes |
def build_wheel(self, wheel_directory, config_settings=None, metadata_directory=None): config_settings = self._fix_config(config_settings) wheel_directory = os.path.abspath(wheel_directory) # Build the wheel in a temporary directory, then copy to the target with TemporaryDirectory(dir=wheel_directory) as tmp_dist_dir: sys.argv = (sys.argv[:1] + ['bdist_wheel', '--dist-dir', tmp_dist_dir] + config_settings["--global-option"]) self.run_setup() wheel_basename = _file_with_extension(tmp_dist_dir, '.whl') wheel_path = os.path.join(wheel_directory, wheel_basename) if os.path.exists(wheel_path): # os.rename will fail overwriting on non-unix env os.remove(wheel_path) os.rename(os.path.join(tmp_dist_dir, wheel_basename), wheel_path) return wheel_basename
Example #10
Source File: build_meta.py From V1EngineeringInc-Docs with Creative Commons Attribution Share Alike 4.0 International | 6 votes |
def _build_with_temp_dir(self, setup_command, result_extension, result_directory, config_settings): config_settings = self._fix_config(config_settings) result_directory = os.path.abspath(result_directory) # Build in a temporary directory, then copy to the target. makedirs(result_directory, exist_ok=True) with TemporaryDirectory(dir=result_directory) as tmp_dist_dir: sys.argv = (sys.argv[:1] + setup_command + ['--dist-dir', tmp_dist_dir] + config_settings["--global-option"]) self.run_setup() result_basename = _file_with_extension(tmp_dist_dir, result_extension) result_path = os.path.join(result_directory, result_basename) if os.path.exists(result_path): # os.rename will fail overwriting on non-Unix. os.remove(result_path) os.rename(os.path.join(tmp_dist_dir, result_basename), result_path) return result_basename
Example #11
Source File: svn_utils.py From pledgeservice with Apache License 2.0 | 5 votes |
def load(cls, dirname=''): normdir = os.path.normpath(dirname) # Temp config directory should be enough to check for repository # This is needed because .svn always creates .subversion and # some operating systems do not handle dot directory correctly. # Real queries in real svn repos with be concerned with it creation with TemporaryDirectory() as tempdir: code, data = _run_command(['svn', '--config-dir', tempdir, 'info', normdir]) # Must check for some contents, as some use empty directories # in testcases, however only enteries is needed also the info # command above MUST have worked svn_dir = os.path.join(normdir, '.svn') is_svn_wd = (not code or os.path.isfile(os.path.join(svn_dir, 'entries'))) svn_version = tuple(cls.get_svn_version().split('.')) try: base_svn_version = tuple(int(x) for x in svn_version[:2]) except ValueError: base_svn_version = tuple() if not is_svn_wd: #return an instance of this NO-OP class return SvnInfo(dirname) if code or not base_svn_version or base_svn_version < (1, 3): warnings.warn(("No SVN 1.3+ command found: falling back " "on pre 1.7 .svn parsing"), DeprecationWarning) return SvnFileInfo(dirname) if base_svn_version < (1, 5): return Svn13Info(dirname) return Svn15Info(dirname)
Example #12
Source File: svn_utils.py From oss-ftp with MIT License | 5 votes |
def load(cls, dirname=''): normdir = os.path.normpath(dirname) # Temp config directory should be enough to check for repository # This is needed because .svn always creates .subversion and # some operating systems do not handle dot directory correctly. # Real queries in real svn repos with be concerned with it creation with TemporaryDirectory() as tempdir: code, data = _run_command(['svn', '--config-dir', tempdir, 'info', normdir]) # Must check for some contents, as some use empty directories # in testcases, however only enteries is needed also the info # command above MUST have worked svn_dir = os.path.join(normdir, '.svn') is_svn_wd = (not code or os.path.isfile(os.path.join(svn_dir, 'entries'))) svn_version = tuple(cls.get_svn_version().split('.')) try: base_svn_version = tuple(int(x) for x in svn_version[:2]) except ValueError: base_svn_version = tuple() if not is_svn_wd: #return an instance of this NO-OP class return SvnInfo(dirname) if code or not base_svn_version or base_svn_version < (1, 3): warnings.warn(("No SVN 1.3+ command found: falling back " "on pre 1.7 .svn parsing"), DeprecationWarning) return SvnFileInfo(dirname) if base_svn_version < (1, 5): return Svn13Info(dirname) return Svn15Info(dirname)