pythonwindowscondaconda-build

How to create a custom conda package from python files?


I'm trying to write my first conda package consisting simply of python files. I'm following documentation from a few sources, including here and here.

My problem

When I run conda-build against my package directory, I get this error triggered from my bld.bat:

(base) C:\Windows\system32>conda-build ./package-name --no-anaconda-upload
...
(%PREFIX%) %SRC_DIR%>xcopy ".\lib\" "%PREFIX%\Lib\site-packages\package-name\" /e
Invalid path
0 File(s) copied

From all of the %...% it would seem as though the environmental variables aren't being set properly.

What am I doing wrong? Also, if there is a better/simpler way to build a package from a collection of scripts, I'm all ears.

Further info

I have the following directory structure:

  package-name/
  ├── lib/
  │   ├── python-file1.py
  │   ├── python-file2.py
  │   └── ...
  ├── bld.bat
  ├── build.sh
  └── meta.yaml

My meta.yaml looks like:

package:
  name: package-name
  version: 1.0

source:
  path: .

requirements:
  host:
    - python
  run:
    - python
    ...

any my bld.bat looks like this:

xcopy ".\lib\" "%PREFIX%\Lib\site-packages\package-name\" /e
if errorlevel 1 exit 1

The idea being that all of source files are in the ./lib directory and that they should be copied to site-packages of the installing environment.

n.b. I'm using conda 4.10.3 and conda-build 3.21.4


Solution

  • Turns out that xcopy doesn't like trailing slashes in the source parameter. Also I should have put the /e switch before the arguments.

    So my bld.bat should have looked like this:

    xcopy /e ".\lib" "%PREFIX%\Lib\site-packages\package-name\"
    if errorlevel 1 exit 1