Conda build fails to set some build environment variables during the build process.
During build I get the following error message
%SRC_DIR%>et "CONDA_BUILD=1"
'et' is not recognized as an internal or external command,
operable program or batch file.
Inspecting the build_env_setup.bat
(temporary file in build work folder) it is suppose to set "CONDA_BUILD=1"
.
That is, it has somehow lost the s
from set
. This happens for roughly half of the set
calls in the build_env_setup.bat
.
I have tried building on another Windows machine and (using the equivalent build.sh
) on Debian (wsl) and it works. So it seems to be an error on my machine. Uninstall + install Miniconda did nothing.
What can cause this error and how may I resolve it?
Update / Extra Info
build_env_setup.bat
has Unix style line-endings (LF) changing to CRLF make the build_env_setup.bat
script work.build_env_setup.bat
script work. Conclusion seems to be that there is some string encoding / reading mismatch when running the various build scrips using PowerShell in the (edge?) cases with special characters in paths.
Old formulation
I am attempting to build a conda package from a standard src-layout python library but my builds keeps failing when using a Windows build script bld.bat
with the error message:
'(_h_env)%SRC_DIR%>"" setup.py install
'""' is not recognized as an internal or external command,
operable program or batch file.
This seems to indicate that the %PYTHON%
environment variable is not defined. (Which I was assuming to exist based on Environment variables and Writing the build script files )
If I add a build
section to the meta.yaml
:
build:
noarch: python
script: "{{ PYTHON }} setup.py install"
Then the build works.
What is the reason for this behavior and where is the error when using the build script?
│ setup.py
│
├───conda_recipe
│ bld.bat
│ meta.yaml
│
└───src
└───conda_build_test
module.py
__init__.py
"%PYTHON%" setup.py install
if errorlevel 1 exit 1
package:
name: conda_build_test
version: {{ data.get('version') }}
source:
path: ..
requirements:
build:
- python
- setuptools
run:
- python
Notice that the documentation on environment variables states that %PYTHON%
is only defined when python
is specified as a host requirement (eg, in a cross-compiling situation). In a native build situation, where python
is directly in the build requirements, the build environment's bin/
will be on PATH and one can use python
directly. That is,
bld.bat
python %SRC_DIR%/setup.py install
For a comparable example, the Conda Forge multineat
feedstock recipe uses a setup.py
-based build.
Alternatively, you can place the python
requirement under host instead of build and that should enable use of %PYTHON%
variable.
I'm not entirely clear on why there isn't a failure after the meta.yaml
edit. Somehow the {{ PYTHON }}
jinja template must not be the same as the environment variable. However, the examples on Conda Forge I find that use a similar {{ PYTHON }} setup.py install
seem to also list python
as a host requirement (eg, wfdb
feedstock ).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.