def _run(self): code, data = environment.run_setup_py(["sdist"], pypath=self.old_cwd, data_stream=0) if code: info = "DIR: " + os.path.abspath('.') info += "\n SDIST RETURNED: %i\n\n" % code info += data raise AssertionError(info) datalines = data.splitlines() possible = ( "running sdist", "running egg_info", "creating dummy\.egg-info", "writing dummy\.egg-info", "writing top-level names to dummy\.egg-info", "writing dependency_links to dummy\.egg-info", "writing manifest file 'dummy\.egg-info", "reading manifest file 'dummy\.egg-info", "reading manifest template 'MANIFEST\.in'", "writing manifest file 'dummy\.egg-info", "creating dummy-0.1.1", "making hard links in dummy-0\.1\.1", "copying files to dummy-0\.1\.1", "copying \S+ -> dummy-0\.1\.1", "copying dummy", "copying dummy\.egg-info", "hard linking \S+ -> dummy-0\.1\.1", "hard linking dummy", "hard linking dummy\.egg-info", "Writing dummy-0\.1\.1", "creating dist", "creating 'dist", "Creating tar archive", "running check", "adding 'dummy-0\.1\.1", "tar .+ dist/dummy-0\.1\.1\.tar dummy-0\.1\.1", "gzip .+ dist/dummy-0\.1\.1\.tar", "removing 'dummy-0\.1\.1' \\(and everything under it\\)", ) print(" DIR: " + os.path.abspath('.')) for line in datalines: found = False for pattern in possible: if re.match(pattern, line): print(" READ: " + line) found = True break if not found: raise AssertionError("Unexpexected: %s\n-in-\n%s" % (line, data)) return data
def test_egg_base_installed_egg_info(self): self._create_project() temp_dir = tempfile.mkdtemp(prefix="setuptools-test.") os.chmod(temp_dir, stat.S_IRWXU) try: paths = {} for dirname in ["home", "lib", "scripts", "data", "egg-base"]: paths[dirname] = os.path.join(temp_dir, dirname) os.mkdir(paths[dirname]) config = os.path.join(paths["home"], ".pydistutils.cfg") with open(config, "w") as f: f.write("[egg_info]\n") f.write("egg-base = %s\n" % paths["egg-base"]) environ = os.environ.copy() environ["HOME"] = paths["home"] code, data = environment.run_setup_py( cmd=[ "install", "--home", paths["home"], "--install-lib", paths["lib"], "--install-scripts", paths["scripts"], "--install-data", paths["data"], ], pypath=os.pathsep.join([paths["lib"], self.old_cwd]), data_stream=1, env=environ, ) if code: raise AssertionError(data) egg_info = None for dirpath, dirnames, filenames in os.walk(paths["lib"]): if os.path.basename(dirpath) == "EGG-INFO": egg_info = sorted(filenames) self.assertEqual( egg_info, [ "PKG-INFO", "SOURCES.txt", "dependency_links.txt", "entry_points.txt", "not-zip-safe", "top_level.txt", ], ) finally: shutil.rmtree(temp_dir)
def test_no_tags(self): code, data = environment.run_setup_py(["egg_info"], pypath=self.old_cwd, data_stream=1) if code: raise AssertionError(data) pkginfo = os.path.join("dummy.egg-info", "PKG-INFO") infile = open(pkginfo, "r") try: read_contents = infile.readlines() finally: infile.close() del infile self.assertTrue("Version: 0.1.1\n" in read_contents)
def test_no_tags(self): code, data = environment.run_setup_py(["egg_info"], pypath=self.old_cwd, data_stream=1) if code: raise AssertionError(data) pkginfo = os.path.join('dummy.egg-info', 'PKG-INFO') infile = open(pkginfo, 'r') try: read_contents = infile.readlines() finally: infile.close() del infile self.assertTrue("Version: 0.1.1\n" in read_contents)
def test_sources(self): code, data = environment.run_setup_py(["sdist"], pypath=self.old_cwd, path="", data_stream=1) if code: raise AssertionError(data) sources = os.path.join("dummy.egg-info", "SOURCES.txt") infile = open(sources, "r") try: read_contents = infile.read() finally: infile.close() del infile self.assertEqual(DUMMY_SOURCE_TXT, read_contents) return data
def test_sources(self): code, data = environment.run_setup_py(["sdist"], pypath=self.old_cwd, data_stream=1) if code: raise AssertionError(data) sources = os.path.join('dummy.egg-info', 'SOURCES.txt') infile = open(sources, 'r') try: read_contents = infile.read() finally: infile.close() del infile self.assertEqual(DUMMY_SOURCE_TXT, read_contents) return data
def test_egg_base_installed_egg_info(self): self._create_project() temp_dir = tempfile.mkdtemp(prefix='setuptools-test.') os.chmod(temp_dir, stat.S_IRWXU) try: paths = {} for dirname in ['home', 'lib', 'scripts', 'data', 'egg-base']: paths[dirname] = os.path.join(temp_dir, dirname) os.mkdir(paths[dirname]) config = os.path.join(paths['home'], '.pydistutils.cfg') with open(config, 'w') as f: f.write('[egg_info]\n') f.write('egg-base = %s\n' % paths['egg-base']) environ = os.environ.copy() environ['HOME'] = paths['home'] code, data = environment.run_setup_py( cmd=[ 'install', '--home', paths['home'], '--install-lib', paths['lib'], '--install-scripts', paths['scripts'], '--install-data', paths['data']], pypath=os.pathsep.join([paths['lib'], self.old_cwd]), data_stream=1, env=environ) if code: raise AssertionError(data) egg_info = None for dirpath, dirnames, filenames in os.walk(paths['lib']): if os.path.basename(dirpath) == 'EGG-INFO': egg_info = sorted(filenames) self.assertEqual( egg_info, ['PKG-INFO', 'SOURCES.txt', 'dependency_links.txt', 'entry_points.txt', 'not-zip-safe', 'top_level.txt']) finally: shutil.rmtree(temp_dir)