|
| 1 | +## Build for Anaconda |
| 2 | + |
| 3 | +Conda package can be generated to support more Linux platforms, and Windows. Conda package build has been tested successfully on local host. |
| 4 | +In the future, parallel-preprocessor will be available on conda-forge channel for `conda install -c condaforge parallel-preprocessor` This conda package for parallel-preprocessor has both c++ binary and python wrapper installed, just like build deb package from source by cmake. |
| 5 | + |
| 6 | + |
| 7 | +``` |
| 8 | +conda config --add channels conda-forge |
| 9 | +conda config --set channel_priority strict |
| 10 | +conda install occt |
| 11 | +conda install parallel-preprocessor |
| 12 | +``` |
| 13 | + |
| 14 | +### conda recipe: meta.yaml and build scripts |
| 15 | + |
| 16 | +The meta.yaml and build scripts have been provided in the `recipe` folder of this repository. |
| 17 | + |
| 18 | +The package config file `meta.yaml` can be generated by a command, or just adapted from an existing recipe online, e.g. |
| 19 | +<https://github.com/conda/conda-recipes/tree/master/libtiff> |
| 20 | +Also note that the compilers used by conda-build can be specified using a `conda_build_config.yaml`. |
| 21 | + |
| 22 | +The build scripts `build.sh` (for Unix-like OS) and `bld.bat` (windows batch file) have the install instruction (cmake is called just as compiling from source code.), install to a tmp prefix, then compressed into a zipped file, i.e. conda package. |
| 23 | + |
| 24 | + |
| 25 | +### build conda package from local machine |
| 26 | + |
| 27 | +`parallel-preprocessor` depends on OpenCASCADE conda package, whose conda packaging configuration can be found at `https://github.com/conda-forge/occt-feedstock/`. To build conda package from local machine, user should install all the necessary dependency, such as OpenCASCADE 7.x, TBB, if conda build failed to download the dependencies specified in `meta.yaml`. |
| 28 | + |
| 29 | +To build conda package, first of all, install anaconda python3 and install necessary packages like `conda-build`, and run the command in the `recipe` folder of this repository: `conda build meta.ymal` |
| 30 | + |
| 31 | +The conda build task is conducted a seperate virtual environment automatically, so is the test(run) process. |
| 32 | +`D:\Software\anaconda3\envs\cf\conda-bld\ppp_1597347412425` |
| 33 | +On windows, cmake isntalled to the `base` conda environment can still detect `occt` package installed in the conda-build tmp conda environment. |
| 34 | + |
| 35 | +NOTE: conda will not auto clean those tmp virtual env, user must manually remove the build virtual env. |
| 36 | + |
| 37 | + |
| 38 | +anaconda upload /opt/anaconda3/conda-bld/linux-64/parallel-preprocessor-0.3-oct_2020.tar.bz2 |
| 39 | + |
| 40 | +To have conda build upload to anaconda.org automatically, use |
| 41 | + |
| 42 | +`conda config --set anaconda_upload yes` |
| 43 | + |
| 44 | + |
| 45 | +### install built local conda package |
| 46 | + |
| 47 | +Where is the generated conda package? |
| 48 | +If testing script passed, the generated conda package, a compressed file, should be copied to the current working directory. |
| 49 | +If test failed, there may be error message: |
| 50 | +> Tests failed for ppp-0.3-hdef9aff_2003.tar.bz2 - moving package to D:\Software\anaconda3\envs\cf\conda-bld\broken |
| 51 | +
|
| 52 | +After conda build, the built package can be installed: `conda install --use-local ppp` or equally `conda install -c local ppp` to install the built pkg. |
| 53 | +`conda install --use-local ppp --dry-run` to test if built package can be found and installed. `conda verify` may also verify the package without installation. |
| 54 | + |
| 55 | + |
| 56 | +It is expected binary conda package for parallel-preprocessor will be hosted on github or conda-forge. After downloaded from github Release, the compressed package file can be installed by the command |
| 57 | + |
| 58 | +```sh |
| 59 | +conda install package-path/package-filename.tar.bz2 |
| 60 | +``` |
| 61 | + |
| 62 | +### Conda build variants |
| 63 | + |
| 64 | +https://docs.conda.io/projects/conda-build/en/latest/resources/variants.html |
| 65 | + |
| 66 | +selector document |
| 67 | + |
| 68 | +Here is an example to skip some variants in meta.yaml file. |
| 69 | + |
| 70 | +```yaml |
| 71 | +build: |
| 72 | + skip: true # [win or osx] |
| 73 | +``` |
| 74 | +
|
| 75 | +### build for multiple python versions |
| 76 | +
|
| 77 | +Since python the optional interface module for parallel preprocessor is C-extension, so separate binary packages are needed for conda python 3.6, 3.7 and 3.8. Depends on platforms, conda python 3.8 may be minimum version to support C++17. |
| 78 | +
|
| 79 | +conda build support build for multiple version, by specify `--py` option multiple times. |
| 80 | +`conda build --py 3.6 --py 3.7 --py 3.8 recipe` if this does not work, try |
| 81 | +`conda build recipe --variants "{'python': ['2.7', '3.6'], 'vc': ['9', '14']}"` |
| 82 | + |
| 83 | +After all, variant control is done by the yaml file`conda_build_config.yaml`. If this file does not exists same directory as` meta.yaml`, `conda build` may generate one. real also [Conda multi variant builds](https://medium.com/@MaheshSawaiker/conda-multi-variant-builds-8edc35c215d7) |
| 84 | + |
| 85 | + |
| 86 | +### conda-forge build environment |
| 87 | + |
| 88 | +Build environments in conda-forge CI (miniconda azure pipeline, ) is quite different from conda build on local machine. After trials and referencing to https://github.com/FreeCAD/FreeCAD/blob/master/conda/, finally conda build is working. |
| 89 | + |
| 90 | +conda windows python 3.8 using "VS 2017 update 9", although it is called `vs2015_runtime` indicating binary compatible, it may be using vs2017 (14.1) compiler. |
| 91 | + |
| 92 | +| [vs2015_runtime](https://docs.anaconda.com/anaconda/packages/py3.8_win-64/None) | 14.16.27012 | MSVC runtimes associated with cl.exe version 19.16.27032.1 (VS 2017 update 9) / None | |
| 93 | +| ------------------------------------------------------------ | ----------- | ------------------------------------------------------------ | |
| 94 | +| [vc](https://github.com/conda/conda/wiki/VC-features) | 14.1 | A meta-package to impose mutual exclusivity among software built with different VS versions / Modified BSD License (3-clause) | |
| 95 | + |
| 96 | +The default conda macos conda-build using MacOS SDK 10.09, XCode 11.6, but MacOS 10.13 is needed for C++17 support. Therefore, the MacOS deploy target has been limited to "10.15", in <../recipe/conda_build_config.yaml> |
| 97 | + |
| 98 | + |
| 99 | +> /src/PropertyContainer/PropertyContainerTest.cpp:46:22: error: 'any_cast<std::__1::shared_ptr<A> >' is unavailable: introduced in macOS 10.13 |
| 100 | +auto data = std::any_cast<std::shared_ptr<myType>>(a); |
| 101 | + |
| 102 | +### Upload to conda forge (yet done) |
| 103 | + |
| 104 | +Here is guide from conda-forge website: |
| 105 | +> If your package is not on conda-forge yet you can follow their contribution documentation here: https://conda-forge.org/#add_recipe |
| 106 | + |
| 107 | +The process: |
| 108 | +https://conda-forge.org/docs/maintainer/adding_pkgs.html |
| 109 | + |
| 110 | +1. fork conda-forge example repo |
| 111 | + |
| 112 | +https://github.com/qingfengxia/staged-recipes |
| 113 | + |
| 114 | +2. push it as a new repo from the branch "parallel-preprocessor" |
| 115 | + |
| 116 | +https://github.com/conda-forge/staged-recipes/pull/12901#issuecomment-709514486 |
| 117 | + |
| 118 | + |
| 119 | +3. later the maintainer (pusher) will have the write control on that repo. |
| 120 | + |
| 121 | + |
| 122 | + |
| 123 | + |
0 commit comments