Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build.py passes invalid arguments to subprocess.Popen #68

Closed
ivan-kalev opened this issue Mar 17, 2014 · 9 comments
Closed

build.py passes invalid arguments to subprocess.Popen #68

ivan-kalev opened this issue Mar 17, 2014 · 9 comments
Labels
locked [bot] locked due to inactivity

Comments

@ivan-kalev
Copy link
Contributor

Since I upgraded to the latest version of conda (3.2.1) and conda-build (1.3.0), the following commands fail:

C:\> conda build coverage 
C:\> conda build coverage --test 
[...]
TypeError: environment can only contain strings

The problem is that conda_build/conda.py passes an env argument to subprocess.Popen, containing entries of invalid data types (e.g. unicode strings). Full stack trace:

C:> conda build coverage --test
TEST START: coverage-3.7-py33_1
Fetching package metadata: ....
Solving package specifications: ...
The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    coverage-3.7               |           py33_1         186 KB

The following packages will be linked:

    package                    |            build
    ---------------------------|-----------------
    coverage-3.7               |           py33_1   hard-link
    python-3.3.5               |                0   hard-link

Fetching packages ...
coverage-3.7-py33_1.tar.bz2 100% |##################| Time: 0:00:00  27.18 MB/s
Extracting packages ...
[      COMPLETE      ] |#################################################| 100%
Linking packages ...
[      COMPLETE      ] |#################################################| 100%
Traceback (most recent call last):
  File "C:\Anaconda\Scripts\conda-build-script.py", line 4, in <module>
    sys.exit(main())
  File "C:\Anaconda\lib\site-packages\conda_build\main_build.py", line 76, in main
    args.func(args, p)
  File "C:\Anaconda\lib\site-packages\conda_build\main_build.py", line 189, in execut
    build.test(m)
  File "C:\Anaconda\lib\site-packages\conda_build\build.py", line 347, in test
    env=env, cwd=tmp_dir)
  File "C:\Anaconda\lib\subprocess.py", line 537, in check_call
    retcode = call(*popenargs, **kwargs)
  File "C:\Anaconda\lib\subprocess.py", line 524, in call
    return Popen(*popenargs, **kwargs).wait()
  File "C:\Anaconda\lib\subprocess.py", line 711, in __init__
    errread, errwrite)
  File "C:\Anaconda\lib\subprocess.py", line 948, in _execute_child
    startupinfo)
TypeError: environment can only contain strings
@asmeurer
Copy link
Contributor

Are you in Python 3?

@ivan-kalev
Copy link
Contributor Author

My root environment is python 2.7-based (full anaconda, i.e. not miniconda). This bug is reproducible with either value of %CONDA_PY% (33 and 27).

@ivan-kalev
Copy link
Contributor Author

Here is a simple test case:

>>> import subprocess
>>> subprocess.Popen(["cmd.exe"], env={u"TEST": ""})
  File "C:\Anaconda\envs\py27\lib\subprocess.py", line 957, in _execute_child
    startupinfo)
TypeError: environment can only contain strings

>>> subprocess.Popen(["cmd.exe"], env={"TEST": ""})
<subprocess.Popen object at 0x0000000002A37748>

Note that this is an issue on Python 2 only, because in Python 3 u"str" is "str".

@asmeurer
Copy link
Contributor

The important thing is the version of Python that conda itself is running in. Python 3 has no "unicode strings".

@asmeurer
Copy link
Contributor

I guess an easy fix would be to call str on each variable. This will be a no-op in Python 3 and convert unicode to str in Python 2. If any of the strings contain non-ascii characters it will fail, but looking through the code, I don't think that can happen.

@H0R5E
Copy link

H0R5E commented Jul 3, 2014

There is a similar problem with "conda skeleton pypi" for 2.7 on win-64.

> conda skeleton pypi watchdog
Using url https://pypi.python.org/packages/source/w/watchdog/watchdog-0.8.0.tar.gz (152770) for watchdog.
Downloading watchdog (use --no-download to skip this step)
Unpacking watchdog...
done
working in c:\users\matthe~1\appdata\local\temp\tmphybgnbconda_skeleton_watchdog
Fetching package metadata: ....
Solving package specifications: .
The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    python-2.7.8               |                0        17.1 MB

The following packages will be UN-linked:

    package                    |            build
    ---------------------------|-----------------
    python-2.7.7               |                2

The following packages will be linked:

    package                    |            build
    ---------------------------|-----------------
    python-2.7.8               |                0   hard-link
    pyyaml-3.11                |           py27_0   hard-link

Fetching packages ...
python-2.7.8-0 100% |###############################| Time: 0:00:27 659.82 kB/s
Extracting packages ...
[      COMPLETE      ] |#################################################| 100%
Unlinking packages ...
[      COMPLETE      ] |#################################################| 100%
Linking packages ...
[      COMPLETE      ] |#################################################| 100%
Applying patch: u'c:\\users\\matthe~1\\appdata\\local\\temp\\tmphybgnbconda_skeleton_watchdog\\pypi-distutils.patch'
patching file core.py
Hunk #1 succeeded at 169 with fuzz 2 (offset 2 lines).
Traceback (most recent call last):
  File "C:\Anaconda\Scripts\conda-skeleton-script.py", line 4, in <module>
    sys.exit(main())
  File "C:\Anaconda\lib\site-packages\conda_build\main_skeleton.py", line 124, in main
    args.func(args, p)
  File "C:\Anaconda\lib\site-packages\conda_build\main_skeleton.py", line 135, in execute
    pypi.main(args, parser)
  File "C:\Anaconda\lib\site-packages\conda_build\pypi.py", line 313, in main
    run_setuppy(src_dir, tempdir, args)
  File "C:\Anaconda\lib\site-packages\conda_build\pypi.py", line 491, in run_setuppy
    subprocess.check_call(args, env=env)
  File "C:\Anaconda\lib\subprocess.py", line 535, in check_call
    retcode = call(*popenargs, **kwargs)
  File "C:\Anaconda\lib\subprocess.py", line 522, in call
    return Popen(*popenargs, **kwargs).wait()
  File "C:\Anaconda\lib\subprocess.py", line 709, in __init__
    errread, errwrite)
  File "C:\Anaconda\lib\subprocess.py", line 957, in _execute_child
    startupinfo)
TypeError: environment can only contain strings

> conda info
Current conda install:

             platform : win-64
        conda version : 3.5.5
       python version : 2.7.6.final.0
     root environment : C:\Anaconda  (writable)
  default environment : C:\Anaconda
     envs directories : C:\Anaconda\envs
        package cache : C:\Anaconda\pkgs
         channel URLs : http://repo.continuum.io/pkgs/free/win-64/
                        http://repo.continuum.io/pkgs/pro/win-64/
          config file : C:\Users\matthewtopper\.condarc
    is foreign system : False

@asmeurer
Copy link
Contributor

asmeurer commented Jul 3, 2014

This should be fixed in the latest version of conda-build. conda update conda-build.

@H0R5E
Copy link

H0R5E commented Jul 4, 2014

Yes, thanks. I was using 1.3.1. Perhaps worth including this update in the anaconda package? I updated anaconda to 2.0.1 yesterday.

@github-actions
Copy link

Hi there, thank you for your contribution!

This issue has been automatically locked because it has not had recent activity after being closed.

Please open a new issue if needed.

Thanks!

@github-actions github-actions bot added the locked [bot] locked due to inactivity label Apr 27, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked [bot] locked due to inactivity
Projects
None yet
Development

No branches or pull requests

3 participants