-
Notifications
You must be signed in to change notification settings - Fork 247
How to generate python wheels
It is possible go define package-specific metadata, like author, author email, description, README file.
To do that, edit wheel definitions in scripts/wheels/<platform>/applications/<application_name>.json
in the Kratos repository.
It's important to edit both linux and windows definitions, since they are treated as separate packages.
Before each new release Kratos version must be changed. This is done by modifying KRATOS_VERSION variables at the top of scripts/wheels/windows/build.ps1
and scripts/wheels/linux/build.sh
.
Allowed version strings are defined by the PEP440.
Build process for KratosCore and Kratos-all wheels is slighty different. Beacuse of that, their definition files are located outside of the applications
directory.
You can find them in scripts/wheels/windows/KratosMultiphysics.json
, scripts/wheels/linux/KratosMultiphysics.json
and scrips/wheels/linux/KratosMultiphysics-all.json
Json structure is exactly the same, as for other applications.
{
"wheel_name": "KratosContactStructuralMechanicsApplication",
"included_modules": ["ContactStructuralMechanicsApplication"],
"included_binaries": ["KratosContactStructuralMechanicsApplication.cpython-${PYTHON}m-x86_64-linux-gnu.so"],
"excluded_binaries": ["libKratosStructuralMechanicsCore"],
"dependencies": ["KratosMultiphysics==${KRATOS_VERSION}", "KratosStructuralMechanicsApplication==${KRATOS_VERSION}"],
"author": "Vicente Mataix Ferrándiz",
"author_email": "[email protected]",
"description": "KRATOS Multiphysics (\"Kratos\") is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.",
"readme": "scripts/wheels/README.md"
}
wheel_name
- this is the wheel name. Will be passed to pip install
command when instaling this package.
included_modules
- included python modules. Those are copied from KratosMultiphysics/<module_name>
included_binaries
- binary files copied from libs
directory. On windows you must include all required binaries and their dependencies. On linux binary dependencies are managed automatically and in most cases it's enough to specify the binary python module. Supports keywords.
excluded_binaries
- On linux only, optional. Used to specify all binary dependencies, that are guaranteed to be already provided, for example by another Kratos application, which is included in dependencies
. Skip file extension. You don't have to specify here binaries provided by Kratos Core wheel - those are filtered automatically. Supports keywords.
dependecies
- names and versions of required python packages, as they are available on the PyPi. Supports keywords. For more information visit PEP440 - version specifiers.
author
- application/package author name
author_email
- application/package author contact email. Will be public
description
- short package description
readme
- path to the readme file in the Kratos repository
In some places in the json file you may use keywords, which will be replaced with correct information during build. Available keywords:
-
${PYTHON}
- two digits and optional 'm' representing currently used python version. For example35m
or38
. -
${KRATOS_VERSION}
- String representing currently built Kratos version. Wheels will be tagged using that version. Useful when definig dependencies on other Kratos wheels.
- Make sure, that every application, that will be included in the new wheel package is being built by the wheel generation scripts.
This can be checked and eventually modified in
scripts/wheels/windows/configure.bat
andscripts/wheels/linux/configure.sh
files. - Define json files. Place them in
scripts/wheels/<platform>/applications
directory for each platform, that you want to support. For more information on json structure visit "Package metadata" section. - Push your changes to any branch in the Kratos repository.
- That's it! Now you can build your wheels as described in the "Wheel generation section". Remember, that due to binary dependecies between wheels, all of them must be built without any code changes in the Kratos Core or any other dependencies.
On windows this process is quite easy. All you have to do is add dependent wheel name in the dependencies
array in the json file. Remember to set dependency version using ${KRATOS_VERSION}
keyword.
On linux you have to also blacklist all binaries provided by the dependency app in excluded_binaries
array, so they don't get packaged twice. You may use ${PYTHON}
and ${KRATOS_VERSION}
keywords.
For a working example check ContactStructuralMechanicsApplication.json
- Install docker.
- Run command
sudo docker run --rm -v local_output_dir:/workspace/out kratosmultiphysics/kratos-wheelbuilder-linux [OPTION]...
Available options:
--branch branch_name
- branch to compile. By default master
.
--cpus number_of_cores
- number of cores assigned to the build. By default 4
.
--cotire ON/OFF
- enable/disable cotire build. By default OFF
.
--pythons python_versions
- coma separated python versions to target. By default "35,36,37,38"
.
--repository git_repository_url
- repository to use during build. By default https://github.com/KratosMultiphysics/Kratos.git
.
- Wait. Wheel files will appear in
local_output_dir
.
- Install docker and enable windows containers.
- Run command
docker run --rm --memory=<memory> --cpus=<number_of_cores> -v local_output_dir:c:\out kratosmultiphysics/kratos-wheelbuilder-windows [OPTION]...
<memory>
- maximum amount of RAM assigned to the container. Recomended value is 8g
.
<number_of_cores>
- number of cores assigned to the container. By default 1
.
Available options:
-branch
- branch to compile. By default master
.
-cotire ON/OFF
- enable/disable cotire build. By default OFF
.
-pythons python_versions
- coma separated python versions to target. By default "35,36,37,38"
.
-cpus number_of_cores
- number of cores assigned to the build. This is not the same as --cpus
option provided by docker. By default the same as <number_of_cores>.
- Wait. Wheel files will appear in
local_output_dir
.
Docker images used in wheel generation process are available on the docker hub of Kratos:
The corresponding Dockerfiles are available here:
- Getting Kratos (Last compiled Release)
- Compiling Kratos
- Running an example from GiD
- Kratos input files and I/O
- Data management
- Solving strategies
- Manipulating solution values
- Multiphysics
- Video tutorials
- Style Guide
- Authorship of Kratos files
- Configure .gitignore
- How to configure clang-format
- How to use smart pointer in Kratos
- How to define adjoint elements and response functions
- Visibility and Exposure
- Namespaces and Static Classes
Kratos structure
Conventions
Solvers
Debugging, profiling and testing
- Compiling Kratos in debug mode
- Debugging Kratos using GDB
- Cross-debugging Kratos under Windows
- Debugging Kratos C++ under Windows
- Checking memory usage with Valgind
- Profiling Kratos with MAQAO
- Creating unitary tests
- Using ThreadSanitizer to detect OMP data race bugs
- Debugging Memory with ASAN
HOW TOs
- How to create applications
- Python Tutorials
- Kratos For Dummies (I)
- List of classes and variables accessible via python
- How to use Logger
- How to Create a New Application using cmake
- How to write a JSON configuration file
- How to Access DataBase
- How to use quaternions in Kratos
- How to do Mapping between nonmatching meshes
- How to use Clang-Tidy to automatically correct code
- How to use the Constitutive Law class
- How to use Serialization
- How to use GlobalPointerCommunicator
- How to use PointerMapCommunicator
- How to use the Geometry
- How to use processes for BCs
- How to use Parallel Utilities in futureproofing the code
- Porting to Pybind11 (LEGACY CODE)
- Porting to AMatrix
- How to use Cotire
- Applications: Python-modules
- How to run multiple cases using PyCOMPSs
- How to apply a function to a list of variables
- How to use Kratos Native sparse linear algebra
Utilities
Kratos API
Kratos Structural Mechanics API