def install_requirements(what): old_path = sys.path[:] w = os.path.join(os.getcwd(), os.path.dirname(inspect.getfile(inspect.currentframe()))) sys.path.insert(0, os.path.dirname(os.path.dirname(w))) try: from setup import EXTRAS_REQUIRE, read finally: sys.path = old_path requirements = ['mock>=2.0.0', 'flake8', 'pytest', 'pytest-cov' ] if what == 'all' else ['behave'] requirements += ['coverage'] # try to split tests between psycopg2 and psycopg3 requirements += ['psycopg[binary]'] if sys.version_info >= (3, 6, 0) and\ (sys.platform != 'darwin' or what == 'etcd3') else ['psycopg2-binary'] for r in read('requirements.txt').split('\n'): r = r.strip() if r != '': extras = { e for e, v in EXTRAS_REQUIRE.items() if v and any(r.startswith(x) for x in v) } if not extras or what == 'all' or what in extras: requirements.append(r) subprocess.call( [sys.executable, '-m', 'pip', 'install', '--upgrade', 'pip']) r = subprocess.call([sys.executable, '-m', 'pip', 'install'] + requirements) s = subprocess.call( [sys.executable, '-m', 'pip', 'install', '--upgrade', 'setuptools']) return s | r
def test_read(self): """ Reads a file and returns unicode. """ contents = 'foo' path = os.path.abspath(self.mktemp()) with open(path, 'wt') as f: f.write(contents) rv = setup.read(path) self.assertEqual(contents, rv) self.assertIsInstance(rv, unicode)
CLEAN_BEFORE = True UPDATE_README = not DRY_RUN GIT_UPDATE = not DRY_RUN GIT_RELEASE = not DRY_RUN AUTO_MANIFEST = True MANIFEST_EXCLUSIONS = [".git", ".gitignore"] PYPI_BUILD = False PYPI_RELEASE = not DRY_RUN # CLEAN_AFTER = not DRY_RUN CLEAN_AFTER = True if __name__ == "__main__": # Read the package name import os package = os.path.basename(os.path.dirname(os.path.abspath(__file__))) from setup import read version = read("version.txt")[0] if CLEAN_BEFORE: # Remove all of the wheel generated files # ================================================= run(["rm", "-rf", "dist", "build", package + ".egg-info"]) # Remove any pyc files that are hidden away run(["find", ".", "-name", '*.pyc', "-delete"]) run(["find", ".", "-name", '__pycache__', "-delete"]) if (UPDATE_README or GIT_UPDATE or GIT_RELEASE): # Make sure the user provided the correct number of arguments import sys, datetime if len(sys.argv) >= 2: notes = sys.argv[1] else: