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

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

Closed
sabotagebeats opened this issue Jul 15, 2021 · 14 comments
Labels
category: bug Something isn't working status: unstaged Not in a current planning cycle at this time, come back when time

Comments

@sabotagebeats
Copy link
Contributor

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 Consensys/ethjsonrpc#5

@sabotagebeats
Copy link
Contributor Author

also experiencing this in anaconda for windows

@antazoey
Copy link
Member

antazoey commented Oct 1, 2021

Have you tried adding -D MS_WIN64 to the compile flags in setup.py?

Reference: last comment here ethereum/ethash#87

@sabotagebeats
Copy link
Contributor Author

Have you tried adding -D MS_WIN64 to the compile flags in setup.py?

Reference: last comment here ethereum/ethash#87

No i have not, I think that @lost-theory was working on trying to resolve this as well so may have some helpful inputs

@lost-theory
Copy link
Contributor

lost-theory commented 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="[email protected]",
     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.

@lost-theory
Copy link
Contributor

Very up to date fork of ethash that doesn't seem to support Windows: https://github.com/chfast/ethash

@lost-theory
Copy link
Contributor

This is the definitive issue on what's blocking Windows support, with next steps on how to fix the issue and making a new release (if pyethash was still maintained):

ethereum/ethash#107

@fubuloubu
Copy link
Member

So, one thing that would help here is to remove the eth-tester provider defined under ape_test, this way we could at least push that to a different plugin where windows support isn't necessary

Otherwise, the trick would be to make some modifications to py-evm to make ethash optional for only situations where you'd need to validate headers (I don't think a precompile uses this like with blake2b)

lost-theory added a commit to ApeWorX/ape-hardhat that referenced this issue Oct 2, 2021
### What I did

Added Windows support for the Hardhat network provider.

### How I did it

See ApeWorX/ape#91 (comment) for steps
on installing Ape on Windows. Once I got that to work, all that was needed was
a small amount of OS-specific code to manage the Hardhat process on Windows.

### How to verify it

No CI support yet (blocked by ApeWorX/ape#91) but the
test suite is passing locally for me:

```
PS C:\Users\orayo\Documents\steve\ape-hardhat> ..\ape-env\Scripts\pytest.exe
=== test session starts ===
platform win32 -- Python 3.8.6, pytest-6.2.5, py-1.10.0, pluggy-0.13.1
rootdir: C:\Users\orayo\Documents\steve\ape-hardhat, configfile: pytest.ini
plugins: hypothesis-6.23.0, cov-2.12.1, forked-1.3.0, xdist-2.4.0, web3-5.23.1
gw0 [17] / gw1 [17] / gw2 [17] / gw3 [17]
................. [100%]
=== warnings summary ===
tests/test_hardhat.py::test_rpc_methods[get_balance-args1-0]
  c:\users\orayo\documents\steve\ape-env\lib\site-packages\web3\method.py:215: DeprecationWarning: getBalance is deprecated in favor of get_balance
    warnings.warn(

tests/test_hardhat.py::test_rpc_methods[get_nonce-args0-0]
  c:\users\orayo\documents\steve\ape-env\lib\site-packages\web3\method.py:215: DeprecationWarning: getTransactionCount is deprecated in favor of get_transaction_count
    warnings.warn(

tests/test_hardhat.py::test_rpc_methods[get_code-args2-]
  c:\users\orayo\documents\steve\ape-env\lib\site-packages\web3\method.py:215: DeprecationWarning: getCode is deprecated in favor of get_code
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/warnings.html
=== 17 passed, 3 warnings in 61.00s (0:01:01) ===
```
@antazoey antazoey changed the title blocker: windows 10 pip install eth-ape fails building pyethhash error: 'alloca.h': No such file or directory Bug: windows 10 pip install eth-ape fails building pyethhash error: 'alloca.h': No such file or directory Jan 27, 2022
@NotPeopling2day
Copy link
Contributor

No CI support yet this ticket blocked lost-theory in ApeWorX/ape-hardhat#2

@NotPeopling2day NotPeopling2day added the status: unstaged Not in a current planning cycle at this time, come back when time label Apr 11, 2022
@Nov1kov
Copy link

Nov1kov commented Nov 21, 2023

I installed the APE on Windows, using this workaround to install ethash ethereum/ethash#131

But it still has problems. For example, ape plugins list doesn't show anything. Something wrong with pydantic + enums in
installed = PluginGroup(plugin_type=PluginType.INSTALLED)

@antazoey
Copy link
Member

But it still has problems. For example, ape plugins list doesn't show anything. Something wrong with pydantic + enums in installed = PluginGroup(plugin_type=PluginType.INSTALLED)

We think we fixed the weird Enum problem here: #1745

@Nov1kov
Copy link

Nov1kov commented Nov 22, 2023

But it still has problems. For example, ape plugins list doesn't show anything. Something wrong with pydantic + enums in installed = PluginGroup(plugin_type=PluginType.INSTALLED)

We think we fixed the weird Enum problem here: #1745

Oh yes, it's quite a coincidence that MR 3 hours ago fixed my issue. I checked the master branch, and it's working! Thank you.

@antazoey
Copy link
Member

But it still has problems. For example, ape plugins list doesn't show anything. Something wrong with pydantic + enums in installed = PluginGroup(plugin_type=PluginType.INSTALLED)

We think we fixed the weird Enum problem here: #1745

Oh yes, it's quite a coincidence that MR 3 hours ago fixed my issue. I checked the master branch, and it's working! Thank you.

Yes that was odd timing! However, I am pretty happy you found a way to get it working on windows 10 and I would like to both document this and include the windows-latest matrix value in CI such that it works.

@Nov1kov
Copy link

Nov1kov commented Nov 22, 2023

Great!
To clarify, In my case I tested on winsows 11 + python 3.10 + custom install ethash. So, it's still not easy "pip install" way.

@antazoey
Copy link
Member

antazoey commented Jun 3, 2024

this is no longer an issue - ever since: Windows support isn't 100% there yet, but this specific problem has been resolved since: ethereum/py-evm#2121 and Ape is using later versions of eth dependencies already.

however we are not 100% windows compat yet.

@antazoey antazoey closed this as completed Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: bug Something isn't working status: unstaged Not in a current planning cycle at this time, come back when time
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants