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

Setup is being failed #2

Open
ping543f opened this issue Mar 1, 2020 · 11 comments
Open

Setup is being failed #2

ping543f opened this issue Mar 1, 2020 · 11 comments

Comments

@ping543f
Copy link

ping543f commented Mar 1, 2020

python version 3.7 and pip version 19.0.3
After issuing pip install hwcounter the following message are showing. Could you please check it.
C:\Users\mdsae>pip install hwcounter
Collecting hwcounter
Using cached https://files.pythonhosted.org/packages/83/8d/855522fe8beb584e7ce748e551122943607655628c7a4a1be0270e2d8c07/hwcounter-0.1.1.tar.gz
Building wheels for collected packages: hwcounter
Building wheel for hwcounter (setup.py) ... error
Complete output from command C:\Users\mdsae\anaconda3\python.exe -u -c "import setuptools, tokenize;file='C:\Users\mdsae\AppData\Local\Temp\pip-install-_3i9s9z1\hwcounter\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" bdist_wheel -d C:\Users\mdsae\AppData\Local\Temp\pip-wheel-xzvzksnp --python-tag cp37:
running bdist_wheel
running build
running build_ext
building 'hwcounter' extension
creating build
creating build\temp.win-amd64-3.7
creating build\temp.win-amd64-3.7\Release
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.24.28314\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -IC:\Users\mdsae\anaconda3\include -IC:\Users\mdsae\anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.24.28314\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" /Tchwcounter.c /Fobuild\temp.win-amd64-3.7\Release\hwcounter.obj
hwcounter.c
hwcounter.c(36): error C2065: 'asm': undeclared identifier
hwcounter.c(36): error C2143: syntax error: missing ';' before 'volatile'
hwcounter.c(37): error C2065: 'asm': undeclared identifier
hwcounter.c(37): error C2143: syntax error: missing ';' before 'volatile'
hwcounter.c(38): error C2065: 'asm': undeclared identifier
hwcounter.c(38): error C2143: syntax error: missing ';' before 'volatile'
hwcounter.c(54): error C2065: 'asm': undeclared identifier
hwcounter.c(54): error C2143: syntax error: missing ';' before 'volatile'
hwcounter.c(65): error C2065: 'asm': undeclared identifier
hwcounter.c(65): error C2143: syntax error: missing ';' before 'volatile'
hwcounter.c(103): error C2065: 'asm': undeclared identifier
hwcounter.c(103): error C2143: syntax error: missing ';' before 'volatile'
hwcounter.c(115): error C2065: 'asm': undeclared identifier
hwcounter.c(115): error C2143: syntax error: missing ';' before 'volatile'
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.24.28314\bin\HostX86\x64\cl.exe' failed with exit status 2


Failed building wheel for hwcounter
Running setup.py clean for hwcounter
Failed to build hwcounter

@daothinga
Copy link

Hello,
I faced the same problem when trying to install hwcounter package on windows 10.
Later, this package was successfully installed on Ubuntu 20.0.
Hope the answer is helpful to you.

@ping543f
Copy link
Author

ping543f commented Sep 24, 2020 via email

@estelelenath
Copy link

I use also Ubuntu, but it doesn't work too, becasue of same problem, with error Status 1

@eabase

This comment was marked as resolved.

@eabase
Copy link

eabase commented Nov 25, 2022

Everywhere, everyone says not to use the inline assembly for RDTSC on Windows, because it's too messy and there is already support for intrinsics.

The code here, reads:

#define HWCOUNTER_GET_TIMESTAMP(count_ptr)                          \
    do {                                                            \
        uint32_t count_high, count_low;                             \
        asm volatile (                                              \
                "cpuid\n\t"                                         \
                "rdtsc\n\t"                                         \
                : "=a" (count_low), "=d" (count_high)               \
                :: "ebx", "ecx");                                   \
        *count_ptr = ((uint64_t)count_high << 32) | count_low;      \
    } while(0)

#define HWCOUNTER_GET_TIMESTAMP_END(count_ptr)                      \
    do {                                                            \
        uint32_t count_high, count_low;                             \
        asm volatile (                                              \
                "rdtscp\n\t"                                        \
                "mov %%edx, %0\n\t"                                 \
                "mov %%eax, %1\n\t"                                 \
                "cpuid\n\t"                                         \
                : "=r" (count_high), "=r" (count_low)               \
                :: "eax", "ebx", "ecx", "edx");                     \
        *count_ptr = ((uint64_t)count_high << 32) | count_low;      \
    } while(0)

Some questions.

  1. Why are you using while(0)?
    (My guess is to prevent OOE?)
  2. Why are you using a different function for ending read of RDTSC and using RTSCP?
  3. This seem to suggest that :

If we are using an IA64 rather than an IA32 platform, in the list of clobbered registers we have to replace:
"%eax", "%ebx", "%ecx", "%edx" with:
"%rax", "%rbx", "%rcx", "%rdx".

and that:

The RDTSCP instruction is an assembly instruction that, at the same time, reads the timestamp register and the CPU identifier. The value of the timestamp register is stored into the EDX and EAX registers; the value of the CPU id is stored into the ECX register. On IA64 processors that support the IA64, the high order 32 bits of each of RAX, RDX, and RCX are cleared.


image


Windows & RDTSC

In Windows, the basic example simply reads:

// rdtsc.cpp
// processor: x86, x64
#include <stdio.h>

#ifdef _WIN32
#include <intrin.h>
#else
#include <x86intrin.h>
#endif

#pragma intrinsic(__rdtsc)

int main()
{
    unsigned __int64 i;
    i = __rdtsc();
    printf_s("%I64d ticks\n", i);
}

For Windows MS Visual Studio or VC, we need to use:


In either case I managed to use MSYS2 MinGW compiler without an issue, by using the methods mentioned here:

@eabase
Copy link

eabase commented Nov 27, 2022

Fixed!

The following changes will fix hwcounter.c to compile for MSVC, when installing using pip install . on Windows Python.

#if defined(_MSC_BUILD) && defined(_WIN32)
    //---------------------------------------------------------
    //  For Windows MSVC C/C++ Compatibility
    //---------------------------------------------------------
    #include <intrin.h>
    #pragma intrinsic(__rdtsc)    
    #define HWCOUNTER_GET_TIMESTAMP(count_ptr)      do {               *count_ptr = (uint64_t) __rdtsc();     } while(0)
    #define HWCOUNTER_GET_TIMESTAMP_END(count_ptr)  do { uint32_t ui;  *count_ptr = (uint64_t) __rdtscp(&ui); } while(0)
#else
    //---------------------------------------------------------
    // For other Compilers or Platforms
    //---------------------------------------------------------
    #define HWCOUNTER_GET_TIMESTAMP(count_ptr)                          \
        do {                                                            \
            uint32_t count_high, count_low;                             \
            asm volatile (                                              \
                    "cpuid\n\t"                                         \
                    "rdtsc\n\t"                                         \
                    : "=a" (count_low), "=d" (count_high)               \
                    :: "ebx", "ecx");                                   \
            *count_ptr = ((uint64_t)count_high << 32) | count_low;      \
        } while(0)

    #define HWCOUNTER_GET_TIMESTAMP_END(count_ptr)                      \
        do {                                                            \
            uint32_t count_high, count_low;                             \
            asm volatile (                                              \
                    "rdtscp\n\t"                                        \
                    "mov %%edx, %0\n\t"                                 \
                    "mov %%eax, %1\n\t"                                 \
                    "cpuid\n\t"                                         \
                    : "=r" (count_high), "=r" (count_low)               \
                    :: "eax", "ebx", "ecx", "edx");                     \
            *count_ptr = ((uint64_t)count_high << 32) | count_low;      \
        } while(0)
    //---------------------------------------------------------
#endif

uint64_t
hwcounter_measure_overhead(void) {
    uint64_t t0, t1, elapsed, overhead = ~0;
    // We should probably average over many more, maybe 3,000,000 ?
    // https://www.intel.com/content/www/us/en/embedded/training/ia-32-ia-64-benchmark-code-execution-paper.html
    for (int i = 0; i < 3; i++) {
        HWCOUNTER_GET_TIMESTAMP(&t0);
#if defined(_MSC_BUILD) && defined(_WIN32)
        void __nop();
#else
        asm volatile("");
#endif
        HWCOUNTER_GET_TIMESTAMP_END(&t1);
        elapsed = t1 - t0;
        if (elapsed < overhead)
            overhead = elapsed;
    }

    return overhead;
}

@pgarraul
Copy link

Hello All, after editing the patch a explained by @eabase getting this error

(.venv) PS C:\test> pip install --use-pep517 .\hwcounter-0.1.1.tar.gz
Processing c:\test\hwcounter-0.1.1.tar.gz
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: hwcounter
  Building wheel for hwcounter (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for hwcounter (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [14 lines of output]
      running bdist_wheel
      running build
      running build_ext
      building 'hwcounter' extension
      creating build
      creating build\temp.win-amd64-cpython-39
      creating build\temp.win-amd64-cpython-39\Release
      "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\test\.venv\include -IC:\python39\include -IC:\python39\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /Tchwcounter.c /Fobuild\temp.win-amd64-cpython-39\Release\hwcounter.obj
      hwcounter.c
      creating C:\Users\pgarraul\AppData\Local\Temp\pip-req-build-nqpmfbt_\build\lib.win-amd64-cpython-39
      "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\link.exe" /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\test\.venv\libs /LIBPATH:C:\python39\libs /LIBPATH:C:\python39 /LIBPATH:C:\test\.venv\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\lib\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.17763.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.17763.0\um\x64" /EXPORT:PyInit_hwcounter build\temp.win-amd64-cpython-39\Release\hwcounter.obj /OUT:build\lib.win-amd64-cpython-39\hwcounter.cp39-win_amd64.pyd /IMPLIB:build\temp.win-amd64-cpython-39\Release\hwcounter.cp39-win_amd64.lib
      LINK : error LNK2001: unresolved external symbol PyInit_hwcounter
      build\temp.win-amd64-cpython-39\Release\hwcounter.cp39-win_amd64.lib : fatal error LNK1120: 1 unresolved externals
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\link.exe' failed with exit code 1120
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for hwcounter
Failed to build hwcounter
ERROR: Could not build wheels for hwcounter, which is required to install pyproject.toml-based projects

anyone sees why this link issue?
win10, python 3.9.7

@eabase
Copy link

eabase commented Dec 14, 2022

@pgarraul Why are you using --use-pep517?
IIRC that caused problems..

Also try changing the includes to:

#define PY_SSIZE_T_CLEAN    // Make "s#" use Py_ssize_t rather than int.

#include <stddef.h>
#include <Python.h>
#include "structmember.h"

@pgarraul
Copy link

pgarraul commented Dec 14, 2022

Thank you so much @eabase for your prompt reply. tried the following without success

header for hwcounter.c

#define PY_SSIZE_T_CLEAN    // Make "s#" use Py_ssize_t rather than int.
#include <stddef.h>
#include <Python.h>
#include "structmember.h"


#if defined(_MSC_BUILD) && defined(_WIN32)
    //---------------------------------------------------------
    //  For Windows MSVC C/C++ Compatibility
    //---------------------------------------------------------
    #include <intrin.h>
    #pragma intrinsic(__rdtsc)    
    #define HWCOUNTER_GET_TIMESTAMP(count_ptr)      do {               *count_ptr = (uint64_t) __rdtsc();     } while(0)
    #define HWCOUNTER_GET_TIMESTAMP_END(count_ptr)  do { uint32_t ui;  *count_ptr = (uint64_t) __rdtscp(&ui); } while(0)
#else
    //---------------------------------------------------------
    // For other Compilers or Platforms
    //---------------------------------------------------------
    #define HWCOUNTER_GET_TIMESTAMP(count_ptr)                          \
        do {                                                            \
            uint32_t count_high, count_low;                             \
            asm volatile (                                              \
                    "cpuid\n\t"                                         \
                    "rdtsc\n\t"                                         \
                    : "=a" (count_low), "=d" (count_high)               \
                    :: "ebx", "ecx");                                   \
            *count_ptr = ((uint64_t)count_high << 32) | count_low;      \
        } while(0)

    #define HWCOUNTER_GET_TIMESTAMP_END(count_ptr)                      \
        do {                                                            \
            uint32_t count_high, count_low;                             \
            asm volatile (                                              \
                    "rdtscp\n\t"                                        \
                    "mov %%edx, %0\n\t"                                 \
                    "mov %%eax, %1\n\t"                                 \
                    "cpuid\n\t"                                         \
                    : "=r" (count_high), "=r" (count_low)               \
                    :: "eax", "ebx", "ecx", "edx");                     \
            *count_ptr = ((uint64_t)count_high << 32) | count_low;      \
        } while(0)
    //---------------------------------------------------------
#endif
...

command: (.venv) PS C:\test> pip install -vvv .\hwcounter-0.1.1.tar.gz


Using pip 22.3.1 from C:\test\.venv\lib\site-packages\pip (python 3.9)
Non-user install because user site-packages disabled
Created temporary directory: C:\Users\pgarraul\AppData\Local\Temp\pip-build-tracker-lda44ezy
Initialized build tracking at C:\Users\pgarraul\AppData\Local\Temp\pip-build-tracker-lda44ezy
Created build tracker: C:\Users\pgarraul\AppData\Local\Temp\pip-build-tracker-lda44ezy
Entered build tracker: C:\Users\pgarraul\AppData\Local\Temp\pip-build-tracker-lda44ezy
Created temporary directory: C:\Users\pgarraul\AppData\Local\Temp\pip-install-yr64l_7q
Created temporary directory: C:\Users\pgarraul\AppData\Local\Temp\pip-ephem-wheel-cache-72kihil4
Processing c:\test\hwcounter-0.1.1.tar.gz
  Created temporary directory: C:\Users\pgarraul\AppData\Local\Temp\pip-req-build-ss6ai3_z
  Added file:///C:/test/hwcounter-0.1.1.tar.gz to build tracker 'C:\\Users\\pgarraul\\AppData\\Local\\Temp\\pip-build-tracker-lda44ezy'
  Running setup.py (path:C:\Users\pgarraul\AppData\Local\Temp\pip-req-build-ss6ai3_z\setup.py) egg_info for package from file:///C:/test/hwcounter-0.1.1.tar.gz
  Created temporary directory: C:\Users\pgarraul\AppData\Local\Temp\pip-pip-egg-info-htdhyxix
  Running command python setup.py egg_info
  running egg_info
  creating C:\Users\pgarraul\AppData\Local\Temp\pip-pip-egg-info-htdhyxix\hwcounter.egg-info
  writing C:\Users\pgarraul\AppData\Local\Temp\pip-pip-egg-info-htdhyxix\hwcounter.egg-info\PKG-INFO
  writing dependency_links to C:\Users\pgarraul\AppData\Local\Temp\pip-pip-egg-info-htdhyxix\hwcounter.egg-info\dependency_links.txt
  writing top-level names to C:\Users\pgarraul\AppData\Local\Temp\pip-pip-egg-info-htdhyxix\hwcounter.egg-info\top_level.txt
  writing manifest file 'C:\Users\pgarraul\AppData\Local\Temp\pip-pip-egg-info-htdhyxix\hwcounter.egg-info\SOURCES.txt'
  reading manifest file 'C:\Users\pgarraul\AppData\Local\Temp\pip-pip-egg-info-htdhyxix\hwcounter.egg-info\SOURCES.txt'
  writing manifest file 'C:\Users\pgarraul\AppData\Local\Temp\pip-pip-egg-info-htdhyxix\hwcounter.egg-info\SOURCES.txt'
  Preparing metadata (setup.py) ... done
  Source in c:\users\pgarraul\appdata\local\temp\pip-req-build-ss6ai3_z has version 0.1.1, which satisfies requirement hwcounter==0.1.1 from file:///C:/test/hwcounter-0.1.1.tar.gz
  Removed hwcounter==0.1.1 from file:///C:/test/hwcounter-0.1.1.tar.gz from build tracker 'C:\\Users\\pgarraul\\AppData\\Local\\Temp\\pip-build-tracker-lda44ezy'       
Created temporary directory: C:\Users\pgarraul\AppData\Local\Temp\pip-unpack-4s0blvph
Building wheels for collected packages: hwcounter
  Created temporary directory: C:\Users\pgarraul\AppData\Local\Temp\pip-wheel-drxk1asi
  Building wheel for hwcounter (setup.py) ...   Destination directory: C:\Users\pgarraul\AppData\Local\Temp\pip-wheel-drxk1asi
  Running command python setup.py bdist_wheel
  running bdist_wheel
  running build
  running build_ext
  building 'hwcounter' extension
  creating build
  creating build\temp.win-amd64-3.9
  creating build\temp.win-amd64-3.9\Release
  C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\test\.venv\include -IC:\python39\include -IC:\python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\include -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt /Tchwcounter.c /Fobuild\temp.win-amd64-3.9\Release\hwcounter.obj
  hwcounter.c
  creating C:\Users\pgarraul\AppData\Local\Temp\pip-req-build-ss6ai3_z\build\lib.win-amd64-3.9
  C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\test\.venv\libs /LIBPATH:C:\python39\libs /LIBPATH:C:\python39 /LIBPATH:C:\test\.venv\PCbuild\amd64 /LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\lib\x64 /LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.17763.0\ucrt\x64 /LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.17763.0\um\x64 /EXPORT:PyInit_hwcounter build\temp.win-amd64-3.9\Release\hwcounter.obj /OUT:build\lib.win-amd64-3.9\hwcounter.cp39-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.9\Release\hwcounter.cp39-win_amd64.lib
  LINK : error LNK2001: unresolved external symbol PyInit_hwcounter
  build\temp.win-amd64-3.9\Release\hwcounter.cp39-win_amd64.lib : fatal error LNK1120: 1 unresolved externals
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\link.exe' failed with exit code 1120
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: 'C:\test\.venv\Scripts\python.exe' -u -c '
  exec(compile('"'"''"'"''"'"'
  # This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py
  #
  # - It imports setuptools before invoking setup.py, to enable projects that directly
  #   import from `distutils.core` to work with newer packaging standards.
  # - It provides a clear error message when setuptools is not installed.
  # - It sets `sys.argv[0]` to the underlying `setup.py`, when invoking `setup.py` so
  #   setuptools doesn'"'"'t think the script is `-c`. This avoids the following warning:
  #     manifest_maker: standard file '"'"'-c'"'"' not found".
  # - It generates a shim setup.py, for handling setup.cfg-only projects.
  import os, sys, tokenize
  
  try:
      import setuptools
  except ImportError as error:
      print(
          "ERROR: Can not execute `setup.py` since setuptools is not available in "
          "the build environment.",
          file=sys.stderr,
      )
      sys.exit(1)
  
  __file__ = %r
  sys.argv[0] = __file__
  
  if os.path.exists(__file__):
      filename = __file__
      with tokenize.open(__file__) as f:
          setup_py_code = f.read()
  else:
      filename = "<auto-generated setuptools caller>"
      setup_py_code = "from setuptools import setup; setup()"
  
  exec(compile(setup_py_code, filename, "exec"))
  '"'"''"'"''"'"' % ('"'"'C:\\Users\\pgarraul\\AppData\\Local\\Temp\\pip-req-build-ss6ai3_z\\setup.py'"'"',), "<pip-setuptools-caller>", "exec"))' bdist_wheel -d 'C:\Users\pgarraul\AppData\Local\Temp\pip-wheel-drxk1asi'
  cwd: C:\Users\pgarraul\AppData\Local\Temp\pip-req-build-ss6ai3_z\
error
  ERROR: Failed building wheel for hwcounter
  Running setup.py clean for hwcounter
  Running command python setup.py clean
  running clean
  removing 'build\temp.win-amd64-3.9' (and everything under it)
  removing 'build\lib.win-amd64-3.9' (and everything under it)
  'build\bdist.win-amd64' does not exist -- can't clean it
  'build\scripts-3.9' does not exist -- can't clean it
  removing 'build'
Failed to build hwcounter
Installing collected packages: hwcounter
  Created temporary directory: C:\Users\pgarraul\AppData\Local\Temp\pip-record-rw9280ex
  Running command Running setup.py install for hwcounter
  running install
  running build
  running build_ext
  building 'hwcounter' extension
  creating build
  creating build\temp.win-amd64-3.9
  creating build\temp.win-amd64-3.9\Release
  C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\test\.venv\include -IC:\python39\include -IC:\python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\include -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt /Tchwcounter.c /Fobuild\temp.win-amd64-3.9\Release\hwcounter.obj
  hwcounter.c
  creating C:\Users\pgarraul\AppData\Local\Temp\pip-req-build-ss6ai3_z\build\lib.win-amd64-3.9
  C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\test\.venv\libs /LIBPATH:C:\python39\libs /LIBPATH:C:\python39 /LIBPATH:C:\test\.venv\PCbuild\amd64 /LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\lib\x64 /LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.17763.0\ucrt\x64 /LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.17763.0\um\x64 /EXPORT:PyInit_hwcounter build\temp.win-amd64-3.9\Release\hwcounter.obj /OUT:build\lib.win-amd64-3.9\hwcounter.cp39-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.9\Release\hwcounter.cp39-win_amd64.lib
  LINK : error LNK2001: unresolved external symbol PyInit_hwcounter
  build\temp.win-amd64-3.9\Release\hwcounter.cp39-win_amd64.lib : fatal error LNK1120: 1 unresolved externals
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\link.exe' failed with exit code 1120       
  error: subprocess-exited-with-error
  
  × Running setup.py install for hwcounter did not run successfully.
  │ exit code: 1
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: 'C:\test\.venv\Scripts\python.exe' -u -c '
  exec(compile('"'"''"'"''"'"'
  # This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py
  #
  # - It imports setuptools before invoking setup.py, to enable projects that directly
  #   import from `distutils.core` to work with newer packaging standards.
  # - It provides a clear error message when setuptools is not installed.
  # - It sets `sys.argv[0]` to the underlying `setup.py`, when invoking `setup.py` so
  #   setuptools doesn'"'"'t think the script is `-c`. This avoids the following warning:
  #     manifest_maker: standard file '"'"'-c'"'"' not found".
  # - It generates a shim setup.py, for handling setup.cfg-only projects.
  import os, sys, tokenize
  
  try:
      import setuptools
  except ImportError as error:
      print(
          "ERROR: Can not execute `setup.py` since setuptools is not available in "
          "the build environment.",
          file=sys.stderr,
      )
      sys.exit(1)
  
  __file__ = %r
  sys.argv[0] = __file__
  
  if os.path.exists(__file__):
      filename = __file__
      with tokenize.open(__file__) as f:
          setup_py_code = f.read()
  else:
      filename = "<auto-generated setuptools caller>"
      setup_py_code = "from setuptools import setup; setup()"
  
  exec(compile(setup_py_code, filename, "exec"))
  '"'"''"'"''"'"' % ('"'"'C:\\Users\\pgarraul\\AppData\\Local\\Temp\\pip-req-build-ss6ai3_z\\setup.py'"'"',), "<pip-setuptools-caller>", "exec"))' install --record 'C:\Users\pgarraul\AppData\Local\Temp\pip-record-rw9280ex\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\test\.venv\include\site\python3.9\hwcounter'
  cwd: C:\Users\pgarraul\AppData\Local\Temp\pip-req-build-ss6ai3_z\
  Running setup.py install for hwcounter ... error
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> hwcounter

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

Given the error:
LINK : error LNK2001: unresolved external symbol PyInit_hwcounter
Wonder if my compilation setup is correct? MSVC, ...?

is it possible to download the wheel built for windows 10 64bits from somewhere?
Thanks

@eabase
Copy link

eabase commented Dec 14, 2022

Sorry, mate, IDK. I was using VS 2019. Also make sure to remove all build artifacts after each run of pip install. Seem like VS like to reuse old compile objects. (And I also had the toml file disabled.)

@eabase
Copy link

eabase commented May 27, 2024

@pgarraul
Sorry, only 2 years too late. 😁

It seem that you're missing having installed setuptools.
It also complains about compatibility, so you may need to try some of the following:

$env:SETUPTOOLS_ENABLE_FEATURES="legacy-editable"
pip install -e . --config-settings editable_mode=compat

# Deprecated?
$env:SETUPTOOLS_USE_DISTUTILS="stdlib"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants