Package: rezbuild
RezbuildRezbuild is a python library for build rez packages. Please visit theRez websitefor more information about rez.点击这里访问 Rezbuild 的中文文档。DescriptionThis project is a tool to build rez packages. It simplifies the build process.Rezbuild support build rez package by python wheel, python source archive,
python source, archive file, unix source, macOS pkg and macOS dmg.InstallationrequisitesRezbuild requires the python-3.6+, build-0.3+(lower version did not test) and
pip-18+ to run.InstallThere are 3 ways to install rezbuild, choose according to your own situation.1.Install by source for rez(New in rezbuild, or do not have rezbuild in you environment)If you are new in rezbuild, or there's no other version of rezbuild in you rez
environment, you can use rez to install this package from source. Make sure all
the requirement already installed into you rez environment(python-3.6+,
build-0.3+, pip-18+).Then, clone this project, cd the source root and run the rez install command:gitclonegit@gitlab.com:Pili-Pala/rezbuild.gitcdrezbuild
rezbuild-i2.Install by itself(Need rezbuild in you rez repository)Rezbuild can install by itself. Make sure you have all the requirements are
installed into rez environment, include rezbuild (another version of this
package). Download wheel file fromPyPI. Then create a directory like
this:install_rezbuild/
├── build.py
├── package.py
└── installers/
    └── rezbuild-0.14.1-py3-none-any.whlThe content of build.py can be like this:# build.pyfromrezbuild.builderimportPythonWheelBuilderif__name__=='__main__':builder=PythonWheelBuilder()builder.build()The content of package.py can be like this:# package.pyname="rezbuild"version="version of this package you download"requires=["build-0.3+","pip-18+","python-3.6+",]private_build_requires=["rezbuild",]build_command='python{root}/build.py{install}'defcommands():env.PYTHONPATH.append("{root}/site-packages")Then, run this command in the root directoryrez build -i.
After that, this package will be installed as a rez package.3.Install from pypiOf course, you can install this package from pippipinstallrezbuildAs this package is for rez, install from pypi doesn't make sense in most of the
time.UsageAfter 2.70.0, rez removed the bez build system. So rezbuild based on
rez-2.70.0.Build from python wheel file(PythonWheelBuilder)I assume that you already know what is rez, how to make a package.py, and now
you want to build a third-party python package come from the internet.First, add a build file into you package root, just like a file namedbuild.py. The content can be like this:# Import third-party modulesfromrezbuildimportPythonWheelBuilderif__name__=='__main__':PythonWheelBuilder().build()Then add variablebuild_commandinto thepackage.pyfile,
content should be like this:build_command = 'python {root}/build.py {install}'.After that, go toPyPIto download the wheel file and put
the file intosource_root/installers. The tree should like this:source_root/
├── build.py
├── package.py
└── installers/
    └── the_package_you_want_to_install.whlFinally, change directory to source_root and run the commandrez build -i,
the package will be installed.Build from python source code(PythonSourceBuilder)PythonSourceBuilder is used to build rez package from python source which
meeting the requirements of Python official structure. The source structure
please refer topython official website.
The source structure should like this:source_root/
├── build.py
├── package.py
├── pyproject.toml
├── setup.cfg
└── src/
    └── module/
        └── __init__.pyThe content ofbuild.py:# Import third-party modulesfromrezbuildimportPythonSourceBuilderif__name__=='__main__':PythonSourceBuilder().build()Then ensure you already make all the necessary files to build a python package.PythonSourceBuilderwill use the official way to build the package.Then run the commandrez build -i, the package will be build and installed.Build from the python source archive fileSome packages only supply the python source archive file, we can use the
PythonSourceArchiveBuilder builder to build.Copy build(CopyBuilder)Sometimes we don't want to use the official way to build rez package(metadata
will be missing if we don't use the official way), but only copy the code. Use
CopyBuilder can build package by only copy the source code. The default source
path is the folder namedsrcunder the source root. Pass the path to the root
parameter in build method to custom the source path. build.py file should like
this:# Import built-in modulesimportos# Import third-party modulesfromrezbuildimportCopyBuilderif__name__=='__main__':builder=CopyBuilder()builder.build(root=os.path.join(builder.source_path,"example_package"))Build from Archive file(ExtractBuilder)ExtractBuilder can extract the archive file to build rez package.
ExtractBuilder now support zip, tar.gz, tar.xz and 7z.exe.build.py:# Import third-party modulesfromrezbuildimportExtractBuilderif__name__=='__main__':ExtractBuilder().build()Put the archive file intoinstallersfolder.source_root/
├── build.py
├── package.py
└── installers/
    └── archive.zipBuild from source code(CompileBuilder)CompileBuilder support useconfigureandmakecommand to build package
on Linux and macOS. The arguments of configure is passed by the
extra_config_args parameter of CompileBuilder.build method.build.py如下:# Import third-party modulesfromrezbuildimportCompileBuilderif__name__=='__main__':CompileBuilder().build(extra_config_args=["LDFLAGS=-L/path/to/lib"])Put the source archive file into installers folder.source_root/
├── build.py
├── package.py
└── installers/
    └── git-2.32.0.tar.gzBuild from dmg file(MacOSDmgBuilder)Makebuild.pylike this:# Import third-party modulesfromrezbuildimportMacOSDmgBuilderif__name__=='__main__':MacOSDmgBuilder().build()Put archive file intoinstallersfolder.source_root/
├── build.py
├── package.py
└── installers/
    └── installer.dmgThen run commandrez build -ifromsource_root.MacOSDmgBuilderwill create a shell script in the package root, has a same
with the.appfolder. Setcreate_shelltoFalseto prevent his creation.
For example:MacOSDmgBuilder().build(create_shell=False)Custom builderYou can customize a builder for you code from base builder. Just make a builder
inherit from RezBuilder and rewritecustom_buildfunction. Follow will
introduce all the default builder from rezbuild so that you can use them to
customize you own builder.RezBuilderRezBuilderis the root builder, all the builder inherit from it. It gets the
rez environment, make sure the workspace, install package, and execute you
custom build function.For example:# Import built-in modulesimportosimportshutil# Import third-party modulesfromrezbuildimportRezBuilderclassCustomBuilder(RezBuilder):defcustom_build(self):shutil.copytree(os.path.join(self.source_path,"src"),self.build_path)if__name__=='__main__':CustomBuilder().build()build function will invoke the custom_build function to build the package.Multiple variantIf you need to install a multi-variant package with different installers for
each variant, you can put the installers into the folders that named with the
variant index under theinstallersfolder. For example:git/
    |___installers/
        |___0
            |___PortableGit-2.32.0.2-64-bit.7z.exe
        |___1
            |___git-2.32.0.tar.xz
    |___build.py
    |___package.pyRezbuild will get all the installers under the variant folder when building it.APIbuilder moduleRezBuilder()RezBuilderis the root builder, any other builder is inherited from it.
RezBuilder load the environment variables, makesure the workspace, install the
package and execute the custom build method.RezBuilder.build_pathBuild path. The rez default directory.RezBuilder.install_pathInstall path. Default is ~/packages.RezBuilder.source_pathThe source path.RezBuilder.workspaceWorkspace. All the files and folders will be copied to the installation path.RezBuilder.namePackage name.RezBuilder.versionBuild version.RezBuilder.variant_indexVariant index.RezBuilder.build(**kwargs) -> NoneBuild method, trigger the build process. This method will invoke the custom
build method of the subclass to run the build.kwargs: Accept all the key word arguments to pass to the custom_build method.VersioningWe useSemVerfor versioning. For the versions available,
see thetags on this repository.AuthorPiliPalaLicenseGPLv3