conda-forge / compilers-feedstock

A conda-smithy repository for compilers.
BSD 3-Clause "New" or "Revised" License
9 stars 17 forks source link

When installing`c-compiler` on Windows, VS 2022 Build Tools init file is not installed #66

Open Dr-Irv opened 3 weeks ago

Dr-Irv commented 3 weeks ago

Solution to issue cannot be found in the documentation.

Issue

Not sure if this issue goes here or somewhere else.

This is on Windows 11. First you install the latest Visual Studio 2022 Build Tools. No other Visual Studio is installed.

If you create a new environment, and do conda install c-compiler -c conda-forge, the batch file that is installed in \envs\pandas-dev\etc\conda\activate.d is vs2019_compiler_vars.bat which does not work with Microsoft Visual Studio 2022 Build Tools.

Installing c-compiler causes vs2019_win-x64 to be installed. I would have expected vs2022_win-x64 to be installed.

If I first install vs2022_win-x64 , then c-compiler, then remove \envs\pandas-dev\etc\conda\activate.d\vs2019_compiler_vars.bat, then edit vs2022_compiler_vars.bat to use version 14.41, instead of 14.40, I think it will work properly.

Trying to do this for building pandas on Windows.

Installed packages

# Name                    Version                   Build  Channel
bzip2                     1.0.8                h2bbff1b_6
c-compiler                1.7.0                hcfcfb64_1    conda-forge
ca-certificates           2024.7.4             h56e8100_0    conda-forge
expat                     2.6.2                hd77b12b_0
libffi                    3.4.4                hd77b12b_1
openssl                   3.3.1                h2466b09_2    conda-forge
pip                       24.2            py312haa95532_0
python                    3.12.4               h14ffc60_1
setuptools                72.1.0          py312haa95532_0
sqlite                    3.45.3               h2bbff1b_0
tk                        8.6.14               h0416ee5_0
tzdata                    2024a                h04d1e81_0
ucrt                      10.0.22621.0         h57928b3_0    conda-forge
vc                        14.40                h2eaa2aa_0
vc14_runtime              14.40.33810         ha82c5b3_20    conda-forge
vs2015_runtime            14.40.33810         h3bf8584_20    conda-forge
vs2019_win-64             19.29.30139         he1865b1_20    conda-forge
vswhere                   3.1.7                h57928b3_0    conda-forge
wheel                     0.43.0          py312haa95532_0
xz                        5.4.6                h8cc25b3_1
zlib                      1.2.13               h8cc25b3_1

Environment info

active environment : compiler-test
    active env location : C:\Condadirs\envs\compiler-test
            shell level : 1
       user config file : C:\Users\Irv\.condarc
 populated config files : C:\Users\Irv\.condarc
          conda version : 24.7.1
    conda-build version : 24.5.1
         python version : 3.12.3.final.0
                 solver : libmamba (default)
       virtual packages : __archspec=1=skylake
                          __conda=24.7.1=0
                          __cuda=12.2=0
                          __win=0=0
       base environment : C:\Anaconda3  (read only)
      conda av data dir : C:\Anaconda3\etc\conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
                          http://conda.anaconda.org/gurobi/win-64
                          http://conda.anaconda.org/gurobi/noarch
          package cache : C:\Condadirs\pkgs
       envs directories : C:\Condadirs\envs
                          C:\Users\Irv\.conda\envs
                          C:\Anaconda3\envs
                          C:\Users\Irv\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/24.7.1 requests/2.32.2 CPython/3.12.3 Windows/11 Windows/10.0.22631 solver/libmamba conda-libmamba-solver/24.1.0 libmambapy/1.5.8 aau/0.4.4 c/. s/. e/.
          administrator : False
             netrc file : None
           offline mode : False
AnujChitari commented 2 weeks ago

It is absolutely possible to develop with Visual Studio 2022 Build Tools on Windows. The issue you're encountering with the init file not being installed is likely an isolated problem that can be resolved with the right steps.

1)Verify Build Tools Installation Make sure that Visual Studio 2022 Build Tools are properly installed:

Open the Visual Studio Installer. Ensure you have Visual Studio Build Tools 2022 installed. Under Workloads, make sure Desktop development with C++ is selected.

2)Install Required Components Sometimes, specific components might be missing: In the Visual Studio Installer, click Modify on the Build Tools installation. Ensure that MSVC v143 - VS 2022 C++ x64/x86 build tools and C++ CMake tools for Windows are selected.

3)Run the Build Tools Command Line To check if the command-line tools are working, open the Developer Command Prompt for Visual Studio or a regular Command Prompt with the appropriate environment setup:

Open Start Menu, search for Developer Command Prompt for Visual Studio 2022, and run it. Try running cl.exe to see if the compiler is recognized.

4)Environment Variables Ensure environment variables are set up correctly: Check that paths to cl.exe, link.exe, and other tools are in your PATH environment variable.

AnujChitari commented 2 weeks ago

I hope this should work!

Dr-Irv commented 2 weeks ago

I hope this should work!

This solves the problem, but is not solving the fundamental problem, which is when you install c-compiler from conda-forge, it doesn't install the correct script in \envs\pandas-dev\etc\conda\activate.d\ that causes the conda environment to be properly updated upon activation with the right paths.

The issue is that c-compiler is installing vs2019_win-64 rather than vs2022_win-64