代码之家  ›  专栏  ›  技术社区  ›  O.rka

如何构建一个conda包,但排除/省略/不包括特定的文件夹/目录?

  •  0
  • O.rka  · 技术社区  · 5 年前

    我试图构建一个conda包,但我刚刚意识到它一直在tar ball中添加我之前的所有版本。我试着添加这一行: recursive-exclude releases/ *.tar.gz 我的 MANIFEST.in 但它不起作用。

    以下是我的build命令:

    (µ_env) jespinozlt-osx:Packages jespinoz$ cd soothsayer/
    (µ_env) jespinozlt-osx:soothsayer jespinoz$ ls
    Icon?           dist            releases
    MANIFEST.in     docs            setup.py
    README.md       install         soothsayer
    bin         license.txt     soothsayer.egg-info
    build           logo.png        standalone
    devel.txt       meta.yaml       tutorials
    (µ_env) jespinozlt-osx:soothsayer jespinoz$ conda build .
    No numpy version specified in conda_build_config.yaml.  Falling back to default numpy value of 1.11
    WARNING:conda_build.metadata:No numpy version specified in conda_build_config.yaml.  Falling back to default numpy value of 1.11
    Adding in variants from internal_defaults
    INFO:conda_build.variants:Adding in variants from internal_defaults
    Attempting to finalize metadata for soothsayer
    INFO:conda_build.metadata:Attempting to finalize metadata for soothsayer
    BUILD START: ['soothsayer-py36_2019.12-0.tar.bz2']
    Collecting package metadata (repodata.json): ...working... done
    Solving environment: ...working... done
    Source cache directory is: /Users/jespinoz/anaconda3/conda-bld/src_cache
    INFO:conda_build.source:Source cache directory is: /Users/jespinoz/anaconda3/conda-bld/src_cache
    INFO conda_build.source:download_to_cache(43): Source cache directory is: /Users/jespinoz/anaconda3/conda-bld/src_cache
    No hash (md5, sha1, sha256) provided for soothsayer_v2019.12.tar.gz.  Source download forced.  Add hash to recipe to use source cache.
    WARNING:conda_build.source:No hash (md5, sha1, sha256) provided for soothsayer_v2019.12.tar.gz.  Source download forced.  Add hash to recipe to use source cache.
    WARNING conda_build.source:download_to_cache(59): No hash (md5, sha1, sha256) provided for soothsayer_v2019.12.tar.gz.  Source download forced.  Add hash to recipe to use source cache.
    Found source in cache: soothsayer_v2019.12.tar.gz
    INFO:conda_build.source:Found source in cache: soothsayer_v2019.12.tar.gz
    INFO conda_build.source:download_to_cache(63): Found source in cache: soothsayer_v2019.12.tar.gz
    Extracting download
    source tree in: /Users/jespinoz/anaconda3/conda-bld/soothsayer_1578343428831/work
    export PREFIX=/Users/jespinoz/anaconda3/conda-bld/soothsayer_1578343428831/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho
    export SRC_DIR=/Users/jespinoz/anaconda3/conda-bld/soothsayer_1578343428831/work
    Processing $SRC_DIR
    Building wheels for collected packages: soothsayer
      Building wheel for soothsayer (setup.py): started
      Building wheel for soothsayer (setup.py): finished with status 'done'
      Stored in directory: /private/tmp/pip-ephem-wheel-cache-z5uej2un/wheels/93/2c/ae/23c5322c97f4ea4b77b566ff85638a1b92198cf0836e7fab90
    Successfully built soothsayer
    Installing collected packages: soothsayer
    Successfully installed soothsayer-2019.12
    
    Resource usage statistics from building soothsayer:
       Process count: 3
       CPU time: Sys=0:00:00.4, User=0:00:00.7
       Memory: 57.2M
       Disk usage: 4.2K
       Time elapsed: 0:00:04.1
    
    Packaging soothsayer
    INFO:conda_build.build:Packaging soothsayer
    INFO conda_build.build:build(1551): Packaging soothsayer
    Packaging soothsayer-py36_2019.12-0
    INFO:conda_build.build:Packaging soothsayer-py36_2019.12-0
    INFO conda_build.build:bundle_conda(890): Packaging soothsayer-py36_2019.12-0
    No files or script found for output soothsayer
    WARNING:conda_build.build:No files or script found for output soothsayer
    WARNING conda_build.build:bundle_conda(970): No files or script found for output soothsayer
    number of files: 0
    Fixing permissions
    Packaged license file/s.
    TEST START: /Users/jespinoz/anaconda3/conda-bld/noarch/soothsayer-py36_2019.12-0.tar.bz2
    Adding in variants from /var/folders/6z/5vbtz_gmkr76ftgc3149dvtr0003c0/T/tmp6matkfoy/info/recipe/conda_build_config.yaml
    INFO:conda_build.variants:Adding in variants from /var/folders/6z/5vbtz_gmkr76ftgc3149dvtr0003c0/T/tmp6matkfoy/info/recipe/conda_build_config.yaml
    INFO conda_build.variants:_combine_spec_dictionaries(189): Adding in variants from /var/folders/6z/5vbtz_gmkr76ftgc3149dvtr0003c0/T/tmp6matkfoy/info/recipe/conda_build_config.yaml
    Nothing to test for: /Users/jespinoz/anaconda3/conda-bld/noarch/soothsayer-py36_2019.12-0.tar.bz2
    Renaming work directory,  /Users/jespinoz/anaconda3/conda-bld/soothsayer_1578343428831/work  to  /Users/jespinoz/anaconda3/conda-bld/soothsayer_1578343428831/work_moved_soothsayer-py36_2019.12-0_osx-64_main_build_loop
    # Automatic uploading is disabled
    # If you want to upload package(s) to anaconda.org later, type:
    
    anaconda upload /Users/jespinoz/anaconda3/conda-bld/noarch/soothsayer-py36_2019.12-0.tar.bz2
    
    # To have conda build upload to anaconda.org automatically, use
    # $ conda config --set anaconda_upload yes
    
    anaconda_upload is not set.  Not uploading wheels: []
    ####################################################################################
    Resource usage summary:
    
    Total time: 0:01:52.0
    CPU usage: sys=0:00:00.4, user=0:00:00.7
    Maximum memory usage observed: 57.2M
    Total disk usage observed (not including envs): 4.2K
    
    
    ####################################################################################
    Source and build intermediates have been left in /Users/jespinoz/anaconda3/conda-bld.
    There are currently 1 accumulated.
    To remove them, you can run the ```conda build purge``` command
    

    这是我的 马尼拉 文件:

    (µ_env) jespinozlt-osx:soothsayer jespinoz$ cat MANIFEST.in
    recursive-include soothsayer/io/data_type/ *.py
    recursive-include soothsayer/feature_extraction/algorithms/ *.py
    recursive-include soothsayer/r_wrappers/packages/ *.py
    recursive-include soothsayer/tests/data/ *.py
    recursive-include soothsayer/db/ *.pbz2
    recursive-exclude releases/ *.tar.gz
    global-exclude *.py[cod] __pycache__
    

    我想排除此文件夹中的焦油球:

    (µ_env) jespinozlt-osx:soothsayer jespinoz$ ls -lhS releases/
    total 189456
    -rwxrwxrwx@ 1 jespinoz  tigr    18M Jan  2 11:41 soothsayer_v2019.12.tar.gz
    -rwxrwxrwx@ 1 jespinoz  tigr    18M Dec  2 10:57 soothsayer_v2019.11.tar.gz
    -rwxrwxrwx@ 1 jespinoz  tigr    18M Nov  5 14:13 soothsayer_v2019.10.tar.gz
    -rwxrwxrwx  1 jespinoz  tigr    10M Oct  2 11:26 soothsayer_v2019.09.tar.gz
    -rwxrwxrwx@ 1 jespinoz  tigr    10M Sep  3 11:08 soothsayer_v2019.08.tar.gz
    -rwxrwxrwx@ 1 jespinoz  tigr    10M Aug  8 16:33 soothsayer_v2019.07.tar.gz
    -rwxrwxrwx@ 1 jespinoz  tigr   9.1M Jun 20  2019 soothsayer_v2019.06.tar.gz
    -rw-r--r--@ 1 jespinoz  tigr   659B Jun 20  2019 create_release.sh
    

    它包括我之前的所有版本:

    (µ_env) jespinozlt-osx:noarch jespinoz$ tar -xzf soothsayer-py36_2019.12-0.tar.bz2
    (µ_env) jespinozlt-osx:noarch jespinoz$ ls -lh info/recipe/releases/
    total 192776
    -rw-r--r--  1 jespinoz  tigr   659B Jun 20  2019 create_release.sh
    -rwxr-xr-x  1 jespinoz  tigr   9.1M Jun 20  2019 soothsayer_v2019.06.tar.gz
    -rwxr-xr-x  1 jespinoz  tigr    10M Aug  8 16:33 soothsayer_v2019.07.tar.gz
    -rwxr-xr-x  1 jespinoz  tigr    10M Sep  3 11:08 soothsayer_v2019.08.tar.gz
    -rwxr-xr-x  1 jespinoz  tigr    10M Oct  2 11:26 soothsayer_v2019.09.tar.gz
    -rwxr-xr-x  1 jespinoz  tigr    18M Nov  5 14:13 soothsayer_v2019.10.tar.gz
    -rwxr-xr-x  1 jespinoz  tigr    18M Dec  2 10:57 soothsayer_v2019.11.tar.gz
    -rwxr-xr-x  1 jespinoz  tigr    18M Jan  2 11:41 soothsayer_v2019.12.tar.gz
    

    这是我的 meta.yml

    {% set name = "soothsayer" %}
    {% set version = "2019.12" %}
    
    package:
      name: {{ name|lower }}
      version: py36_{{ version }}
    
    source:
      url: https://github.com/jolespin/{{ name }}/releases/download/v{{ version }}/soothsayer_v{{ version }}.tar.gz
    
    build:
      noarch: python
      number: 0
      script: python -m pip install --no-deps --ignore-installed .
    
    requirements:
      run:
        - python >=3.6,<3.7
    
    about:
      home: https://github.com/jolespin/soothsayer
      license: BSD-3
      license_family: BSD
      license_file: license.txt
      summary: 'High-level package for (bio-)informatics'
      description: 'This module contains analytical tools and sophisticated plotting methods for informatics datasets.'
    
    0 回复  |  直到 5 年前
        1
  •  0
  •   Bradley Kreider    4 年前

    这是解决这里出现的任何问题的变通方法。您始终可以将构建脚本拆分为一个名为build.sh的文件,并手动执行 rm -rf releases 最后。

    rm -rf $PREFIX/info/recipe/releases
    

    Conda-build只是对脚本命令所做的一切进行tar存档。虽然这是在info/recipe下,所以这可能是你的食谱目录的内容。我会将你的配方移动到一个子目录(conda.recipe)中并从那里运行它,或者你可以告诉conda-build(在meta.yaml中)不要使用开关包含配方: --no-include-recipe