Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure conda build to exclude some folders from the conda package output

tl;dr:

How do you exclude folders from being packaged by conda build ?

Context

I am building my first packages with conda build.

My meta.yaml file looks like this:

package:
    name: 'some_name'
    version: {{ load_setup_py_data().get('version') }}

source:
    path: ./

build:
    script: python setup.py install --single-version-externally-managed --record=record.txt

requirements:
    run:
        - python >=3.6
        - pandas >=0.2
        - numpy >=1.12
        # Packages that must be installed
        # in the user's conda environment
        # to run this package.

    build:
        # Packages used by setup.py
        # to install this package.
        # May also install compilers
        # for non-python code.
        - python
        - setuptools

And my root directory (where lies the setup.py & meta.yaml files) looks like this:

$ ls
README.md   __pycache__      input       isi_classif meta.yaml   
notebooks   output      scripts     setup.py    version.py

Some folders are only there because they were useful during the prototyping but I don't want to delete them from the repo.

How do I exclude a folder (like input or notebooks here) and its content from the package that conda builds ?

For info, I build with the following command:

$ conda build some_folder_name
like image 274
godot Avatar asked Mar 08 '19 00:03

godot


People also ask

Can I use pip in conda?

Built into Anaconda, conda is a powerful package manager and environment manager that you use with command-line in the Anaconda Prompt for Windows, or in a terminal window for macOS or Linux. pip is the standard package manager for python, meaning you can use it both inside and outside of Anaconda.

What is Noarch anaconda?

As of Anaconda Enterprise 4 Repository version 2.6. 0, your Repository supports conda “noarch” packages that contain no operating system-specific files. The conda build system allows you to specify “no architecture” when building a package, so it is compatible with all platforms and architectures.

What is a .conda file?

A conda package is a compressed tarball file that contains system-level libraries, Python or other modules, executable programs and other components. Conda keeps track of the dependencies between packages and platforms.

What is conda skeleton?

The conda skeleton command picks up the PyPI package metadata and prepares the conda-build recipe. The final step is to build the package itself and install it into your conda environment.


1 Answers

I think the best way would be to create a directory recipe/ and move the recipe related files there. Then change the meta.yaml to

source:
    path: ./..

So only the contents of the recipe directory would be copied over by conda into the package. Secondly, the folders notebooks and input would only be included if they are specified in the setup.py to be included. Otherwise they are ignored. So they are not installed as part of the setup.py install and would not be included in the package. So your source directory structure would look like:

some_folder_name
|--README.md
|--__pycache__
|--input
|--isi_classif
|--recipe
   |--meta.yaml   
|--notebooks
|--output
|--scripts
|--setup.py
|--version.py

then you could still build the package using conda build some_folder_name

like image 194
Alan Abraham Avatar answered Oct 24 '22 04:10

Alan Abraham