How to use the setuptools.command.build_py.build_py function in setuptools

To help you get started, we’ve selected a few setuptools 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 silx-kit / silx / setup.py View on Github external
def find_package_modules(self, package, package_dir):
        modules = _build_py.find_package_modules(self, package, package_dir)
        if package == PROJECT:
            modules.append((PROJECT, '_version', 'version.py'))
        return modules
github pycalphad / pycalphad / versioneer.py View on Github external
def run(self):
            root = get_root()
            cfg = get_config_from_root(root)
            versions = get_versions()
            _build_py.run(self)
            # now locate _version.py in the new build/ directory and replace
            # it with an updated value
            if cfg.versionfile_build:
                target_versionfile = os.path.join(self.build_lib,
                                                  cfg.versionfile_build)
                print("UPDATING %s" % target_versionfile)
                write_to_version_file(target_versionfile, versions)
    cmds["build_py"] = cmd_build_py
github informatics-lab / forest / setup.py View on Github external
@build_js
class InstallCommand(setuptools.command.install.install):
    """Python and JS code"""


@build_js
class DevelopCommand(setuptools.command.develop.develop):
    """Python and JS code"""


@build_js
class BuildPyCommand(setuptools.command.build_py.build_py):
    """Python and JS code"""


class BuildJSCommand(setuptools.command.build_py.build_py):
    """Use nodejs and npm commands to browserify forest.js

    .. note:: Assume current working directory is package ROOT
    """
    def run(self):
        cwd = os.getcwd()
        os.chdir(JS_DIR)
        if not os.path.exists("node_modules"):
            subprocess.check_call(["npm", "install"])
        subprocess.check_call(["npm", "run", "build"])
        os.chdir(cwd)
        super().run()


setuptools.setup(
        name=NAME,
github lutzroeder / netron / setup.py View on Github external
'node_modules/protobufjs/ext/prototxt/prototxt.js',
        'node_modules/flatbuffers/js/flatbuffers.js' ] )
]

class build(distutils.command.build.build):
    user_options = distutils.command.build.build.user_options + [ ('version', None, 'version' ) ]
    def initialize_options(self):
        distutils.command.build.build.initialize_options(self)
        self.version = None
    def finalize_options(self):
        distutils.command.build.build.finalize_options(self)
    def run(self):
        build_py.version = bool(self.version)
        return distutils.command.build.build.run(self)

class build_py(setuptools.command.build_py.build_py):
    user_options = setuptools.command.build_py.build_py.user_options + [ ('version', None, 'version' ) ]
    def initialize_options(self):
        setuptools.command.build_py.build_py.initialize_options(self)
        self.version = None
    def finalize_options(self):
        setuptools.command.build_py.build_py.finalize_options(self)
    def run(self):
        setuptools.command.build_py.build_py.run(self)
        for target, files in node_dependencies:
            target = os.path.join(self.build_lib, target)
            if not os.path.exists(target):
                os.makedirs(target)
            for file in files:
                self.copy_file(file, target)
    def build_module(self, module, module_file, package):
        setuptools.command.build_py.build_py.build_module(self, module, module_file, package)
github nipy / nipype / setup.py View on Github external
def run(self):
        import subprocess
        import configparser

        build_py.run(self)
        proc = subprocess.Popen('git rev-parse --short HEAD',
                                stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE,
                                shell=True)
        repo_commit, _ = proc.communicate()
        # Fix for python 3
        if PY3:
            repo_commit = repo_commit.decode()

        # We write the installation commit even if it's empty
        cfg_parser = configparser.RawConfigParser()
        cfg_parser.read(pjoin('nipype', 'COMMIT_INFO.txt'))
        cfg_parser.set('commit hash', 'install_hash', repo_commit.strip())
        out_pth = pjoin(self.build_lib, 'nipype', 'COMMIT_INFO.txt')
        if PY3:
            cfg_parser.write(open(out_pth, 'wt'))
github probcomp / iventure / setup.py View on Github external
def run(self):
        write_version_py(version_py)
        build_py.run(self)
github opsdroid / opsdroid / setup.py View on Github external
# For now we simply define the install_requires based on the contents
# of requirements.txt. In the future, install_requires may become much
# looser than the (automatically) resolved requirements.txt.
with open(os.path.join(HERE, "requirements.txt"), "r") as fh:
    REQUIRES = [line.strip() for line in fh]


class Develop(develop):
    """Custom `develop` command to always build mo files on install -e."""

    def run(self):
        self.run_command("compile_catalog")
        develop.run(self)  # old style class


class BuildPy(build_py):
    """Custom `build_py` command to always build mo files for wheels."""

    def run(self):
        self.run_command("compile_catalog")
        build_py.run(self)  # old style class


class Sdist(sdist):
    """Custom `sdist` command to ensure that mo files are always created."""

    def run(self):
        self.run_command("compile_catalog")
        sdist.run(self)  # old style class


setup(
github clearclaw / xxpaper / versioneer.py View on Github external
#
    # most invocation pathways end up running build_py:
    #  distutils/build -> build_py
    #  distutils/install -> distutils/build ->..
    #  setuptools/bdist_wheel -> distutils/install ->..
    #  setuptools/bdist_egg -> distutils/install_lib -> build_py
    #  setuptools/install -> bdist_egg ->..
    #  setuptools/develop -> ?

    # we override different "build_py" commands for both environments
    if "setuptools" in sys.modules:
        from setuptools.command.build_py import build_py as _build_py
    else:
        from distutils.command.build_py import build_py as _build_py

    class cmd_build_py(_build_py):
        def run(self):
            root = get_root()
            cfg = get_config_from_root(root)
            versions = get_versions()
            _build_py.run(self)
            # now locate _version.py in the new build/ directory and replace
            # it with an updated value
            if cfg.versionfile_build:
                target_versionfile = os.path.join(self.build_lib,
                                                  cfg.versionfile_build)
                print("UPDATING %s" % target_versionfile)
                write_to_version_file(target_versionfile, versions)
    cmds["build_py"] = cmd_build_py

    if "cx_Freeze" in sys.modules:  # cx_freeze enabled?
        from cx_Freeze.dist import build_exe as _build_exe
github flozz / pypapi / setup.py View on Github external
def run(self):
        os.environ["CFLAGS"] = "%s -fPIC -Werror=format-truncation=0" % os.environ.get("CFLAGS", "")
        subprocess.call("cd papi/src/ && ./configure", shell=True)  # noqa
        subprocess.call("cd papi/src/ && make", shell=True)  # noqa
        build_py.run(self)
github gaphor / gaphor / setup.py View on Github external
def run(self):
        for cmd_name in self.get_sub_commands():
            self.run_command(cmd_name)

        build_py.run(self)