Exemplo n.º 1
0
    def install(self):
        """return a string with `install` section"""
        if hasattr(self, "_install"):
            return getattr(self, "_install")
        if os.path.exists("setup.cfg"):
            return """```bash
$ [sudo] pip install %s
```""" % setupcfg.get("metadata", "name")
Exemplo n.º 2
0
 def get_modules(self):
     """load python files and return its module objects. `setup.cfg` `[options]` `py_modules` or `packages` required"""
     packages = setupcfg.get("options", "packages", [])
     py_modules = setupcfg.get("options", "py_modules", [])
     files = list(map(lambda m: "%s.py" % m, py_modules))
     for package in packages:
         path = package.replace(".", "/")
         filenames = filter(lambda f: f[0] != ".", os.listdir(path))
         py = filter(lambda f: os.path.splitext(f)[1] == ".py", filenames)
         files += list(map(lambda l: os.path.join(path, l), py))
     modules = []
     for f in files:
         try:
             module = import_module(f)
             modules.append(module)
         except Exception as e:
             module_name = sys.modules[type(e).__module__].__name__
             class_name = type(e).__name__
             print("%s.%s: %s" % (module_name, class_name, str(e)))
     return modules
Exemplo n.º 3
0
#!/usr/bin/env python
import os
import setupcfg

os.chdir(os.path.dirname(__file__))

name = setupcfg.get("metadata", "name")
print("name: %s" % name)

default = setupcfg.get("metadata", "not-existing", "default value")
print("default: %s" % default)
Exemplo n.º 4
0
def name():
    if os.path.exists("setup.cfg"):
        return setupcfg.get("metadata", "name")
    return os.popen("python setup.py --name").read().strip()
Exemplo n.º 5
0
 def get_scripts(self):
     """todo"""
     scripts = setupcfg.get("options", "scripts", [])
     return list(filter(lambda f: os.path.basename(f)[0] != ".", scripts))