def test_finalize_options(self):
        pkg_dir, dist = self.create_dist()
        cmd = build(dist)
        cmd.finalize_options()

        # if not specified, plat_name gets the current platform
        self.assertEquals(cmd.plat_name, get_platform())

        # build_purelib is build + lib
        wanted = os.path.join(cmd.build_base, 'lib')
        self.assertEquals(cmd.build_purelib, wanted)

        # build_platlib is 'build/lib.platform-x.x[-pydebug]'
        # examples:
        #   build/lib.macosx-10.3-i386-2.7
        plat_spec = '.%s-%s' % (cmd.plat_name, sys.version[0:3])
        if hasattr(sys, 'gettotalrefcount'):
            self.assertTrue(cmd.build_platlib.endswith('-pydebug'))
            plat_spec += '-pydebug'
        wanted = os.path.join(cmd.build_base, 'lib' + plat_spec)
        self.assertEquals(cmd.build_platlib, wanted)

        # by default, build_lib = build_purelib
        self.assertEquals(cmd.build_lib, cmd.build_purelib)

        # build_temp is build/temp.<plat>
        wanted = os.path.join(cmd.build_base, 'temp' + plat_spec)
        self.assertEquals(cmd.build_temp, wanted)

        # build_scripts is build/scripts-x.x
        wanted = os.path.join(cmd.build_base, 'scripts-' +  sys.version[0:3])
        self.assertEquals(cmd.build_scripts, wanted)

        # executable is os.path.normpath(sys.executable)
        self.assertEquals(cmd.executable, os.path.normpath(sys.executable))
Example #2
0
File: setup.py Project: p0i0/Hazama
class MakePKGBUILD(Command):
    description = 'Generate PKGBUILD for archlinux'
    user_options = []
    template = """
# Maintainer: krrr <*****@*****.**>
pkgname=hazama
pkgver={ver}
pkgrel=1
pkgdesc="Diary application"
arch=('any')
url="https://krrr.github.io/hazama"
license=('GPL')
depends=('python' 'python-pyside')
makedepends=('python-setuptools' 'python-pyside-tools')
source=("https://github.com/krrr/Hazama/archive/v$pkgver.tar.gz")

build() {{
    cd "$srcdir/Hazama-$pkgver"
    ./setup.py build
}}

package() {{
    cd "$srcdir/Hazama-$pkgver"
    # --skip-build avoid building again when --root specified
    ./setup.py install --root "$pkgdir/" --skip-build
}}
"""

    initialize_options = finalize_options = lambda self: None

    def run(self):
        with open('PKGBUILD', 'w') as f:
            f.write(self.template.strip().format(ver=hazama.__version__))
            f.write('\n')
        os.system('makepkg -g >> PKGBUILD')
Example #3
0
    def run (self):

        """Run the regrtest module appropriately"""

        # figure out where the _ssl2 extension will be put
        b = build(self.distribution)
        b.initialize_options()
        b.finalize_options()
        extdir = os.path.abspath(b.build_platlib)

        # now set up the load path
        topdir = os.path.dirname(os.path.abspath(__file__))
        localtestdir = os.path.join(topdir, "test")
        sys.path.insert(0, topdir)        # for ssl package
        sys.path.insert(0, localtestdir)  # for test module
        sys.path.insert(0, extdir)        # for _ssl2 extension

        # make sure the network is enabled
        import test.test_support
        test.test_support.use_resources = ["network"]

        # and load the test and run it
        os.chdir(localtestdir)
        the_module = __import__("test_ssl", globals(), locals(), [])
        # Most tests run to completion simply as a side-effect of
        # being imported.  For the benefit of tests that can't run
        # that way (like test_threaded_import), explicitly invoke
        # their test_main() function (if it exists).
        indirect_test = getattr(the_module, "test_main", None)
        if indirect_test is not None:
            indirect_test()
Example #4
0
    def run(self):
        """Run the regrtest module appropriately"""

        # figure out where the _ssl2 extension will be put
        b = build(self.distribution)
        b.initialize_options()
        b.finalize_options()
        extdir = os.path.abspath(b.build_platlib)

        # now set up the load path
        topdir = os.path.dirname(os.path.abspath(__file__))
        localtestdir = os.path.join(topdir, "test")
        sys.path.insert(0, topdir)  # for ssl package
        sys.path.insert(0, localtestdir)  # for test module
        sys.path.insert(0, extdir)  # for _ssl2 extension

        # make sure the network is enabled
        import test.test_support
        test.test_support.use_resources = ["network"]

        # and load the test and run it
        os.chdir(localtestdir)
        the_module = __import__("test_ssl", globals(), locals(), [])
        # Most tests run to completion simply as a side-effect of
        # being imported.  For the benefit of tests that can't run
        # that way (like test_threaded_import), explicitly invoke
        # their test_main() function (if it exists).
        indirect_test = getattr(the_module, "test_main", None)
        if indirect_test is not None:
            indirect_test()
    def test_finalize_options(self):
        pkg_dir, dist = self.create_dist()
        cmd = build(dist)
        cmd.finalize_options()

        # if not specified, plat_name gets the current platform
        self.assertEquals(cmd.plat_name, get_platform())

        # build_purelib is build + lib
        wanted = os.path.join(cmd.build_base, 'lib')
        self.assertEquals(cmd.build_purelib, wanted)

        # build_platlib is 'build/lib.platform-x.x[-pydebug]'
        # examples:
        #   build/lib.macosx-10.3-i386-2.7
        plat_spec = '.%s-%s' % (cmd.plat_name, sys.version[0:3])
        if hasattr(sys, 'gettotalrefcount'):
            self.assertTrue(cmd.build_platlib.endswith('-pydebug'))
            plat_spec += '-pydebug'
        wanted = os.path.join(cmd.build_base, 'lib' + plat_spec)
        self.assertEquals(cmd.build_platlib, wanted)

        # by default, build_lib = build_purelib
        self.assertEquals(cmd.build_lib, cmd.build_purelib)

        # build_temp is build/temp.<plat>
        wanted = os.path.join(cmd.build_base, 'temp' + plat_spec)
        self.assertEquals(cmd.build_temp, wanted)

        # build_scripts is build/scripts-x.x
        wanted = os.path.join(cmd.build_base, 'scripts-' + sys.version[0:3])
        self.assertEquals(cmd.build_scripts, wanted)

        # executable is os.path.normpath(sys.executable)
        self.assertEquals(cmd.executable, os.path.normpath(sys.executable))
 def run(self):
     b = build(self.distribution)
     b.finalize_options()
     b.run()
     top_builddir = os.path.join(os.getcwd(), b.build_lib)
     cmd = 'DBUS_TOP_BUILDDIR="%s" test/run-test.sh' % top_builddir
     print cmd
     os.system(cmd)
 def run (self):
   b = build(self.distribution)
   b.finalize_options()
   b.run()
   top_builddir = os.path.join (os.getcwd(), b.build_lib) 
   cmd = 'DBUS_TOP_BUILDDIR="%s" test/run-test.sh'%top_builddir
   print cmd
   os.system (cmd)
Example #8
0
def get_service(request):
    storage = DjangoORMStorage(CredentialsModel, 'id', request.user, 'credential')
    credential = storage.get()
    if credential is None or credential.invalid:
        FLOW.params['state'] = xsrfutil.generate_token(settings.SECRET_KEY, request.user)
        authorize_url = FLOW.step1_get_authorize_url()
        return HttpResponseRedirect(authorize_url), False
    else:
        http = httplib2.Http()
        http = credential.authorize(http)
        service = build("calendar", "v3", http=http)
    return service, True
Example #9
0
    def initialize_options(self):

        self.dependencies = None
        self.authors = None
        self.create_workspace = None
        self.no_config = None
        self.force = None

        # use the build command to find build directories
        self.build = build(self.distribution)

        # parse config files
        self.cfg = configparser.ConfigParser()
        self.cfg.read(self.distribution.find_config_files())
Example #10
0
 def test_finalize_options(self):
     pkg_dir, dist = self.create_dist()
     cmd = build(dist)
     cmd.finalize_options()
     self.assertEqual(cmd.plat_name, get_platform())
     wanted = os.path.join(cmd.build_base, "lib")
     self.assertEqual(cmd.build_purelib, wanted)
     plat_spec = ".%s-%s" % (cmd.plat_name, sys.version[0:3])
     if hasattr(sys, "gettotalrefcount"):
         self.assertTrue(cmd.build_platlib.endswith("-pydebug"))
         plat_spec += "-pydebug"
     wanted = os.path.join(cmd.build_base, "lib" + plat_spec)
     self.assertEqual(cmd.build_platlib, wanted)
     self.assertEqual(cmd.build_lib, cmd.build_purelib)
     wanted = os.path.join(cmd.build_base, "temp" + plat_spec)
     self.assertEqual(cmd.build_temp, wanted)
     wanted = os.path.join(cmd.build_base, "scripts-" + sys.version[0:3])
     self.assertEqual(cmd.build_scripts, wanted)
     self.assertEqual(cmd.executable, os.path.normpath(sys.executable))
Example #11
0
 def test_finalize_options(self):
     pkg_dir, dist = self.create_dist()
     cmd = build(dist)
     cmd.finalize_options()
     self.assertEqual(cmd.plat_name, get_platform())
     wanted = os.path.join(cmd.build_base, 'lib')
     self.assertEqual(cmd.build_purelib, wanted)
     plat_spec = '.%s-%s' % (cmd.plat_name, sys.version[0:3])
     if hasattr(sys, 'gettotalrefcount'):
         self.assertTrue(cmd.build_platlib.endswith('-pydebug'))
         plat_spec += '-pydebug'
     wanted = os.path.join(cmd.build_base, 'lib' + plat_spec)
     self.assertEqual(cmd.build_platlib, wanted)
     self.assertEqual(cmd.build_lib, cmd.build_purelib)
     wanted = os.path.join(cmd.build_base, 'temp' + plat_spec)
     self.assertEqual(cmd.build_temp, wanted)
     wanted = os.path.join(cmd.build_base, 'scripts-' + sys.version[0:3])
     self.assertEqual(cmd.build_scripts, wanted)
     self.assertEqual(cmd.executable, os.path.normpath(sys.executable))
Example #12
0
 def test_finalize_options(self):
     pkg_dir, dist = self.create_dist()
     cmd = build(dist)
     cmd.finalize_options()
     self.assertEqual(cmd.plat_name, get_platform())
     wanted = os.path.join(cmd.build_base, 'lib')
     self.assertEqual(cmd.build_purelib, wanted)
     plat_spec = '.%s-%s' % (cmd.plat_name, sys.version[0:3])
     if hasattr(sys, 'gettotalrefcount'):
         self.assertTrue(cmd.build_platlib.endswith('-pydebug'))
         plat_spec += '-pydebug'
     wanted = os.path.join(cmd.build_base, 'lib' + plat_spec)
     self.assertEqual(cmd.build_platlib, wanted)
     self.assertEqual(cmd.build_lib, cmd.build_purelib)
     wanted = os.path.join(cmd.build_base, 'temp' + plat_spec)
     self.assertEqual(cmd.build_temp, wanted)
     wanted = os.path.join(cmd.build_base, 'scripts-' + sys.version[0:3])
     self.assertEqual(cmd.build_scripts, wanted)
     self.assertEqual(cmd.executable, os.path.normpath(sys.executable))
#!/usr/bin/env python
"""Run nosetests with build/lib.* in sys.path"""

# Fix up sys.path so as to include the correct build/lib.*/ directory.
import sys
from distutils.dist import Distribution
from distutils.command.build import build

build_cmd = build(Distribution({"ext_modules": True}))
build_cmd.finalize_options()
lib_dirn = build_cmd.build_lib
sys.path.insert(0, lib_dirn)

# Dump info plugin stuff
import nose
import logging
from nose.plugins import Plugin

logger = logging.getLogger("nose.plugins.pylibmc")

def dump_infos():
    logger.info("injected path: %s", lib_dirn)
    import pylibmc, _pylibmc
    if hasattr(_pylibmc, "__file__"):
        logger.info("loaded _pylibmc from %s", _pylibmc.__file__)
        if not _pylibmc.__file__.startswith(lib_dirn):
            logger.warn("double-check the source path")
    else:
        logger.warn("static _pylibmc: %s", _pylibmc)
    logger.info("libmemcached version: %s", _pylibmc.libmemcached_version)
    logger.info("pylibmc version: %s", _pylibmc.__version__)
Example #14
0
def build_lib_dirname():
    from distutils.dist import Distribution
    from distutils.command.build import build
    build_cmd = build(Distribution({"ext_modules": True}))
    build_cmd.finalize_options()
    return build_cmd.build_lib
Example #15
0
def build_lib_dirname():
    from distutils.dist import Distribution
    from distutils.command.build import build
    build_cmd = build(Distribution({"ext_modules": True}))
    build_cmd.finalize_options()
    return build_cmd.build_lib
Example #16
0
from os import getcwd
from os.path import join
from distutils.dist import Distribution
from distutils.command.build import build
b = build(Distribution())
b.finalize_options()
print(join(getcwd(), b.build_platlib))
Example #17
0
>>> bc = _pylibmc.client([test_server], binary=True)
>>> bc.set("\0\0", "ORMOD")
True
>>> bc.get_multi(["\0\0"])
{'\x00\x00': 'ORMOD'}
"""

# Used to test pickling.
class Foo(object): pass

# Fix up sys.path so as to include the correct build/lib.*/ directory.
import sys
from distutils.dist import Distribution
from distutils.command.build import build

build_cmd = build(Distribution({"ext_modules": True}))
build_cmd.finalize_options()
lib_dirn = build_cmd.build_lib
sys.path.insert(0, lib_dirn)

import pylibmc, _pylibmc
import socket

__doc__ = pylibmc.__doc__ + "\n\n" + __doc__

# {{{ Ported cmemcache tests
import unittest

class TestCmemcached(unittest.TestCase):
    def setUp(self):
        self.mc = pylibmc.Client(["%s:%d" % (test_server[1:])])
Example #18
0
        'Development Status :: 4 - Beta', 'Intended Audience :: Developers',
        'License :: OSI Approved :: BSD License',
        'Operating System :: OS Independent', 'Programming Language :: Python',
        'Programming Language :: Python :: 2.7',
        'Programming Language :: Python :: 3.5',
        'Programming Language :: Python :: 3.6',
        'Programming Language :: Python :: 3.7',
        'Programming Language :: Python :: 3.8',
        'Programming Language :: Python :: 3.9',
        'Programming Language :: Python :: 3.10',
        'Topic :: System :: Networking',
        'Topic :: System :: Networking :: Monitoring'
    ])

if platform == 'darwin':  # Newer Net-SNMP dylib may not be linked to properly
    b = build.build(dist.Distribution())  # Dynamically determine build path
    b.finalize_options()
    ext = sysconfig.get_config_var('EXT_SUFFIX') or '.so'  # None for Python 2
    linked = check_output(("otool -L {0}/easysnmp/interface{1} | "
                           r"egrep 'libnetsnmp\.' | "
                           "tr -s '\t' ' ' | "
                           "cut -d' ' -f2").format(b.build_platlib, ext),
                          shell=True).decode().strip()
    target_libs = check_output("find {0} -name libnetsnmp.*.dylib".format(
        ' '.join(libdirs)),
                               shell=True).decode().strip().split()
    prefix = check_output("net-snmp-config --prefix",
                          shell=True).decode().strip()
    for lib in target_libs:
        if prefix in lib:
            target_lib = lib