<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                #11.4 以Conda包的形式發布一個簡單的項目 **NOTE**:*此示例代碼可以在 https://github.com/dev-cafe/cmake-cookbook/tree/v1.0/chapter-11/recipe-04 中找到。該示例在CMake 3.5版(或更高版本)中是有效的,并且已經在GNU/Linux、macOS和Windows上進行過測試。* 雖然PyPI是發布Python包的標準平臺,但Anaconda (https://anaconda.org )更為可能更為流行,因為它不僅允許使用Python接口發布Python或混合項目,還允許對非Python項目進行打包和依賴關系管理。這個示例中,我們將為一個非常簡單的C++示例項目準備一個Conda包,該項目使用CMake配置和構建,除了C++之外沒有依賴關系。下一個示例中,我們將會來看看一個更復雜的Conda包。 ## 準備工作 我們的目標是打包以下示例代碼(`example.cpp`): ```c++ #include <iostream> int main() { std::cout << "hello from your conda package!" << std::endl; return 0; } ``` ## 具體實施 1. `CMakeLists.txt`文件給出了最低版本要求、項目名稱和支持的語言: ```cmake cmake_minimum_required(VERSION 3.5 FATAL_ERROR) project(recipe-04 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_STANDARD_REQUIRED ON) ``` 2. 使用`example.cpp`構建`hello-conda`可執行目標: ```cmake add_executable(hello-conda "") target_sources(hello-conda PRIVATE example.cpp ) ``` 3. 使用`CMakeLists.txt`定義安裝目標: ```cmake nstall( TARGETS hello-conda DESTINATION bin ) ``` 4. 將在一個名為` meta.yaml `的文件中,對Conda包進行描述。我們將把它放在`conda-recipe`目錄下,文件結構如下: ```shell . ├── CMakeLists.txt ├── conda-recipe │ └── meta.yaml └── example.cpp ``` 5. `meta.yaml`包含如下內容: ```yaml package: name: conda-example-simple version: "0.0.0" source: path: .. / # this can be changed to git-url build: number: 0 binary_relocation: true script: - cmake -H. -Bbuild_conda -G "${CMAKE_GENERATOR}" -DCMAKE_INSTALL_PREFIX=${PREFIX} # [not win] - cmake -H. -Bbuild_conda -G "%CMAKE_GENERATOR%" -DCMAKE_INSTALL_PREFIX="%LIBRARY_PREFIX%" # [win] - cmake - -build build_conda - -target install requirements: build: - cmake >=3.5 - { { compiler('cxx') } } about: home: http://www.example.com license: MIT summary: "Summary in here ..." ``` 6. 現在來構建包: ```shell $ conda build conda-recipe ``` 7. 過程中屏幕上看到大量輸出,但是一旦構建完成,就可以對包進行安裝。首先,在本地進行測試: ```shell $ conda install --use-local conda-example-simple ``` 8. 現在準備測試安裝包,打開一個新的終端(假設Anaconda處于激活狀態),并輸入以下內容: ```shell $ hello-conda hello from your conda package! ``` 9. 測試成功后,再移除包裝: ```shell $ conda remove conda-example-simple ``` ## 工作原理 `CMakeLists.txt`中,安裝目標是這個示例的一個基本組件: ```cmake install( TARGETS hello-conda DESTINATION bin ) ``` 目標的二進制文件會安裝到`${CMAKE_INSTALL_PREFIX}/bin`中。變量由Conda定義,并且構建步驟中定義在` meta.yaml `: ```yaml build: number: 0 binary_relocation: true script: - cmake -H. -Bbuild_conda -G "${CMAKE_GENERATOR}" -DCMAKE_INSTALL_PREFIX=${PREFIX} # [not win] - cmake -H. -Bbuild_conda -G "%CMAKE_GENERATOR%" -DCMAKE_INSTALL_PREFIX="%LIBRARY_PREFIX%" # [win] - cmake - -build build_conda - -target install ``` 將安裝目錄設置為`${prefix}` (Conda的內部變量),然后構建并安裝項目。調用構建目錄命名為`build_conda`的動機與前面的示例類似:特定的構建目錄名可能已經命名為`build`。 ## 更多信息 配置文件` meta.yaml `可為任何項目指定構建、測試和安裝步驟。詳情請參考官方文檔:https://conda.io/docs/user-guide/tasks/build-packages/define-metadata.html 要將Conda包上傳到Anaconda云,請遵循官方的Anaconda文檔: https://docs.anaconda.com/anaconda-cloud/user-guide/ 此外,也可以考慮將Miniconda,作為Anaconda的輕量級替代品:https://conda.io/miniconda.html
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看