def get_platform( platform=False, peak=False ): if platform: if peak: return "%s-%s" % ( get_py(), pkg_resources.get_platform() ) else: return "%s-%s-%s" % ( get_py(), pkg_resources.get_platform(), get_ucs() ) else: if peak: return get_py() else: return "%s-noplatform" % get_py()
def get_platform(platform=False, peak=False): if platform: if peak: return "%s-%s" % (get_py(), pkg_resources.get_platform()) else: return "%s-%s-%s" % (get_py(), pkg_resources.get_platform(), get_ucs()) else: if peak: return get_py() else: return "%s-noplatform" % get_py()
def make_build_properties(cls): pi = PythonInterpreter() base_info = { 'class': pi.identity().interpreter, 'version': pi.identity().version, 'platform': get_platform(), } try: from twitter.pants import get_buildroot, get_scm buildroot = get_buildroot() scm = get_scm() now = localtime() if scm: revision = scm.commit_id tag = scm.tag_name or 'none' branchname = scm.branch_name or revision else: revision = 'unknown' tag = 'none' branchname = 'unknown' base_info.update({ 'date': strftime('%A %b %d, %Y', now), 'time': strftime('%H:%M:%S', now), 'timestamp': strftime('%m.%d.%Y %H:%M', now), 'branch': branchname, 'tag': tag, 'sha': revision, 'user': getpass.getuser(), 'machine': socket.gethostname(), 'path': buildroot }) except ImportError: pass return base_info
def fix_compiler(self): platform = get_platform() cc = self.compiler if not cc: return if 'macosx-10.9' in platform: for needle in ['-mno-fused-madd']: try: cc.compiler.remove(needle) cc.compiler_so.remove(needle) except ValueError: # We are removing, so OK when needle not there pass for name, args in cc.__dict__.items(): if not args or not isinstance(args, list): continue new_args = [] enum_args = enumerate(args) for i, arg in enum_args: if arg == '-arch': # Skip not needed architecture if args[i + 1] != self.arch: next(enum_args) else: new_args.append(arg) else: new_args.append(arg) try: cc.setattr(name, new_args) except AttributeError: # Old class cc.__dict__[name] = new_args # Add system headers to Extensions extra_compile_args sysheaders = ['-isystem' + dir for dir in cc.include_dirs] for ext in self.extensions: # Add Protobuf include and library dirs if ext.name == "_mysqlxpb": ext.include_dirs.append(self.with_protobuf_include_dir) ext.library_dirs.append(self.with_protobuf_lib_dir) if os.name == 'nt': ext.libraries.append("libprotobuf") else: ext.libraries.append("protobuf") # Add extra compile args if self.extra_compile_args: ext.extra_compile_args.append(self.extra_compile_args) # Add system headers for sysheader in sysheaders: if sysheader not in ext.extra_compile_args: ext.extra_compile_args.append(sysheader) # Stop warnings about unknown pragma if os.name != 'nt': ext.extra_compile_args.append('-Wno-unknown-pragmas')
def make_build_properties(cls): pi = PythonInterpreter() base_info = { 'class': pi.identity().interpreter, 'version': pi.identity().version, 'platform': get_platform(), } try: from twitter.pants.base.build_environment import get_buildroot, get_scm buildroot = get_buildroot() scm = get_scm() now = localtime() if scm: revision = scm.commit_id tag = scm.tag_name or 'none' branchname = scm.branch_name or revision else: revision = 'unknown' tag = 'none' branchname = 'unknown' base_info.update({ 'date': strftime('%A %b %d, %Y', now), 'time': strftime('%H:%M:%S', now), 'timestamp': strftime('%m.%d.%Y %H:%M', now), 'branch': branchname, 'tag': tag, 'sha': revision, 'user': getpass.getuser(), 'machine': socket.gethostname(), 'path': buildroot }) except ImportError: pass return base_info
def fetch( self, requirement ): """ fetch() serves as the install method to pkg_resources.working_set.resolve() """ def find_alternative(): """ Some platforms (e.g. Solaris) support eggs compiled on older platforms """ class LinkParser( HTMLParser.HTMLParser ): """ Finds links in what should be an Apache-style directory index """ def __init__( self ): HTMLParser.HTMLParser.__init__( self ) self.links = [] def handle_starttag( self, tag, attrs ): if tag == 'a' and 'href' in dict( attrs ): self.links.append( dict( attrs )['href'] ) parser = LinkParser() try: parser.feed( urllib2.urlopen( self.url + '/' ).read() ) except urllib2.HTTPError, e: if e.code == 404: return None parser.close() for link in parser.links: file = urllib.unquote( link ).rsplit( '/', 1 )[-1] tmp_dist = pkg_resources.Distribution.from_filename( file ) if tmp_dist.platform is not None and \ self.distribution.project_name == tmp_dist.project_name and \ self.distribution.version == tmp_dist.version and \ self.distribution.py_version == tmp_dist.py_version and \ pkg_resources.compatible_platforms( tmp_dist.platform, pkg_resources.get_platform() ): return file return None
def fetch( self, requirement ): """ fetch() serves as the install method to pkg_resources.working_set.resolve() """ def find_alternative(): """ Some platforms (e.g. Solaris) support eggs compiled on older platforms """ class LinkParser( HTMLParser.HTMLParser ): """ Finds links in what should be an Apache-style directory index """ def __init__( self ): HTMLParser.HTMLParser.__init__( self ) self.links = [] def handle_starttag( self, tag, attrs ): if tag == 'a' and 'href' in dict( attrs ): self.links.append( dict( attrs )['href'] ) parser = LinkParser() try: parser.feed( urllib2.urlopen( self.url + '/' ).read() ) except urllib2.HTTPError, e: if e.code == 404: return None parser.close() for link in parser.links: file = urllib.unquote( link ).rsplit( '/', 1 )[-1] tmp_dist = pkg_resources.Distribution.from_filename( file ) if tmp_dist.platform is not None and \ self.distribution.project_name == tmp_dist.project_name and \ self.distribution.version == tmp_dist.version and \ self.distribution.py_version == tmp_dist.py_version and \ pkg_resources.compatible_platforms( tmp_dist.platform, pkg_resources.get_platform() ): return file return None
def find(self, requirement, platform=pkg_resources.get_platform(), py_version=None): """ Query the location of a distribution that fulfills a requirement. Returns a tuple of: location = the location of the distribution (or None if none found.) repo = the repo in which it was found (or None if local or not found.) """ if py_version is None: py_version = '%s.%s' % (sys.version_info[0], sys.version_info[1]) env = pkg_resources.Environment() if isinstance(requirement, str): requirement = pkg_resources.Requirement.parse(requirement) # first check the local cache for dist in pkg_resources.find_distributions(self._cache): if dist in requirement and env.can_add(dist): return (dist.location, None) # if nothing found, go out to remotes for repo in self._pis: repo.find_packages(requirement) for package in repo[requirement.project_name]: if pkg_resources.compatible_platforms(package.platform, platform): if package.py_version is not None and package.py_version != py_version: continue if package not in requirement: continue return (package.location, repo) return (None, None)
def get_env(): env = pkg_resources.Environment(search_path='', platform=pkg_resources.get_platform()) for dist in pkg_resources.find_distributions( os.path.join(galaxy_dir, 'eggs'), False): env.add(dist) return env
def fix_compiler(self): platform = get_platform() cc = self.compiler if not cc: return if 'macosx-10.9' in platform: for needle in ['-mno-fused-madd']: try: cc.compiler.remove(needle) cc.compiler_so.remove(needle) except ValueError: # We are removing, so OK when needle not there pass for name, args in cc.__dict__.items(): if not args or not isinstance(args, list): continue new_args = [] enum_args = enumerate(args) for i, arg in enum_args: if arg == '-arch': # Skip not needed architecture if args[i+1] != self.arch: next(enum_args) else: new_args.append(arg) else: new_args.append(arg) try: cc.setattr(name, new_args) except AttributeError: # Old class cc.__dict__[name] = new_args # Add system headers to Extensions extra_compile_args sysheaders = [ '-isystem' + dir for dir in cc.include_dirs] for ext in self.extensions: # Add Protobuf include and library dirs if ext.name == "_mysqlxpb": ext.include_dirs.append(self.with_protobuf_include_dir) ext.library_dirs.append(self.with_protobuf_lib_dir) if os.name == 'nt': ext.libraries.append("libprotobuf") else: ext.libraries.append("protobuf") # Add extra compile args if self.extra_compile_args: ext.extra_compile_args.append(self.extra_compile_args) # Add system headers for sysheader in sysheaders: if sysheader not in ext.extra_compile_args: ext.extra_compile_args.append(sysheader) # Stop warnings about unknown pragma if os.name != 'nt': ext.extra_compile_args.append('-Wno-unknown-pragmas')
def check_pysam(): # can't build pysam on solaris < 10 plat = pkg_resources.get_platform().split('-') if plat[0] == 'solaris': minor = plat[1].split('.')[1] if int(minor) < 10: return False return True
def check_pysam(): # can't build pysam on solaris < 10 plat = pkg_resources.get_platform().split( '-' ) if plat[0] == 'solaris': minor = plat[1].split('.')[1] if int( minor ) < 10: return False return True
def make_build_properties(cls): from .interpreter import PythonInterpreter from pkg_resources import get_platform pi = PythonInterpreter.get() return { 'class': pi.identity.interpreter, 'version': pi.identity.version, 'platform': get_platform(), }
def parse_egg_section( self, eggs, tags, full_platform=False, egg_class=Egg ): for name, version in eggs: tag = dict( tags ).get( name, '' ) url = '/'.join( ( self.repo, name ) ) if full_platform: platform = self.platform or '-'.join( ( py, pkg_resources.get_platform() ) ) else: platform = self.py_platform or py egg = egg_class( name=name, version=version, tag=tag, url=url, platform=platform, crate=self ) self.eggs[name] = egg
def parse_egg_section( self, eggs, tags, full_platform=False, egg_class=Egg ): for name, version in eggs: tag = dict( tags ).get( name, '' ) url = '/'.join( ( self.repo, name ) ) if full_platform: platform = self.platform or '-'.join( ( py, pkg_resources.get_platform() ) ) else: platform = self.py_platform or py egg = egg_class( name=name, version=version, tag=tag, url=url, platform=platform, crate=self ) self.eggs[name] = egg
def make_build_properties(cls): from .interpreter import PythonInterpreter from pkg_resources import get_platform pi = PythonInterpreter.get() return { 'class': pi.identity.interpreter, 'version': pi.identity.version, 'platform': get_platform(), }
def build_properties(cls): pi = PythonInterpreter() base_info = { 'class': pi.identity().interpreter, 'version': pi.identity().version, 'platform': get_platform(), } try: from twitter.pants.base.build_info import get_build_info base_info.update(get_build_info()._asdict()) except ImportError: pass return base_info
def fetch(self, requirement, platform=pkg_resources.get_platform()): """ Fetch a distribution that matches the requirement. Returns a local path to the distribution or None if nothing appropriate found. """ location, repo = self.find(requirement, platform) if repo: return repo.download(location, self._cache) # if location is set and repo is None, it's a local package. elif location: return location
def build_properties(cls): pi = PythonInterpreter() base_info = { 'class': pi.identity().interpreter, 'version': pi.identity().version, 'platform': get_platform(), } try: from twitter.pants.base.build_info import get_build_info base_info.update(get_build_info()._asdict()) except ImportError: pass return base_info
def test_config(self): c = Config() self.assertIsNotNone(c.tar) self.assertIsNotNone(c.cat) self.assertIsNotNone(c.split) self.assertTrue(os.path.isfile(c.tar)) self.assertTrue(os.path.isfile(c.split)) self.assertTrue(os.path.isfile(c.cat)) platform = pkg_resources.get_platform() if platform == "linux-x86_64": self.assertTrue(os.path.isfile(c.hairgapr_path)) self.assertTrue(os.path.isfile(c.hairgaps_path)) else: print("Unknown platform : %s" % platform)
def get_platform(): """ Return finer-grained platform names, corresponding to supported EPD versions. """ PLAT, PLAT_VER = platform.dist()[0:2] # Map RedHat to Enthought repo names if PLAT.lower().startswith("redhat"): PLAT = "redhat" if PLAT_VER.startswith("3"): PLAT_VER = "3" elif PLAT_VER.startswith("4"): PLAT_VER = "4" elif PLAT_VER.startswith("5"): PLAT_VER = "5" # Ubuntu returns debian...check /etc/issue too elif PLAT.lower().startswith("debian"): if path.exists("/etc/issue"): fh = open("/etc/issue", "r") lines = fh.readlines() fh.close() patt = re.compile("^([\w]+) ([\w\.]+).*") for line in lines: match = patt.match(line) if match is not None: plat = match.group(1).lower() if plat == "ubuntu": PLAT = plat PLAT_VER = match.group(2).lower() break # Windows elif sys.platform.lower().startswith("win"): PLAT = "windows" # this returns "xp" for Windows XP and "vista" for Windows Vista # XXX If we want to support Windows 2k we need to check this PLAT_VER = platform.release().lower() # setuptools get_platform() finds the right info for OSX elif sys.platform.lower().startswith("darwin"): (PLAT, PLAT_VER) = pkg_resources.get_platform().split( "-" )[0:2] return (PLAT, PLAT_VER)
def find(self, requirement, platform=pkg_resources.get_platform()): """ Query the location of a distribution that fulfills a requirement. Returns a tuple of: location = the location of the distribution (or None if none found.) repo = the repo in which it was found (or None if local or not found.) """ if isinstance(requirement, str): requirement = pkg_resources.Requirement.parse(requirement) # first check the local cache for dist in pkg_resources.find_distributions(self._cache): if dist in requirement and pkg_resources.compatible_platforms(dist.platform, platform): return (dist.location, None) # if nothing found, go out to remotes for repo in self._pis: repo.find_packages(requirement) for package in repo[requirement.project_name]: if pkg_resources.compatible_platforms(package.platform, platform): return (package.location, repo) return (None, None)
out = p.stdout.read() p.wait() if 'Sun C' in out: return 'cc' else: return 'gcc' # get galaxy eggs lib galaxy_lib = os.path.abspath( os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, 'lib')) sys.path.insert(0, galaxy_lib) from galaxy import eggs # get setuptools try: from setuptools import * import pkg_resources except ImportError: from ez_setup import use_setuptools use_setuptools(download_delay=8, to_dir=os.path.dirname(__file__)) from setuptools import * import pkg_resources # some constants root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) archives = os.path.abspath(os.path.join(root, 'archives')) patches = os.path.abspath(os.path.join(root, 'patches')) platform_noucs = pkg_resources.get_platform().rsplit('-', 1)[0]
def make_build_properties(cls): from .interpreter import PythonInterpreter from pkg_resources import get_platform pi = PythonInterpreter.get() return {"class": pi.identity.interpreter, "version": pi.identity.version, "platform": get_platform()}
root.setLevel( 10 ) root.addHandler( logging.StreamHandler( sys.stdout ) ) lib = os.path.abspath( os.path.join( os.path.dirname( __file__ ), "..", "lib" ) ) sys.path.insert( 1, lib ) from galaxy.eggs import Crate, EggNotFetchable, py import pkg_resources try: assert options.platform platform = options.platform c = Crate( options.config, platform = platform ) print "Platform forced to '%s'" % platform except: platform = '-'.join( ( py, pkg_resources.get_platform() ) ) c = Crate( options.config ) print "Using Python interpreter at %s, Version %s" % ( sys.executable, sys.version ) print "This platform is '%s'" % platform print "Override with:" print " make_egg_packager.py <forced-platform>" shutil.copy( os.path.join( os.path.dirname( __file__ ), 'egg_packager_template.py' ), 'egg_packager-%s.py' % platform ) packager = open( 'egg_packager-%s.py' % platform, 'a' ) packager.write( "py = '%s'\n" % py ) packager.write( "url = '%s'\n" % c.repo ) packager.write( "platform = '%s'\n" % platform ) packager.write( "dists = [\n" ) for egg in c.all_eggs:
# get the tag if os.access(".galaxy_tag", os.F_OK): tagfile = open(".galaxy_tag", "r") tag = tagfile.readline().strip() else: tag = None # LZO version is the same as this egg LZO_VERSION = "1.08" LZO_ARCHIVE = os.path.abspath( os.path.join("..", "..", "..", "archives", "lzo-%s.tar.gz" % LZO_VERSION)) LZO_BINARY_ARCHIVE = os.path.abspath( os.path.join( "..", "..", "..", "archives", "lzo-%s-%s.tar.bz2" % (LZO_VERSION, pkg_resources.get_platform()))) # there's no need to have a completely separate build script for this if pkg_resources.get_platform() == "macosx-10.3-fat": CONFIGURE = "CFLAGS='-O -g -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc' " CONFIGURE += "LDFLAGS='-arch i386 -arch ppc' " CONFIGURE += "LD='gcc -mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -nostartfiles -arch i386 -arch ppc' " CONFIGURE += "./configure --prefix=%s/lzo --disable-shared --disable-dependency-tracking --enable-static" % os.getcwd( ) else: CONFIGURE = "CFLAGS='-fPIC' ./configure --prefix=%s/lzo --disable-shared --enable-static" % os.getcwd( ) # clean, in case you're running this by hand from a dirty module source dir for dir in ["build", "dist", "lzo-%s" % LZO_VERSION]: if os.access(dir, os.F_OK): print "scramble_it.py: removing dir:", dir
from setuptools import setup, Extension from setuptools.command.build_ext import build_ext from pkg_resources import get_platform # import numpy only when it is needed class build_ext_custom(build_ext): def run(self): import numpy self.include_dirs.append(numpy.get_include()) build_ext.run(self) if get_platform() == "win32" or get_platform() == "win-amd64": libraries = [] else: libraries = ['m'] ext_modules = [ Extension("minepy.mine", ["minepy/mine.c", "libmine/mine.c"], libraries=libraries, extra_compile_args=['-Wall']) ] classifiers = [ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Science/Research', 'License :: OSI Approved :: GNU General Public License (GPL)', 'Programming Language :: C', 'Programming Language :: C++', 'Programming Language :: Cython',
if not os.path.exists(options.config): print "Config file does not exist (see 'python %s --help'): %s" % ( sys.argv[0], options.config) sys.exit(1) root = logging.getLogger() root.setLevel(10) root.addHandler(logging.StreamHandler(sys.stdout)) try: assert options.platform platform = options.platform c = Crate(options.config, platform=platform) print "Platform forced to '%s'" % platform except: platform = '-'.join((py, pkg_resources.get_platform())) c = Crate(options.config) print "Using Python interpreter at %s, Version %s" % (sys.executable, sys.version) print "This platform is '%s'" % platform print "Override with:" print " make_egg_packager.py <forced-platform>" shutil.copy( os.path.join(os.path.dirname(__file__), 'egg_packager_template.py'), 'egg_packager-%s.py' % platform) packager = open('egg_packager-%s.py' % platform, 'a') packager.write("py = '%s'\n" % py) packager.write("url = '%s'\n" % c.repo) packager.write("platform = '%s'\n" % platform)
__all__ = ["distribution", "software", "python", "platform", "revision"] import pkg_resources import sys import git platform = pkg_resources.get_platform() python = sys.version distribution = pkg_resources.get_distribution(__name__.split(".")[0]) software = "{} {}".format(distribution.project_name, distribution.version) try: repo = git.Repo(search_parent_directories=True) revision = repo.head.object.hexsha except git.exc.InvalidGitRepositoryError: revision = "UNKNOWN"
def get_env(): env = pkg_resources.Environment( search_path='', platform=pkg_resources.get_platform() ) for dist in pkg_resources.find_distributions( os.path.join( galaxy_dir, 'eggs' ), False ): env.add( dist ) return env
# get the tag if os.access(".galaxy_tag", os.F_OK): tagfile = open(".galaxy_tag", "r") tag = tagfile.readline().strip() else: tag = None # globals MYSQL_VERSION = (tag.split("_"))[1] MYSQL_ARCHIVE = os.path.abspath( os.path.join("..", "..", "..", "archives", "mysql-%s.tar.gz" % MYSQL_VERSION)) MYSQL_BINARY_ARCHIVE = os.path.abspath( os.path.join( "..", "..", "..", "archives", "mysql-%s-%s.tar.bz2" % (MYSQL_VERSION, pkg_resources.get_platform()))) # there's no need to have a completely separate build script for this if pkg_resources.get_platform() == "macosx-10.3-fat": CONFIGURE = "CFLAGS='-O -g -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc' " CONFIGURE += "CXXFLAGS='-O -g -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc' " CONFIGURE += "LDFLAGS='-arch i386 -arch ppc' " CONFIGURE += "LD='gcc -mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -nostartfiles -arch i386 -arch ppc' " CONFIGURE += "./configure --prefix=%s/mysql --disable-dependency-tracking --without-server --without-uca --without-libwrap " % os.getcwd( ) CONFIGURE += "--without-extra-tools --without-openssl --without-yassl --without-docs --without-man --without-bench --enable-thread-safe-client" else: CONFIGURE = "CFLAGS='-fPIC' ./configure --prefix=%s/mysql --disable-shared --without-server --without-uca --without-libwrap " % os.getcwd( ) CONFIGURE += "--without-extra-tools --without-openssl --without-yassl --without-docs --without-man --without-bench --enable-thread-safe-client" # clean, in case you're running this by hand from a dirty module source dir
# patch file = "setup.py" print "scramble(): Patching", file if not os.access( "%s.orig" %file, os.F_OK ): shutil.copyfile( file, "%s.orig" %file ) i = open( "%s.orig" %file, "r" ) o = open( file, "w" ) for line in i.readlines(): if line == 'SGE6_ROOT="/scratch_test02/SGE6"\n': line = 'SGE6_ROOT="%s"\n' % os.environ["SGE_ROOT"] if line.startswith('link_args ='): line = 'link_args = [ "-L%s" % os.path.join(SGE6_ROOT, "lib", SGE6_ARCH), "-ldrmaa" ]\n' print >>o, line, i.close() o.close() # go me = sys.argv[0] sys.argv = [ me ] sys.argv.append( "build" ) execfile( "setup.py", globals(), locals() ) # fix _cDRMAA.so rpath so = "build/lib.%s-%s/_cDRMAA.so" % ( pkg_resources.get_platform(), sys.version[:3] ) libdrmaa = os.path.join(SGE6_ROOT, "lib", SGE6_ARCH, "libdrmaa.dylib.1.0" ) os.system( "install_name_tool -change libdrmaa.dylib.1.0 %s %s" % ( libdrmaa, so ) ) sys.argv = [ me ] sys.argv.append( "bdist_egg" ) execfile( "setup.py", globals(), locals() )
def _finalize_connector_c(self, connc_loc): """Finalize the --with-connector-c command line argument """ platform = get_platform() self._mysql_config_info = None min_version = BuildExtDynamic.min_connector_c_version err_invalid_loc = "MySQL C API location is invalid; was %s" mysql_config = None err_version = "MySQL C API {0}.{1}.{2} or later required".format( *BuildExtDynamic.min_connector_c_version) if not os.path.exists(connc_loc): log.error(err_invalid_loc, connc_loc) sys.exit(1) if os.path.isdir(connc_loc): # if directory, and no mysql_config is available, figure out the # lib/ and include/ folders from the the filesystem mysql_config = os.path.join(connc_loc, 'bin', 'mysql_config') if os.path.isfile(mysql_config) and \ os.access(mysql_config, os.X_OK): connc_loc = mysql_config log.debug("# connc_loc: {0}".format(connc_loc)) else: # Probably using MS Windows myconfigh = os.path.join(connc_loc, 'include', 'my_config.h') if not os.path.exists(myconfigh): log.error("MySQL C API installation invalid " "(my_config.h not found)") sys.exit(1) else: with open(myconfigh, 'rb') as fp: for line in fp.readlines(): if b'#define VERSION' in line: version = tuple([ int(v) for v in line.split()[2].replace( b'"', b'').split(b'.') ]) if version < min_version: log.error(err_version) sys.exit(1) break # On Windows we check libmysql.dll if os.name == 'nt': lib = os.path.join(self.with_mysql_capi, 'lib', 'libmysql.dll') connc_64bit = win_dll_is64bit(lib) # On OSX we check libmysqlclient.dylib elif 'macos' in platform: lib = os.path.join(self.with_mysql_capi, 'lib', 'libmysqlclient.dylib') connc_64bit = unix_lib_is64bit(lib) # On other Unices we check libmysqlclient (follow symlinks) elif os.name == 'posix': connc_64bit = unix_lib_is64bit(connc_loc) else: raise OSError("Unsupported platform: %s" % os.name) include_dirs = [os.path.join(connc_loc, 'include')] if os.name == 'nt': libraries = ['libmysql'] else: libraries = ['-lmysqlclient'] library_dirs = os.path.join(connc_loc, 'lib') log.debug("# connc_64bit: {0}".format(connc_64bit)) if connc_64bit: self.arch = 'x86_64' else: self.arch = 'i386' # We were given the location of the mysql_config tool (not on Windows) if not os.name == 'nt' and os.path.isfile(connc_loc) \ and os.access(connc_loc, os.X_OK): mysql_config = connc_loc # Check mysql_config myc_info = get_mysql_config_info(mysql_config) log.debug("# myc_info: {0}".format(myc_info)) if myc_info['version'] < min_version: log.error(err_version) sys.exit(1) include_dirs = myc_info['include'] libraries = myc_info['libs'] library_dirs = myc_info['lib_dir'] self._mysql_config_info = myc_info self.arch = self._mysql_config_info['arch'] connc_64bit = self.arch == 'x86_64' for include_dir in include_dirs: if not os.path.exists(include_dir): log.error(err_invalid_loc, connc_loc) sys.exit(1) # Set up the build_ext class self.include_dirs.extend(include_dirs) self.libraries.extend(libraries) self.library_dirs.append(library_dirs) # We try to offer a nice message when the architecture of Python # is not the same as MySQL Connector/C binaries. py_arch = '64-bit' if ARCH_64BIT else '32-bit' log.debug("# Python architecture: {0}".format(py_arch)) log.debug("# Python ARCH_64BIT: {0}".format(ARCH_64BIT)) log.debug("# self.arch: {0}".format(self.arch)) if ARCH_64BIT != connc_64bit: log.error("Python is {0}, but does not " "match MySQL C API {1} architecture, " "type: {2}" "".format(py_arch, '64-bit' if connc_64bit else '32-bit', self.arch)) sys.exit(1)
#!/usr/bin/env python import os import sys assert sys.version_info[:2] >= (2, 6) lib = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, "lib")) sys.path.insert(1, lib) import pkg_resources print(pkg_resources.get_platform())
from setuptools import setup, Extension from setuptools.command.build_ext import build_ext from pkg_resources import get_platform # import numpy only when it is needed class build_ext_custom(build_ext): def run(self): import numpy self.include_dirs.append(numpy.get_include()) build_ext.run(self) if get_platform() == "win32" or get_platform() == "win-amd64": libraries = [] else: libraries = ['m'] ext_modules = [ Extension("minepy.mine", ["minepy/mine.c", "libmine/mine.c"], libraries=libraries, extra_compile_args=['-Wall']) ] classifiers = [ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Science/Research', 'License :: OSI Approved :: GNU General Public License (GPL)', 'Programming Language :: C', 'Programming Language :: C++', 'Programming Language :: Cython',
except: from ez_setup import use_setuptools use_setuptools( download_delay=8, to_dir=scramble_lib ) from setuptools import * import pkg_resources # get the tag if os.access( ".galaxy_tag", os.F_OK ): tagfile = open( ".galaxy_tag", "r" ) tag = tagfile.readline().strip() else: tag = None POSTGRES_VERSION = ( tag.split( "_" ) )[1] POSTGRES_ARCHIVE = os.path.abspath( os.path.join( "..", "..", "..", "archives", "postgresql-%s.tar.bz2" %POSTGRES_VERSION ) ) POSTGRES_BINARY_ARCHIVE = os.path.abspath( os.path.join( "..", "..", "..", "archives", "postgresql-%s-%s.tar.bz2" %( POSTGRES_VERSION, pkg_resources.get_platform() ) ) ) # there's no need to have a completely separate build script for this if pkg_resources.get_platform() == "macosx-10.3-fat": CONFIGURE = "CFLAGS='-O -g -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc' LDFLAGS='-arch i386 -arch ppc' LD='gcc -mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -nostartfiles -arch i386 -arch ppc' ./configure --prefix=%s/postgres --disable-shared --disable-dependency-tracking --without-readline" %os.getcwd() else: CONFIGURE = "CFLAGS='-fPIC' ./configure --prefix=%s/postgres --disable-shared --without-readline" %os.getcwd() # clean, in case you're running this by hand from a dirty module source dir for dir in [ "build", "dist", "postgresql-%s" %POSTGRES_VERSION ]: if os.access( dir, os.F_OK ): print "scramble_it.py: removing dir:", dir shutil.rmtree( dir ) # build/unpack Postgres unpack_prebuilt_postgres()
#!/usr/bin/env python import os import sys assert sys.version_info[:2] >= (2, 4) lib = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, "lib")) sys.path.insert(1, lib) import pkg_resources print pkg_resources.get_platform()
def get_solaris_compiler(): p = subprocess.Popen( '%s -V 2>&1' % get_config_var('CC'), shell = True, stdout = subprocess.PIPE ) out = p.stdout.read() p.wait() if 'Sun C' in out: return 'cc' else: return 'gcc' # get galaxy eggs lib galaxy_lib = os.path.abspath( os.path.join( os.path.dirname( __file__ ), '..', '..', '..', 'lib' ) ) sys.path.insert( 0, galaxy_lib ) from galaxy import eggs # get setuptools try: from setuptools import * import pkg_resources except ImportError: from ez_setup import use_setuptools use_setuptools( download_delay=8, to_dir=os.path.dirname( __file__ ) ) from setuptools import * import pkg_resources # some constants root = os.path.abspath( os.path.join( os.path.dirname( __file__ ), '..' ) ) archives = os.path.abspath( os.path.join( root, 'archives' ) ) patches = os.path.abspath( os.path.join( root, 'patches' ) ) platform_noucs = pkg_resources.get_platform().rsplit( '-', 1 )[0]
def _finalize_connector_c(self, connc_loc): """Finalize the --with-connector-c command line argument """ platform = get_platform() self._mysql_config_info = None min_version = BuildExtDynamic.min_connector_c_version err_invalid_loc = "MySQL C API location is invalid; was %s" mysql_config = None err_version = "MySQL C API {0}.{1}.{2} or later required".format( *BuildExtDynamic.min_connector_c_version) if not os.path.exists(connc_loc): log.error(err_invalid_loc, connc_loc) sys.exit(1) if os.path.isdir(connc_loc): # if directory, and no mysql_config is available, figure out the # lib/ and include/ folders from the the filesystem mysql_config = os.path.join(connc_loc, 'bin', 'mysql_config') if os.path.isfile(mysql_config) and \ os.access(mysql_config, os.X_OK): connc_loc = mysql_config log.debug("# connc_loc: {0}".format(connc_loc)) else: # Probably using MS Windows myconfigh = os.path.join(connc_loc, 'include', 'my_config.h') if not os.path.exists(myconfigh): log.error("MySQL C API installation invalid " "(my_config.h not found)") sys.exit(1) else: with open(myconfigh, 'rb') as fp: for line in fp.readlines(): if b'#define VERSION' in line: version = tuple([ int(v) for v in line.split()[2].replace( b'"', b'').split(b'.') ]) if version < min_version: log.error(err_version); sys.exit(1) break # On Windows we check libmysql.dll if os.name == 'nt': lib = os.path.join(self.with_mysql_capi, 'lib', 'libmysql.dll') connc_64bit = win_dll_is64bit(lib) # On OSX we check libmysqlclient.dylib elif 'macos' in platform: lib = os.path.join(self.with_mysql_capi, 'lib', 'libmysqlclient.dylib') connc_64bit = unix_lib_is64bit(lib) # On other Unices we check libmysqlclient (follow symlinks) elif os.name == 'posix': connc_64bit = unix_lib_is64bit(connc_loc) else: raise OSError("Unsupported platform: %s" % os.name) include_dir = os.path.join(connc_loc, 'include') if os.name == 'nt': libraries = ['libmysql'] else: libraries = ['-lmysqlclient'] library_dirs = os.path.join(connc_loc, 'lib') log.debug("# connc_64bit: {0}".format(connc_64bit)) if connc_64bit: self.arch = 'x86_64' else: self.arch = 'i386' # We were given the location of the mysql_config tool (not on Windows) if not os.name == 'nt' and os.path.isfile(connc_loc) \ and os.access(connc_loc, os.X_OK): mysql_config = connc_loc # Check mysql_config myc_info = get_mysql_config_info(mysql_config) log.debug("# myc_info: {0}".format(myc_info)) if myc_info['version'] < min_version: log.error(err_version) sys.exit(1) include_dir = myc_info['include'] libraries = myc_info['libs'] library_dirs = myc_info['lib_dir'] self._mysql_config_info = myc_info self.arch = self._mysql_config_info['arch'] connc_64bit = self.arch == 'x86_64' if not os.path.exists(include_dir): log.error(err_invalid_loc, connc_loc) sys.exit(1) # Set up the build_ext class self.include_dirs.append(include_dir) self.libraries.extend(libraries) self.library_dirs.append(library_dirs) # We try to offer a nice message when the architecture of Python # is not the same as MySQL Connector/C binaries. print("# self.arch: {0}".format(self.arch)) if ARCH_64BIT != connc_64bit: log.error("Python is {0}, but does not " "match MySQL C API {1} architecture, " "type: {2}" "".format(py_arch, '64-bit' if connc_64bit else '32-bit', self.arch)) sys.exit(1)
from ez_setup import use_setuptools use_setuptools( download_delay=8, to_dir=scramble_lib ) from setuptools import * import pkg_resources # get the tag if os.access( ".galaxy_tag", os.F_OK ): tagfile = open( ".galaxy_tag", "r" ) tag = tagfile.readline().strip() else: tag = None # LZO version is the same as this egg LZO_VERSION = "1.08" LZO_ARCHIVE = os.path.abspath( os.path.join( "..", "..", "..", "archives", "lzo-%s.tar.gz" %LZO_VERSION ) ) LZO_BINARY_ARCHIVE = os.path.abspath( os.path.join( "..", "..", "..", "archives", "lzo-%s-%s.tar.bz2" %( LZO_VERSION, pkg_resources.get_platform() ) ) ) # there's no need to have a completely separate build script for this if pkg_resources.get_platform() == "macosx-10.3-fat": CONFIGURE = "CFLAGS='-O -g -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc' " CONFIGURE += "LDFLAGS='-arch i386 -arch ppc' " CONFIGURE += "LD='gcc -mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -nostartfiles -arch i386 -arch ppc' " CONFIGURE += "./configure --prefix=%s/lzo --disable-shared --disable-dependency-tracking --enable-static" %os.getcwd() else: CONFIGURE = "CFLAGS='-fPIC' ./configure --prefix=%s/lzo --disable-shared --enable-static" %os.getcwd() # clean, in case you're running this by hand from a dirty module source dir for dir in [ "build", "dist", "lzo-%s" %LZO_VERSION ]: if os.access( dir, os.F_OK ): print "scramble_it.py: removing dir:", dir shutil.rmtree( dir )
#!/usr/bin/env python import os, sys assert sys.version_info[:2] >= ( 2, 4 ) lib = os.path.abspath( os.path.join( os.path.dirname( __file__ ), "..", "lib" ) ) sys.path.insert( 1, lib ) import galaxy import pkg_resources print pkg_resources.get_platform()
from ez_setup import use_setuptools use_setuptools( download_delay=8, to_dir=scramble_lib ) from setuptools import * import pkg_resources # get the tag if os.access( ".galaxy_tag", os.F_OK ): tagfile = open( ".galaxy_tag", "r" ) tag = tagfile.readline().strip() else: tag = None # globals MYSQL_VERSION = ( tag.split( "_" ) )[1] MYSQL_ARCHIVE = os.path.abspath( os.path.join( "..", "..", "..", "archives", "mysql-%s.tar.gz" %MYSQL_VERSION ) ) MYSQL_BINARY_ARCHIVE = os.path.abspath( os.path.join( "..", "..", "..", "archives", "mysql-%s-%s.tar.bz2" %( MYSQL_VERSION, pkg_resources.get_platform() ) ) ) # there's no need to have a completely separate build script for this if pkg_resources.get_platform() == "macosx-10.3-fat": CONFIGURE = "CFLAGS='-O -g -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc' " CONFIGURE += "CXXFLAGS='-O -g -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc' " CONFIGURE += "LDFLAGS='-arch i386 -arch ppc' " CONFIGURE += "LD='gcc -mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -nostartfiles -arch i386 -arch ppc' " CONFIGURE += "./configure --prefix=%s/mysql --disable-dependency-tracking --without-server --without-uca --without-libwrap " %os.getcwd() CONFIGURE += "--without-extra-tools --without-openssl --without-yassl --without-docs --without-man --without-bench --enable-thread-safe-client" else: CONFIGURE = "CFLAGS='-fPIC' ./configure --prefix=%s/mysql --disable-shared --without-server --without-uca --without-libwrap " %os.getcwd() CONFIGURE += "--without-extra-tools --without-openssl --without-yassl --without-docs --without-man --without-bench --enable-thread-safe-client" # clean, in case you're running this by hand from a dirty module source dir for dir in [ "build", "dist", "mysql-%s" %MYSQL_VERSION ]: if os.access( dir, os.F_OK ):