How to use the setupmeta.relative_path function in setupmeta

To help you get started, we’ve selected a few setupmeta examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zsimic / setupmeta / tests / test_model.py View on Github external
def test_first_word():
    assert setupmeta.relative_path(None) is None
    assert setupmeta.relative_path("") == ""
    assert setupmeta.relative_path("foo") == "foo"

    assert setupmeta.first_word(None) is None
    assert setupmeta.first_word("") is None
    assert setupmeta.first_word("  \n \t ") is None
    assert setupmeta.first_word("  \n \t foo[bar]") == "foo"
    assert setupmeta.first_word("FOO bar") == "foo"
    assert setupmeta.first_word(" FOO, bar") == "foo"
    assert setupmeta.first_word("123") == "123"
github zsimic / setupmeta / setupmeta / commands.py View on Github external
def delete(self, full_path):
        if os.path.isdir(full_path):
            shutil.rmtree(full_path)
            print("deleted %s" % setupmeta.relative_path(full_path))

        else:
            os.unlink(full_path)
            self.by_ext[full_path.rpartition(".")[2]] += 1

        self.deleted += 1
github zsimic / setupmeta / setupmeta / model.py View on Github external
def finalize(self, upstream):
        self.attrs.update(MetaDefs.dist_to_dict(upstream))

        self.find_project_dir(self.attrs.pop("_setup_py_path", None))
        scm = self.attrs.pop("scm", None)

        # Add definitions from setup()'s attrs (highest priority)
        for key, value in self.attrs.items():
            if key not in self.definitions:
                self.add_definition(key, value, EXPLICIT)

        # Add definitions from PKG-INFO, when available
        self.pkg_info = PackageInfo(MetaDefs.project_dir)
        for key, value in self.pkg_info.info.items():
            if key in MetaDefs.all_fields:
                self.add_definition(key, value, relative_path(self.pkg_info.path))

        # Allow to auto-fill 'name' from setup.py's __title__, if any
        self.merge(SimpleModule("setup.py"))
        title = self.definitions.get("title")
        if title:
            self.auto_fill("name", title.value, source=title.source)

        if "--name" in sys.argv[1:3]:
            # No need to waste time auto-filling anything if all we need to show is package name
            return self

        packages = self.attrs.get("packages", [])
        py_modules = self.attrs.get("py_modules", [])

        if not packages and not py_modules and self.name:
            # Try to auto-determine a good default from 'self.name'
github zsimic / setupmeta / setupmeta / model.py View on Github external
def auto_fill_entry_points(self, key="entry_points"):
        if self.pkg_info.entry_points_txt:
            self.add_definition(key, load_contents(self.pkg_info.entry_points_txt), relative_path(self.pkg_info.entry_points_txt))
        path = "%s.ini" % key
        self.add_definition(key, load_contents(path), path)