question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: windows 10 `pip install eth-ape` fails building `pyethhash` error: `'alloca.h': No such file or directory`

See original GitHub issue

Environment information

  • ape and plugin versions:
`eth_ape-0.1.0a14-py3-none-any.whl`
  • Python Version: 3.8.3
  • OS: Windows 10

What went wrong?

PS> pip install eth-ape errors installing pyethhash dependency fatal error C1083: Cannot open include file: 'alloca.h': No such file or directory

How can it be fixed?

upstream issue in pyethhash https://github.com/ConsenSys/ethjsonrpc/issues/5

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
lost-theorycommented, Oct 1, 2021

Yes, I tried that -D MS_WIN64 flag and it didn’t do anything. Here’s how I was able to workaround this issue and get Ape to install on Windows

  1. Clone github.com/ethereum/ethash
  2. Apply this patch:
diff --git a/setup.py b/setup.py
index 18aa20f..fd01603 100755
--- a/setup.py
+++ b/setup.py
@@ -38,7 +38,7 @@ setup(
     author="Matthew Wampler-Doty",
     author_email="matthew.wampler.doty@gmail.com",
     license='GPL',
-    version='0.1.23',
+    version='0.1.27',
     url='https://github.com/ethereum/ethash',
     download_url='https://github.com/ethereum/ethash/tarball/v23',
     description=('Python wrappers for ethash, the ethereum proof of work'
diff --git a/src/libethash/io_win32.c b/src/libethash/io_win32.c
index 34f1aaa..30f819f 100644
--- a/src/libethash/io_win32.c
+++ b/src/libethash/io_win32.c
@@ -89,6 +89,8 @@ bool ethash_get_default_dirname(char* strbuf, size_t buffsize)
 {
 	static const char dir_suffix[] = "Ethash\\";
 	strbuf[0] = '\0';
+	return false;
+	/*
 	if (!SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, (CHAR*)strbuf))) {
 		return false;
 	}
@@ -97,4 +99,5 @@ bool ethash_get_default_dirname(char* strbuf, size_t buffsize)
 	}
 
 	return ethash_strncat(strbuf, buffsize, dir_suffix, sizeof(dir_suffix));
+	*/
 }
diff --git a/src/libethash/util_win32.c b/src/libethash/util_win32.c
index 268e6db..59693b9 100644
--- a/src/libethash/util_win32.c
+++ b/src/libethash/util_win32.c
@@ -35,4 +35,4 @@ void debugf(char const* str, ...)
 	_vsnprintf_s(buf, sizeof(buf), sizeof(buf), str, args);
 	buf[sizeof(buf)-1] = '\0';
 	OutputDebugStringA(buf);
-}
+}
\ No newline at end of file
diff --git a/src/python/core.c b/src/python/core.c
index c66e03c..e89d40c 100644
--- a/src/python/core.c
+++ b/src/python/core.c
@@ -1,5 +1,5 @@
 #include <Python.h>
-#include <alloca.h>
+#include <malloc.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <time.h>
diff --git a/test/c/test.cpp b/test/c/test.cpp
index 44e0c38..de5d3aa 100644
--- a/test/c/test.cpp
+++ b/test/c/test.cpp
@@ -296,7 +296,7 @@ BOOST_AUTO_TEST_CASE(test_ethash_get_default_dirname) {
 	// TODO: Improve this test ...
 #ifdef _WIN32
 	char homedir[256];
-	BOOST_REQUIRE(SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_PROFILE, NULL, 0, (CHAR*)homedir)));
+	//BOOST_REQUIRE(SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_PROFILE, NULL, 0, (CHAR*)homedir)));
 	BOOST_REQUIRE(ethash_get_default_dirname(result, 256));
 	std::string res = std::string(homedir) + std::string("\\AppData\\Local\\Ethash\\");
 #else
  1. Create a venv and run python setup.py install for ethash in the venv.
  2. Now you can do pip install eth-ape or pip install -e .[dev] in the ape repo and it’ll use the already installed version of pyethash when installing all the dependencies (it’s actually py-evm which requires pyethash>=0.1.27,<1.0.0).

Note that the patch in step 2 may be removing some important code. It’s not a real fix, just a workaround I came up with to see if the package would build.

0reactions
NotPeopling2daycommented, Apr 11, 2022

No CI support yet this ticket blocked lost-theory in https://github.com/ApeWorX/ape-hardhat/pull/2

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot compile pyethash python package which requires C99 ...
I think it is x86 / x64 compability error. I've used python 3.9.0 and these steps worked for me (with py-evm project on...
Read more >
install pyethash - Visual Studio Feedback
when I try to install pyethash I receivad this error : ... error C1083: Cannot open include file: 'alloca.h': No such file or...
Read more >
pip install ethereum failed - python
You can fix it: I think it is x86 / x64 compability error. ... You can try to copy not all files (from...
Read more >
win10下pip install安装pyethash库时报错:“无法打开包括文件
1 问题win10下python环境安装pyethash时报错:无法打开包括文件: “alloca.h”: No such file or directory”2 原因Windows下没有alloca.h这个头 ...
Read more >
pyethash · PyPI
Python wrappers for ethash, the ethereum proof of workhashing function.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found