コード例 #1
0
def test_dist_fetch_build_egg(tmpdir):
    """
    Check multiple calls to `Distribution.fetch_build_egg` work as expected.
    """
    index = tmpdir.mkdir('index')
    index_url = urljoin('file://', pathname2url(str(index)))

    def sdist_with_index(distname, version):
        dist_dir = index.mkdir(distname)
        dist_sdist = '%s-%s.tar.gz' % (distname, version)
        make_nspkg_sdist(str(dist_dir.join(dist_sdist)), distname, version)
        with dist_dir.join('index.html').open('w') as fp:
            fp.write(
                DALS('''
                <!DOCTYPE html><html><body>
                <a href="{dist_sdist}" rel="internal">{dist_sdist}</a><br/>
                </body></html>
                ''').format(dist_sdist=dist_sdist))

    sdist_with_index('barbazquux', '3.2.0')
    sdist_with_index('barbazquux-runner', '2.11.1')
    with tmpdir.join('setup.cfg').open('w') as fp:
        fp.write(
            DALS('''
            [easy_install]
            index_url = {index_url}
            ''').format(index_url=index_url))
    reqs = '''
    barbazquux-runner
    barbazquux
    '''.split()
    with tmpdir.as_cwd():
        dist = Distribution()
        resolved_dists = [dist.fetch_build_egg(r) for r in reqs]
    assert [dist.key for dist in resolved_dists if dist] == reqs
コード例 #2
0
def build() -> None:
    # if running in RTD, skip compilation
    if os.environ.get("READTHEDOCS") == "True":
        return

    # compile FLI library
    os.system("cd lib && make && cd ..")

    extensions = [
        Extension(
            "pyobs_fli.flidriver",
            ["pyobs_fli/flidriver.pyx"],
            library_dirs=["lib/"],
            libraries=["fli", "cfitsio"],
            include_dirs=[numpy.get_include()],
            extra_compile_args=["-fPIC"],
        )
    ]
    ext_modules = cythonize(extensions)

    distribution = Distribution(
        {
            "name": "extended",
            "ext_modules": ext_modules,
            "cmdclass": {
                "build_ext": cython_build_ext,
            },
        }
    )

    distribution.run_command("build_ext")
    build_ext_cmd = distribution.get_command_obj("build_ext")
    build_ext_cmd.copy_extensions_to_source()
コード例 #3
0
ファイル: ptr.py プロジェクト: blue-yonder/pyscaffold
	def fetch_build_egg(self, req):
		""" Specialized version of Distribution.fetch_build_egg
		that respects respects allow_hosts and index_url. """
		from setuptools.command.easy_install import easy_install
		dist = Distribution({'script_args': ['easy_install']})
		dist.parse_config_files()
		opts = dist.get_option_dict('easy_install')
		keep = (
			'find_links', 'site_dirs', 'index_url', 'optimize',
			'site_dirs', 'allow_hosts'
		)
		for key in list(opts):
			if key not in keep:
				del opts[key]  # don't use any other settings
		if self.dependency_links:
			links = self.dependency_links[:]
			if 'find_links' in opts:
				links = opts['find_links'][1].split() + links
			opts['find_links'] = ('setup', links)
		if self.allow_hosts:
			opts['allow_hosts'] = ('test', self.allow_hosts)
		if self.index_url:
			opts['index_url'] = ('test', self.index_url)
		install_dir_func = getattr(self, 'get_egg_cache_dir', _os.getcwd)
		install_dir = install_dir_func()
		cmd = easy_install(
			dist, args=["x"], install_dir=install_dir,
			exclude_scripts=True,
			always_copy=False, build_directory=None, editable=False,
			upgrade=False, multi_version=True, no_report=True, user=False
		)
		cmd.ensure_finalized()
		return cmd.easy_install(req)
コード例 #4
0
 def __init__(self, attrs=None):
     self.vcpkg_root = None
     self.enable_boost_cmake = None
     self.cmake_options = None
     self.cmake_generator = None
     self.debug = False
     _distribution.__init__(self, attrs)
コード例 #5
0
ファイル: build.py プロジェクト: scoriiu/nautilus_trader
def _build_distribution(extensions: List[Extension]) -> Distribution:
    # Build a Distribution using cythonize()
    # Determine the build output directory
    if DEBUG_MODE:
        # For subsequent debugging, the C source needs to be in
        # the same tree as the Cython code (not in a separate build directory).
        build_dir = None
    elif ANNOTATION_MODE:
        build_dir = "build/annotated"
    else:
        build_dir = "build/optimized"

    distribution = Distribution(
        dict(
            name="nautilus_trader",
            ext_modules=cythonize(
                module_list=extensions,
                compiler_directives=CYTHON_COMPILER_DIRECTIVES,
                nthreads=os.cpu_count(),
                build_dir=build_dir,
                gdb_debug=DEBUG_MODE,
            ),
            zip_safe=False,
        )
    )
    distribution.package_dir = "nautilus_trader"
    return distribution
コード例 #6
0
ファイル: ptr.py プロジェクト: karishmabardoliya/flaskr
	def fetch_build_egg(self, req):
		""" Specialized version of Distribution.fetch_build_egg
		that respects respects allow_hosts and index_url. """
		from setuptools.command.easy_install import easy_install
		dist = Distribution({'script_args': ['easy_install']})
		dist.parse_config_files()
		opts = dist.get_option_dict('easy_install')
		keep = (
			'find_links', 'site_dirs', 'index_url', 'optimize',
			'site_dirs', 'allow_hosts'
		)
		for key in list(opts):
			if key not in keep:
				del opts[key]  # don't use any other settings
		if self.dependency_links:
			links = self.dependency_links[:]
			if 'find_links' in opts:
				links = opts['find_links'][1].split() + links
			opts['find_links'] = ('setup', links)
		if self.allow_hosts:
			opts['allow_hosts'] = ('test', self.allow_hosts)
		if self.index_url:
			opts['index_url'] = ('test', self.index_url)
		install_dir_func = getattr(self, 'get_egg_cache_dir', _os.getcwd)
		install_dir = install_dir_func()
		cmd = easy_install(
			dist, args=["x"], install_dir=install_dir,
			exclude_scripts=True,
			always_copy=False, build_directory=None, editable=False,
			upgrade=False, multi_version=True, no_report=True, user=False
		)
		cmd.ensure_finalized()
		return cmd.easy_install(req)
コード例 #7
0
ファイル: setup.py プロジェクト: segfaulthunter/pypentago
 def _include_misc(self, name, value):
     if name == 'entry_points':
         old = getattr(self, name)
         for (group, entries) in value.iteritems():
             self.entry_points.setdefault(group, list()).extend(entries)
     else:
         Distribution._include_misc(self, name, value)
コード例 #8
0
def self_upgrade():
    """Upgrade ourselves with pip."""

    # Run pip using the current python executable to accommodate for virtualenvs
    command = (
        [sys.executable]
        + ["-m", "pip"]
        + ["install", "MozPhab"]
        + ["--upgrade"]
        + ["--no-cache-dir"]
        + ["--disable-pip-version-check"]
    )

    if config.get_pre_releases:
        command += ["--pre"]

    # sys.path[0] is the directory containing the script that was used to
    # start python. This will be something like:
    # "<python environment>/bin" or "<python environment>\Scripts" (Windows)
    script_dir = Path(sys.path[0])

    # If moz-phab was installed with --user, we need to pass it to pip
    # Create "install" setuptools command with --user to find the scripts_path
    d = Distribution()
    d.parse_config_files()
    i = d.get_command_obj("install", create=True)
    # Forcing the environment detected by Distribution to the --user one
    i.user = True
    i.prefix = i.exec_prefix = i.home = i.install_base = i.install_platbase = None
    i.finalize_options()
    # Checking if the moz-phab script is installed in user's scripts directory
    user_dir = Path(i.install_scripts).resolve()
    if script_dir == user_dir:
        command.append("--user")

    if environment.IS_WINDOWS:
        # Windows does not allow to remove the exe file of the running process.
        # Renaming the `moz-phab.exe` file to allow pip to install a new version.
        temp_exe = script_dir / "moz-phab-temp.exe"
        try:
            temp_exe.unlink()
        except FileNotFoundError:
            pass

        exe = script_dir / "moz-phab.exe"
        exe.rename(temp_exe)

        try:
            check_call(command)
        except Exception:
            temp_exe.rename(exe)
            raise

        if not exe.is_file():
            # moz-phab.exe is not created - install wasn't needed.
            temp_exe.rename(exe)

    else:
        check_call(command)
コード例 #9
0
ファイル: setup.py プロジェクト: segfaulthunter/pypentago
 def _exclude_misc(self, name, value):
     if name == 'entry_points':
         old = getattr(self, name)
         for (group, entries) in value.iteritems():
             old_entries = set(self.entry_points.get(group, list()))
             self.entry_points[group] = list(old_entries - set(entries))
     else:
         Distribution._exclude_misc(self, name, value)
コード例 #10
0
ファイル: setup.py プロジェクト: jobovy/apogee
 def get_setuptools_script_dir():
     " Get the directory setuptools installs scripts to for current python "
     dist = Distribution({'cmdclass': {'install': OnlyGetScriptPath}})
     dist.dry_run = True  # not sure if necessary
     dist.parse_config_files()
     command = dist.get_command_obj('install')
     command.ensure_finalized()
     command.run()
     return dist.install_scripts
コード例 #11
0
 def get_install_lib(args):
     # This helper uses the distutils/setuptools machinery to determine
     # where a command will install files based on the arguments passed
     # to setup.py
     dist = Distribution({'script_args': args})
     dist.parse_command_line()
     install_cmd = dist.get_command_obj('install')
     install_cmd.ensure_finalized()
     return install_cmd.install_lib
コード例 #12
0
 def get_install_lib(args):
     # This helper uses the distutils/setuptools machinery to determine
     # where a command will install files based on the arguments passed
     # to setup.py
     dist = Distribution({'script_args': args})
     dist.parse_command_line()
     install_cmd = dist.get_command_obj('install')
     install_cmd.ensure_finalized()
     return install_cmd.install_lib
コード例 #13
0
ファイル: wheel.py プロジェクト: jsirois/pex
    def _convert_metadata(zf, destination_eggdir, dist_info, egg_info):
        def get_metadata(name):
            with zf.open(posixpath.join(dist_info, name)) as fp:
                value = fp.read().decode('utf-8') if PY3 else fp.read()
                return email.parser.Parser().parsestr(value)

        wheel_metadata = get_metadata('WHEEL')
        # Check wheel format version is supported.
        wheel_version = parse_version(wheel_metadata.get('Wheel-Version'))
        wheel_v1 = (
            parse_version('1.0') <= wheel_version < parse_version('2.0dev0')
        )
        if not wheel_v1:
            raise ValueError(
                'unsupported wheel format version: %s' % wheel_version)
        # Extract to target directory.
        os.mkdir(destination_eggdir)
        zf.extractall(destination_eggdir)
        # Convert metadata.
        dist_info = os.path.join(destination_eggdir, dist_info)
        dist = Distribution.from_location(
            destination_eggdir, dist_info,
            metadata=PathMetadata(destination_eggdir, dist_info),
        )

        # Note: Evaluate and strip markers now,
        # as it's difficult to convert back from the syntax:
        # foobar; "linux" in sys_platform and extra == 'test'
        def raw_req(req):
            req.marker = None
            return str(req)
        install_requires = list(sorted(map(raw_req, dist.requires())))
        extras_require = {
            extra: sorted(
                req
                for req in map(raw_req, dist.requires((extra,)))
                if req not in install_requires
            )
            for extra in dist.extras
        }
        os.rename(dist_info, egg_info)
        os.rename(
            os.path.join(egg_info, 'METADATA'),
            os.path.join(egg_info, 'PKG-INFO'),
        )
        setup_dist = SetuptoolsDistribution(
            attrs=dict(
                install_requires=install_requires,
                extras_require=extras_require,
            ),
        )
        write_requirements(
            setup_dist.get_command_obj('egg_info'),
            None,
            os.path.join(egg_info, 'requires.txt'),
        )
コード例 #14
0
ファイル: test_dist.py プロジェクト: luzpaz/setuptools
def test_check_specifier():
    # valid specifier value
    attrs = {'name': 'foo', 'python_requires': '>=3.0, !=3.1'}
    dist = Distribution(attrs)
    check_specifier(dist, attrs, attrs['python_requires'])

    # invalid specifier value
    attrs = {'name': 'foo', 'python_requires': ['>=3.0', '!=3.1']}
    with pytest.raises(DistutilsSetupError):
        dist = Distribution(attrs)
コード例 #15
0
ファイル: mpidistutils.py プロジェクト: mpi4py/mpi4py
 def __init__ (self, attrs=None):
     # support for pkg data
     self.package_data = {}
     # PEP 314
     self.provides = None
     self.requires = None
     self.obsoletes = None
     # supports 'executables' keyword
     self.executables = None
     cls_Distribution.__init__(self, attrs)
コード例 #16
0
ファイル: setup.py プロジェクト: lessc0de/pyq
    def finalize_options(self):
        self.cmdclass['config'] = config

        self.cmdclass['build'] = build
        self.cmdclass['build_exe'] = build_exe
        self.cmdclass['build_qk'] = build_qk
        self.cmdclass['build_ext'] = build_ext
        self.cmdclass['build_qext'] = build_qext

        self.cmdclass['install'] = install
        self.cmdclass['install_exe'] = install_exe
        self.cmdclass['install_qlib'] = install_qlib
        self.cmdclass['install_qext'] = install_qext

        self.cmdclass['test'] = PyTest

        if 'QHOME' in os.environ:
            self.qhome = os.getenv('QHOME')
        else:
            qhome_root = os.getenv(
                'SystemDrive') + '\\' if platform == 'Windows' else os.getenv(
                    'HOME')
            self.qhome = os.path.join(qhome_root, 'q')
            if 'VIRTUAL_ENV' in os.environ:
                path = os.path.join(os.getenv('VIRTUAL_ENV'), 'q')
                if os.path.exists(path):
                    self.qhome = path

        bits = BITS
        if platform == 'Linux':
            o = 'l'
        elif platform == 'SunOS':
            o = 'v' if uname()[-1] == 'i86pc' else 's'
        elif platform == 'Darwin':
            o = 'm'
            bits = 32
        elif platform == 'Windows':
            o = 'w'
            bits = 32  # FIXME: We test with 32-bit kdb+ on Windows, so forcing 32-bit version.
        else:
            sys.stderr.write("Unknown platform: %s\n" % str(platform))
            sys.exit(1)
        self.qarch = "%s%d" % (o, bits)
        self.install_data = os.path.join(self.qhome, self.qarch)
        self.kxver = self.get_kxver(self.qhome)
        self.qexecutable = os.path.join(self.qhome, self.qarch, 'q')
        _Distribution.finalize_options(self)
        for ext in self.ext_modules + self.qext_modules:
            ext.define_macros.append(('KXVER', self.kxver.split('.')[0]))
            ext.define_macros.append(('QVER', self.kxver.split('.')[0]))
            if sys.hexversion >= 0x3000000:
                ext.define_macros.append(
                    ('PY3K', "%s%s" % sys.version_info[:2]))
        for exe in self.executables:
            exe.define_macros.append(('QARCH', self.qarch))
コード例 #17
0
    def test_distribution_files_additional_files():
        """
        Test setup.py and tests discovery.
        """
        dist = Distribution()
        with change_dir(os.path.join(TEST_PATH, "..")):
            dist.packages = find_packages()
            files = FormatCommand(dist).distribution_files()

            # Ensure data is appended to fake_package
            assert set(files) == {"setup.py", "setuptools_black", "tests"}
コード例 #18
0
 def __init__(self, attrs=None):
     self.translations = []
     Distribution.__init__(self, attrs)
     self.cmdclass = {
         'install_mo' : install_mo,
         'build_mo' : build_mo,
         # 'build_conf' : build_conf,
         'build_ext': BuildExt,
         'build_scripts': build_scripts_app,
         }
     self.command_obj['build_scripts'] = None
コード例 #19
0
ファイル: mydistutils.py プロジェクト: Ichag/openerp-client
 def __init__(self, attrs=None):
     self.translations = []
     Distribution.__init__(self, attrs)
     self.cmdclass = {
         'install_mo' : install_mo,
         'build_mo' : build_mo,
         # 'build_conf' : build_conf,
         'build_ext': BuildExt,
         'build_scripts': build_scripts_app,
         }
     self.command_obj['build_scripts'] = None
コード例 #20
0
ファイル: test_dist.py プロジェクト: luzpaz/setuptools
def test_provides_extras_deterministic_order():
    extras = collections.OrderedDict()
    extras['a'] = ['foo']
    extras['b'] = ['bar']
    attrs = dict(extras_require=extras)
    dist = Distribution(attrs)
    assert dist.metadata.provides_extras == ['a', 'b']
    attrs['extras_require'] = collections.OrderedDict(
        reversed(list(attrs['extras_require'].items())))
    dist = Distribution(attrs)
    assert dist.metadata.provides_extras == ['b', 'a']
コード例 #21
0
    def test_distribution_files_package_dir():
        """
        Test packages collection when pacakge_dir is used to get packages from sub-directory.
        """
        dist = Distribution()
        with change_dir(TEST_PATH):
            dist.packages = find_packages("data")
            dist.package_dir = {"": "data"}
            files = FormatCommand(dist).distribution_files()

            # Ensure data is appended to fake_package
            assert list(files) == [os.path.join("data", "fake_package")]
コード例 #22
0
def read_setuptools_cfg():
    """
    Reads the `setup.cfg` file and extracts the various requirements lists
    """
    # see https://stackoverflow.com/a/30679041/7262247
    from setuptools import Distribution
    dist = Distribution()
    dist.parse_config_files()
    return SetupCfg(setup_requires=dist.setup_requires,
                    install_requires=dist.install_requires,
                    tests_requires=dist.tests_require,
                    extras_require=dist.extras_require)
コード例 #23
0
ファイル: wheel.py プロジェクト: fariasjr/CitiTuirer
    def _convert_metadata(zf, destination_eggdir, dist_info, egg_info):
        def get_metadata(name):
            with zf.open(posixpath.join(dist_info, name)) as fp:
                value = fp.read().decode('utf-8') if PY3 else fp.read()
                return email.parser.Parser().parsestr(value)

        wheel_metadata = get_metadata('WHEEL')
        # Check wheel format version is supported.
        wheel_version = parse_version(wheel_metadata.get('Wheel-Version'))
        wheel_v1 = (parse_version('1.0') <= wheel_version <
                    parse_version('2.0dev0'))
        if not wheel_v1:
            raise ValueError('unsupported wheel format version: %s' %
                             wheel_version)
        # Extract to target directory.
        os.mkdir(destination_eggdir)
        zf.extractall(destination_eggdir)
        # Convert metadata.
        dist_info = os.path.join(destination_eggdir, dist_info)
        dist = Distribution.from_location(
            destination_eggdir,
            dist_info,
            metadata=PathMetadata(destination_eggdir, dist_info),
        )

        # Note: Evaluate and strip markers now,
        # as it's difficult to convert back from the syntax:
        # foobar; "linux" in sys_platform and extra == 'test'
        def raw_req(req):
            req.marker = None
            return str(req)

        install_requires = list(sorted(map(raw_req, dist.requires())))
        extras_require = {
            extra: sorted(req for req in map(raw_req, dist.requires((extra, )))
                          if req not in install_requires)
            for extra in dist.extras
        }
        os.rename(dist_info, egg_info)
        os.rename(
            os.path.join(egg_info, 'METADATA'),
            os.path.join(egg_info, 'PKG-INFO'),
        )
        setup_dist = SetuptoolsDistribution(attrs=dict(
            install_requires=install_requires,
            extras_require=extras_require,
        ), )
        write_requirements(
            setup_dist.get_command_obj('egg_info'),
            None,
            os.path.join(egg_info, 'requires.txt'),
        )
コード例 #24
0
 def test_run(format_mock: mock.Mock, build_mock: mock.Mock):
     """Ensure both format and normal build are called in sequence."""
     dist = Distribution()
     # Simulate setup.py registration
     dist.cmdclass = {
         "format": setuptools_black.setuptools_command.FormatCommand,
     }
     build_command = BuildCommand(dist)
     build_command.run()
     # Format run once, in check-only mode
     format_mock.return_value.run.assert_called_once_with()
     assert format_mock.return_value.check is True
     # Build run once, in check-only mode
     build_mock.run.assert_called_once_with(build_command)
コード例 #25
0
ファイル: test_plugin.py プロジェクト: kingking888/scrapydd
def build_sample_plugin():
    plugin_src_dir = os.path.join(os.path.dirname(__file__),
                                  '../../samples/scrapy-splitvariants-plugin')
    with cd(plugin_src_dir):
        if os.path.exists('dist'):
            shutil.rmtree('dist')
        d = Distribution(
            dict(
                version='1.0',
                name='scrapy_splitvariants_plugin',
                description='scrapy_splitvariants_plugin',
                packages=find_packages(exclude=['tests', 'tests.*']),
                entry_points={
                    'scrapydd.spliderplugin': [
                        'splitvariants = scrapy_splitvariants_plugin.plugin:Plugin',
                    ],
                },
                install_requires=['scrapy', 'scrapy-splitvariants'],
                zip_safe=True,
            ))
        d.script_name = 'setup.py'
        d.script_args = ['--quiet', 'clean', 'bdist_egg']
        d.parse_command_line()
        d.run_commands()

        egg_name = os.listdir('dist')[0]
        return os.path.abspath(os.path.join('dist', egg_name))
コード例 #26
0
ファイル: setup.py プロジェクト: vineeth-s/pomoxis
def get_setuptools_script_dir():
    # Run the above class just to get paths
    dist = Distribution({'cmdclass': {'install': GetPaths}})
    dist.dry_run = True
    dist.parse_config_files()
    command = dist.get_command_obj('install')
    command.ensure_finalized()
    command.run()

    src_dir = glob(os.path.join(dist.install_libbase, 'pomoxis-*', 'exes'))[0]
    for exe in (os.path.join(src_dir, x) for x in os.listdir(src_dir)):
        print("Copying", os.path.basename(exe), '->', dist.install_scripts)
        shutil.copy(exe, dist.install_scripts)
    return dist.install_libbase, dist.install_scripts
コード例 #27
0
 def test_run_invalid_format(run_mock: mock.Mock):
     """Simulate error return from black on invalid format."""
     dist = Distribution()
     run_mock.side_effect = subprocess.CalledProcessError(returncode=1,
                                                          cmd="black")
     with pytest.raises(distutils.errors.DistutilsError):
         FormatCommand(dist).run()
コード例 #28
0
    def run_command(self, command):
        '''Builds the documentation if needed, then passes control to
        the superclass' run_command(...) method.
        '''

        if command == 'install_data' and docutils:
            print 'creating doc/index.html'
            docutils.core.publish_file(writer_name='html',
                    source=open('doc/index.rst'),
                    source_path='doc',
                    destination=open('doc/index.html', 'w'),
                    destination_path='doc',
                    settings_overrides={'stylesheet_path':
                        'doc/documentation.css'}
            )
        Distribution.run_command(self, command)
コード例 #29
0
ファイル: test_dist.py プロジェクト: luzpaz/setuptools
def test_read_metadata(name, attrs):
    dist = Distribution(attrs)
    metadata_out = dist.metadata
    dist_class = metadata_out.__class__

    # Write to PKG_INFO and then load into a new metadata object
    PKG_INFO = io.StringIO()

    metadata_out.write_pkg_file(PKG_INFO)

    PKG_INFO.seek(0)
    metadata_in = dist_class()
    metadata_in.read_pkg_file(PKG_INFO)

    tested_attrs = [
        ('name', dist_class.get_name),
        ('version', dist_class.get_version),
        ('author', dist_class.get_contact),
        ('author_email', dist_class.get_contact_email),
        ('metadata_version', dist_class.get_metadata_version),
        ('provides', dist_class.get_provides),
        ('description', dist_class.get_description),
        ('long_description', dist_class.get_long_description),
        ('download_url', dist_class.get_download_url),
        ('keywords', dist_class.get_keywords),
        ('platforms', dist_class.get_platforms),
        ('obsoletes', dist_class.get_obsoletes),
        ('requires', dist_class.get_requires),
        ('classifiers', dist_class.get_classifiers),
        ('project_urls', lambda s: getattr(s, 'project_urls', {})),
        ('provides_extras', lambda s: getattr(s, 'provides_extras', set())),
    ]

    for attr, getter in tested_attrs:
        assert getter(metadata_in) == getter(metadata_out)
コード例 #30
0
ファイル: test_dist.py プロジェクト: fluiddyn/transonic
def test_build_ext():
    dist = Distribution()
    build_ext = ParallelBuildExt(dist)

    build_ext.initialize_options()
    build_ext.parallel = 1
    build_ext.finalize_options()
コード例 #31
0
    def test_run_check(run_mock: mock.Mock):
        """
        Test check-only run.
        """
        dist = Distribution()
        with change_dir(TEST_PATH):
            dist.packages = find_packages("data")
            command = FormatCommand(dist)
            command.check = True
            command.run()

        run_mock.assert_called_with(
            [sys.executable, "-m", "black", "--check", "fake_package"],
            check=True,
            env=mock.ANY,
        )
コード例 #32
0
    def test_run(run_mock: mock.Mock):
        """
        Test basic usage, only relying on find_packages to fill setup packages,
        with no setup.py nor tests.
        """
        dist = Distribution()
        # Switch to fake project's root
        with change_dir(TEST_PATH):
            dist.packages = find_packages("data")
            FormatCommand(dist).run()

        run_mock.assert_called_with(
            [sys.executable, "-m", "black", "fake_package"],
            check=True,
            env=mock.ANY,
        )
コード例 #33
0
def test_maintainer_author(name, attrs):
    tested_keys = {
        'author': 'Author',
        'author_email': 'Author-email',
        'maintainer': 'Maintainer',
        'maintainer_email': 'Maintainer-email',
    }

    # Generate a PKG-INFO file
    dist = Distribution(attrs)
    PKG_INFO = StringIO()
    dist.metadata.write_pkg_file(PKG_INFO)
    PKG_INFO.seek(0)

    pkg_lines = PKG_INFO.readlines()
    pkg_lines = [_ for _ in pkg_lines if _]  # Drop blank lines
    pkg_lines_set = set(pkg_lines)

    # Duplicate lines should not be generated
    assert len(pkg_lines) == len(pkg_lines_set)

    for fkey, dkey in tested_keys.items():
        val = attrs.get(dkey, None)
        if val is None:
            for line in pkg_lines:
                assert not line.startswith(fkey + ':')
        else:
            line = '%s: %s' % (fkey, val)
            assert line in pkg_lines_set
コード例 #34
0
def test_maintainer_author(name, attrs, tmpdir):
    tested_keys = {
        'author': 'Author',
        'author_email': 'Author-email',
        'maintainer': 'Maintainer',
        'maintainer_email': 'Maintainer-email',
    }

    # Generate a PKG-INFO file
    dist = Distribution(attrs)
    fn = tmpdir.mkdir('pkg_info')
    fn_s = str(fn)

    dist.metadata.write_pkg_info(fn_s)

    with io.open(str(fn.join('PKG-INFO')), 'r', encoding='utf-8') as f:
        raw_pkg_lines = f.readlines()

    # Drop blank lines
    pkg_lines = list(filter(None, raw_pkg_lines))

    pkg_lines_set = set(pkg_lines)

    # Duplicate lines should not be generated
    assert len(pkg_lines) == len(pkg_lines_set)

    for fkey, dkey in tested_keys.items():
        val = attrs.get(dkey, None)
        if val is None:
            for line in pkg_lines:
                assert not line.startswith(fkey + ':')
        else:
            line = '%s: %s' % (fkey, val)
            assert line in pkg_lines_set
コード例 #35
0
    def setUp(self):  # suppress(N802)
        """Create a temporary directory and put some files in it."""
        super(TestPolysquareLintCommand, self).setUp()
        os.environ["JOBSTAMPS_DISABLED"] = "1"
        self._previous_directory = os.getcwd()

        project_directory = mkdtemp(
            prefix=os.path.join(os.getcwd(), "test_project_dir"))
        os.chdir(project_directory)

        def cleanup_func():
            """Change into the previous dir and remove the project dir."""
            os.chdir(self._previous_directory)
            shutil.rmtree(project_directory)

        self.addCleanup(cleanup_func)
        self.patch(polysquare_setuptools_lint, "sys_exit", Mock())

        with self._open_test_file():
            pass

        with self._open_module_file():
            pass

        with self._open_setup_file() as f:
            # Write a very basic /setup.py file so that pyroma doesn't trip
            # and throw an exception.
            f.write("from setuptools import setup\n" "setup()\n")

        self._distribution = Distribution(
            dict(name="my-package",
                 version="0.0.1",
                 packages=fp(exclude=["test"])))
コード例 #36
0
ファイル: setup.py プロジェクト: rsms/smisk
	def __init__(self, attrs=None):
		Distribution.__init__(self, attrs)
		self.cmdclass = {
			'build': build,
			'build_ext': build_ext,
			'sdist': sdist,
			'config': config,
			'docs': sphinx_build,
			'clean': clean,
		}
		try:
			shell_cmd('which dpkg-buildpackage')
			self.cmdclass['debian'] = debian
		except IOError:
			# Not a debian system or dpkg-buildpackage not installed
			pass
コード例 #37
0
ファイル: dist.py プロジェクト: Web5design/Bento
 def get_command_class(self, command):
     # Better raising an error than having some weird behavior for a command
     # we don't support
     if self.script_args is not None \
        and command in self.script_args \
        and command not in _BENTO_MONKEYED_CLASSES:
         raise ValueError("Command %s is not supported by bento.distutils compat layer" % command)
     return Distribution.get_command_class(self, command)
コード例 #38
0
def _test_process_docstring(lines, obj_in_package):
    t = build_sphinx.build_sphinx(Distribution())
    originals = lines[:]

    with patch.object(t, "_obj_in_package", return_value=obj_in_package):
        t._process_docstring("foo", lines)

    return originals
コード例 #39
0
ファイル: dist.py プロジェクト: cournape/toydist
    def __init__(self, attrs=None):
        if attrs is None:
            attrs = {}

        attrs = _setup_cmd_classes(attrs)

        self.package = PackageDescription.from_yaml("setup.yaml")

        attrs.update({
            "name": self.package.name,
            "version": str(self.package.version),
            "long_description": self.package.description,
            "description": self.package.summary,
            "packages": self.package.packages,
        })

        OldDistribution.__init__(self, attrs)
コード例 #40
0
 def get_command_class(self, command):
     # Better raising an error than having some weird behavior for a command
     # we don't support
     if self.script_args is not None \
        and command in self.script_args \
        and command not in _BENTO_MONKEYED_CLASSES:
         raise ValueError("Command %s is not supported by bento.distutils compat layer" % command)
     return Distribution.get_command_class(self, command)
コード例 #41
0
    def run_command(self, command):
        '''Builds the documentation if needed, then passes control to
        the superclass' run_command(...) method.
        '''

        if command == 'install_data' and docutils:
            print 'creating doc/index.html'
            docutils.core.publish_file(writer_name='html',
                                       source=open('doc/index.rst'),
                                       source_path='doc',
                                       destination=open('doc/index.html', 'w'),
                                       destination_path='doc',
                                       settings_overrides={
                                           'stylesheet_path':
                                           'doc/documentation.css'
                                       })
        Distribution.run_command(self, command)
コード例 #42
0
ファイル: setupext.py プロジェクト: anntzer/dlsym
def _prepare_build_ext(kwargs):
    cmdclass = kwargs.setdefault("cmdclass", {})
    get = Distribution({"cmdclass": cmdclass}).get_command_class
    cmdclass["build_ext"] = type("build_ext_with_extensions",
                                 (_build_ext_mixin, get("build_ext")), {})
    if _build_ext_mixin._ext_gens:
        # Don't tag wheels as dist-specific if no extension.
        kwargs.setdefault("ext_modules", [Extension("", [])])
コード例 #43
0
ファイル: setup.py プロジェクト: zjc5415/pyq
    def finalize_options(self):
        self.cmdclass['config'] = config

        self.cmdclass['build'] = build
        self.cmdclass['build_exe'] = build_exe
        self.cmdclass['build_qk'] = build_qk
        self.cmdclass['build_ext'] = build_ext
        self.cmdclass['build_qext'] = build_qext

        self.cmdclass['install'] = install
        self.cmdclass['install_exe'] = install_exe
        self.cmdclass['install_qlib'] = install_qlib
        self.cmdclass['install_qext'] = install_qext

        self.cmdclass['test'] = PyTest

        default_qhome_root = os.getenv('SystemDrive') + '\\' if platform == 'Windows' else os.getenv('HOME')
        self.qhome = os.getenv('QHOME') or os.path.join(default_qhome_root, 'q')

        bits = BITS
        if platform == 'Linux':
            o = 'l'
        elif platform == 'SunOS':
            o = 'v' if uname()[-1] == 'i86pc' else 's'
        elif platform == 'Darwin':
            o = 'm'
            bits = 32
        elif platform == 'Windows':
            o = 'w'
            bits = 32  # FIXME: We test with 32-bit kdb+ on Windows, so forcing 32-bit version.
        else:
            sys.stderr.write("Unknown platform: %s\n" % str(platform))
            sys.exit(1)
        self.qarch = "%s%d" % (o, bits)
        self.install_data = os.path.join(self.qhome, self.qarch)
        self.kxver = self.get_kxver(self.qhome)
        self.qexecutable = os.path.join(self.qhome, self.qarch, 'q')
        _Distribution.finalize_options(self)
        for ext in self.ext_modules + self.qext_modules:
            ext.define_macros.append(('KXVER', self.kxver.split('.')[0]))
            ext.define_macros.append(('QVER', self.kxver.split('.')[0]))
            if sys.hexversion >= 0x3000000:
                ext.define_macros.append(('PY3K', "%s%s" % sys.version_info[:2]))
コード例 #44
0
ファイル: ah_bootstrap.py プロジェクト: astrofrog/sphere
 def get_option_dict(self, command_name):
     opts = Distribution.get_option_dict(self, command_name)
     if command_name == 'easy_install':
         if find_links is not None:
             opts['find_links'] = ('setup script', find_links)
         if index_url is not None:
             opts['index_url'] = ('setup script', index_url)
         if allow_hosts is not None:
             opts['allow_hosts'] = ('setup script', allow_hosts)
     return opts
コード例 #45
0
ファイル: test_dist.py プロジェクト: benoit-pierre/setuptools
def test_dist_fetch_build_egg(tmpdir):
    """
    Check multiple calls to `Distribution.fetch_build_egg` work as expected.
    """
    index = tmpdir.mkdir('index')
    index_url = urljoin('file://', pathname2url(str(index)))

    def sdist_with_index(distname, version):
        dist_dir = index.mkdir(distname)
        dist_sdist = '%s-%s.tar.gz' % (distname, version)
        make_nspkg_sdist(str(dist_dir.join(dist_sdist)), distname, version)
        with dist_dir.join('index.html').open('w') as fp:
            fp.write(DALS(
                '''
                <!DOCTYPE html><html><body>
                <a href="{dist_sdist}" rel="internal">{dist_sdist}</a><br/>
                </body></html>
                '''
            ).format(dist_sdist=dist_sdist))
    sdist_with_index('barbazquux', '3.2.0')
    sdist_with_index('barbazquux-runner', '2.11.1')
    with tmpdir.join('setup.cfg').open('w') as fp:
        fp.write(DALS(
            '''
            [easy_install]
            index_url = {index_url}
            '''
        ).format(index_url=index_url))
    reqs = '''
    barbazquux-runner
    barbazquux
    '''.split()
    with tmpdir.as_cwd():
        dist = Distribution()
        dist.parse_config_files()
        resolved_dists = [
            dist.fetch_build_egg(r)
            for r in reqs
        ]
    assert [dist.key for dist in resolved_dists if dist] == reqs
コード例 #46
0
ファイル: dist.py プロジェクト: pberkes/Bento
    def __init__(self, attrs=None):
        if attrs is None:
            attrs = {}

        if not "bento_info" in attrs:
            bento_info = "bento.info"
        else:
            bento_info = attrs["bento.info"]
        self.pkg = PackageDescription.from_file(bento_info)
        self.package_options = PackageOptions.from_file(bento_info)


        attrs = _setup_cmd_classes(attrs)

        d = pkg_to_distutils_meta(self.pkg)
        attrs.update(d)

        Distribution.__init__(self, attrs)

        self.packages = self.pkg.packages
        self.py_modules = self.pkg.py_modules
        if hasattr(self, "entry_points"):
            if self.entry_points is None:
                self.entry_points = {}
            console_scripts = [e.full_representation() for e in self.pkg.executables.values()]
            if "console_scripts" in self.entry_points:
                self.entry_points["console_scripts"].extend(console_scripts)
            else:
                self.entry_points["console_scripts"] = console_scripts

        source_root = os.getcwd()
        build_root = os.path.join(source_root, "build")
        root = create_root_with_source_tree(source_root, build_root)
        self.top_node = root._ctx.srcnode
        self.build_node = root._ctx.bldnode
        self.run_node = root._ctx.srcnode

        self.global_context = global_context_factory(self.package_options)
        modules = set_main(self.top_node, self.build_node, self.pkg)
コード例 #47
0
ファイル: setup.py プロジェクト: e42s/pyq
    def finalize_options(self):
        self.cmdclass['config'] = config

        self.cmdclass['build'] = build
        self.cmdclass['build_exe'] = build_exe
        self.cmdclass['build_qk'] = build_qk
        self.cmdclass['build_ext'] = build_ext
        self.cmdclass['build_qext'] = build_qext

        self.cmdclass['install'] = install
        self.cmdclass['install_exe'] = install_exe
        self.cmdclass['install_qlib'] = install_qlib
        self.cmdclass['install_qext'] = install_qext

        self.cmdclass['test'] = PyTest

        self.qhome = os.getenv('QHOME') or os.path.join(os.getenv('HOME'), 'q')
        bits = 8 * get_config_var('SIZEOF_VOID_P')
        u = os.uname()
        if u[0] == 'Linux':
            o = 'l'
        elif u[0] == 'SunOS':
            o = 'v' if u[-1] == 'i86pc' else 's'
        elif u[0] == 'Darwin':
            o = 'm'
            bits = 32
        else:
            sys.stderr.write("Unknown platform: %s\n" % str(u))
            sys.exit(1)
        self.qarch = "%s%d" % (o, bits)
        self.install_data = os.path.join(self.qhome, self.qarch)
        self.kxver = self.get_kxver(self.qhome)
        self.qexecutable = os.path.join(self.qhome, self.qarch, 'q')
        _Distribution.finalize_options(self)
        for ext in self.ext_modules + self.qext_modules:
            ext.define_macros.append(('KXVER', self.kxver.split('.')[0]))
            ext.define_macros.append(('QVER', self.kxver.split('.')[0]))
            if sys.hexversion >= 0x3000000:
                ext.define_macros.append(('PY3K', "%s%s" % sys.version_info[:2]))
コード例 #48
0
def ensure_sphinx_astropy_installed():
    """
    Make sure that sphinx-astropy is available, installing it temporarily if not.

    This returns the available version of sphinx-astropy as well as any
    paths that should be added to sys.path for sphinx-astropy to be available.
    """
    # We've split out the Sphinx part of astropy-helpers into sphinx-astropy
    # but we want it to be auto-installed seamlessly for anyone using
    # build_docs. We check if it's already installed, and if not, we install
    # it to a local .eggs directory and add the eggs to the path (these
    # have to each be added to the path, we can't add them by simply adding
    # .eggs to the path)
    sys_path_inserts = []
    sphinx_astropy_version = None
    try:
        from sphinx_astropy import __version__ as sphinx_astropy_version  # noqa
    except ImportError:

        from setuptools import Distribution
        dist = Distribution()
        eggs = dist.fetch_build_eggs('sphinx-astropy')

        # Find out the version of sphinx-astropy if possible. For some old
        # setuptools version, eggs will be None even if sphinx-astropy was
        # successfully installed.
        if eggs is not None:
            for egg in eggs:
                if egg.project_name == 'sphinx-astropy':
                    sphinx_astropy_version = egg.parsed_version.public
                    break

        eggs_path = os.path.abspath('.eggs')
        for egg in glob.glob(os.path.join(eggs_path, '*.egg')):
            sys_path_inserts.append(egg)

    return sphinx_astropy_version, sys_path_inserts
コード例 #49
0
ファイル: setup.py プロジェクト: uggla/python-redfish
    def getprefix(self):
        '''Retrieve setup tool calculated prefix

        :returns: prefix
        :rtype: string
        '''
        dist = Distribution({'cmdclass': {'install': OnlyGetScriptPath}})
        dist.dry_run = True  # not sure if necessary, but to be safe
        dist.parse_config_files()
        try:
            dist.parse_command_line()
        except (distutils.errors.DistutilsArgError, AttributeError):
            pass
        command = dist.get_command_obj('install')
        command.ensure_finalized()
        command.run()
        prefix = dist.install_scripts.replace('/bin', '')
        return prefix
コード例 #50
0
ファイル: setup.py プロジェクト: Eigenstate/vmd-python
 def __init__(self, *args, **kwargs):
     self.egl = False
     self.debug = False
     Distribution.__init__(self, *args, **kwargs)
コード例 #51
0
ファイル: runtests.py プロジェクト: NunoEdgarGub1/pkglib
def main(argv=None, **kw):
    """ Run a test package's tests.
    """
    # TODO: allow cmdline override of org config?
    config.setup_org_config()

    from path import path

    USAGE = """\
usage: %(script)s <package name> [test options]
   or: %(script)s --help
""" % {'script': sys.argv[0] or 'runtests'}

    if argv is None:
        argv = sys.argv[1:]

    if not argv:
        print "Please specify a package name."
        print USAGE
        sys.exit(1)

    pkg_name, argv = argv[0], argv[1:]
    test_pkg_name = 'test.%s' % pkg_name

    # Find our
    real_dist = [i for i in working_set if i.project_name == pkg_name]
    if not real_dist:
        print "Package %s is not installed" % pkg_name
        sys.exit(1)
    real_dist = real_dist[0]

    test_dist = [i for i in working_set if i.project_name == test_pkg_name]
    if not test_dist:
        print "Test package %s is not installed" % test_pkg_name
        sys.exit(1)
    test_dist = test_dist[0]

    # Construct a distutils.Distribtion class from the pkg_resources.Distribution
    # of the real package so we can pass it into the test command class.
    # We have checked that the packages are already installed so we set the install
    # requirements to blank.

    args = {'name': real_dist.project_name,
            'install_requires': [],
            'tests_require': [],
            'namespace_packages': list(real_dist._get_metadata('namespace_packages')),
            'packages': [real_dist.project_name],
            }
    real_cmd_dist = Distribution(args)
    cmd = test(real_cmd_dist)
    cmd.args = argv

    # Read in the test options saved away during egg_info and set the command defaults,
    # this would normally be done by the setup() method via the Distribution class
    test_options = path(test_dist.location) / 'EGG-INFO' / 'test_options.txt'
    if test_options.isfile():
        real_cmd_dist.parse_config_files([test_options])
    for k, v in real_cmd_dist.get_option_dict('test').items():
        print "Found test option in %s: %s = %s" % (v[0], k, v[1])
        setattr(cmd, k, v[1])

    # Finalize and run the command, overriding the test root to be inside the test egg
    cmd.finalize_options()
    cmd.test_root = path(test_dist.location) / CONFIG.test_egg_namespace / \
                         real_dist.project_name.replace('.', '/')
    # Pylint is only for regular Jenkins jobs, this in itself should not trigger even if
    # running under Jenkins
    cmd.no_pylint = True
    cmd.run()
コード例 #52
0
ファイル: setup.py プロジェクト: JohnLangford/vowpal_wabbit
 def __init__(self, attrs=None):
     self.vcpkg_root = None
     _distribution.__init__(self, attrs)
コード例 #53
0
ファイル: setup.py プロジェクト: Feng2012/PTVS
 def find_config_files(self):
     configs = Distribution.find_config_files(self)
     configs.append("setup.py3.cfg" if running_python3 else "setup.py2.cfg")
     return configs
コード例 #54
0
ファイル: setup.py プロジェクト: data-exp-lab/pyrobuf
 def run_commands(self):
     # By now the setup_requires deps have been fetched.
     if not self.ext_modules:
         self.ext_modules = list()
     self.ext_modules.extend(self.pyrobufize_builtins())
     Distribution.run_commands(self)
コード例 #55
0
ファイル: setup.py プロジェクト: cobbler/cobbler
 def __init__(self, *args, **kwargs):
     self.configure_files = []
     self.configure_values = {}
     self.man_pages = []
     _Distribution.__init__(self, *args, **kwargs)
コード例 #56
0
ファイル: setup.py プロジェクト: agiledata/pkglib
def fetch_build_eggs(requires, dist):
    return Distribution.fetch_build_eggs(dist, requires)
コード例 #57
0
ファイル: setup.py プロジェクト: Trilliant/pyang
 def run_commands(self):
       opts = self.command_options
       if "install" in opts:
             self.preprocess_files(opts["install"].get("prefix",
                                                       ("", None))[1])
       Distribution.run_commands(self)
コード例 #58
0
ファイル: setup3lib.py プロジェクト: ArekSredzki/ubcsailbots
 def __init__(self, attrs=None):
     self.test_dirs = []
     self.test_build_dir = None
     self.doctest_exts = ['.py', '.rst']
     self.pyversion_patching = False
     _Distribution.__init__(self, attrs)
コード例 #59
0
ファイル: wheel.py プロジェクト: BrentLeeSF/REST_APIs
 def install_as_egg(self, destination_eggdir):
     '''Install wheel as an egg directory.'''
     with zipfile.ZipFile(self.filename) as zf:
         dist_basename = '%s-%s' % (self.project_name, self.version)
         dist_info = '%s.dist-info' % dist_basename
         dist_data = '%s.data' % dist_basename
         def get_metadata(name):
             with zf.open('%s/%s' % (dist_info, name)) as fp:
                 value = fp.read().decode('utf-8') if PY3 else fp.read()
                 return email.parser.Parser().parsestr(value)
         wheel_metadata = get_metadata('WHEEL')
         dist_metadata = get_metadata('METADATA')
         # Check wheel format version is supported.
         wheel_version = parse_version(wheel_metadata.get('Wheel-Version'))
         if not parse_version('1.0') <= wheel_version < parse_version('2.0dev0'):
             raise ValueError('unsupported wheel format version: %s' % wheel_version)
         # Extract to target directory.
         os.mkdir(destination_eggdir)
         zf.extractall(destination_eggdir)
         # Convert metadata.
         dist_info = os.path.join(destination_eggdir, dist_info)
         dist = Distribution.from_location(
             destination_eggdir, dist_info,
             metadata=PathMetadata(destination_eggdir, dist_info)
         )
         # Note: we need to evaluate and strip markers now,
         # as we can't easily convert back from the syntax:
         # foobar; "linux" in sys_platform and extra == 'test'
         def raw_req(req):
             req.marker = None
             return str(req)
         install_requires = list(sorted(map(raw_req, dist.requires())))
         extras_require = {
             extra: list(sorted(
                 req
                 for req in map(raw_req, dist.requires((extra,)))
                 if req not in install_requires
             ))
             for extra in dist.extras
         }
         egg_info = os.path.join(destination_eggdir, 'EGG-INFO')
         os.rename(dist_info, egg_info)
         os.rename(os.path.join(egg_info, 'METADATA'),
                   os.path.join(egg_info, 'PKG-INFO'))
         setup_dist = SetuptoolsDistribution(attrs=dict(
             install_requires=install_requires,
             extras_require=extras_require,
         ))
         write_requirements(setup_dist.get_command_obj('egg_info'),
                            None, os.path.join(egg_info, 'requires.txt'))
         # Move data entries to their correct location.
         dist_data = os.path.join(destination_eggdir, dist_data)
         dist_data_scripts = os.path.join(dist_data, 'scripts')
         if os.path.exists(dist_data_scripts):
             egg_info_scripts = os.path.join(destination_eggdir,
                                             'EGG-INFO', 'scripts')
             os.mkdir(egg_info_scripts)
             for entry in os.listdir(dist_data_scripts):
                 # Remove bytecode, as it's not properly handled
                 # during easy_install scripts install phase.
                 if entry.endswith('.pyc'):
                     os.unlink(os.path.join(dist_data_scripts, entry))
                 else:
                     os.rename(os.path.join(dist_data_scripts, entry),
                               os.path.join(egg_info_scripts, entry))
             os.rmdir(dist_data_scripts)
         for subdir in filter(os.path.exists, (
             os.path.join(dist_data, d)
             for d in ('data', 'headers', 'purelib', 'platlib')
         )):
             unpack(subdir, destination_eggdir)
         if os.path.exists(dist_data):
             os.rmdir(dist_data)
         # Fix namespace packages.
         namespace_packages = os.path.join(egg_info, 'namespace_packages.txt')
         if os.path.exists(namespace_packages):
             with open(namespace_packages) as fp:
                 namespace_packages = fp.read().split()
             for mod in namespace_packages:
                 mod_dir = os.path.join(destination_eggdir, *mod.split('.'))
                 mod_init = os.path.join(mod_dir, '__init__.py')
                 if os.path.exists(mod_dir) and not os.path.exists(mod_init):
                     with open(mod_init, 'w') as fp:
                         fp.write(NAMESPACE_PACKAGE_INIT)
コード例 #60
0
ファイル: setup.py プロジェクト: pythongssapi/python-gssapi
 def run_command(self, command):
     self._last_run_command = command
     Distribution.run_command(self, command)