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

Windows support #140

Closed
techtonik opened this issue Nov 3, 2015 · 62 comments
Closed

Windows support #140

techtonik opened this issue Nov 3, 2015 · 62 comments

Comments

@techtonik
Copy link
Contributor

Can't create environment on Windows, because it requires compiler.

E:\grtp.co>py -m nodeenv -v .vjs -n 4.2.1
 * Install node (4.2.1)
   Downloading https://nodejs.org/dist/v4.2.1/node-v4.2.1.tar.gz
.'.' is not recognized as an internal or external command,
operable program or batch file.
'.' is not recognized as an internal or external command,
operable program or batch file.
Traceback (most recent call last):
  File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python27\lib\site-packages\nodeenv.py", line 1044, in <module>
    main()
  File "C:\Python27\lib\site-packages\nodeenv.py", line 892, in main
    create_environment(env_dir, opt)
  File "C:\Python27\lib\site-packages\nodeenv.py", line 733, in create_environment
    install_node(env_dir, src_dir, opt)
  File "C:\Python27\lib\site-packages\nodeenv.py", line 609, in install_node
    build_node_from_src(env_dir, src_dir, node_src_dir, opt)
  File "C:\Python27\lib\site-packages\nodeenv.py", line 574, in build_node_from_src
    callit(conf_cmd, opt.verbose, True, node_src_dir, env)
  File "C:\Python27\lib\site-packages\nodeenv.py", line 461, in callit
    % (cmd_desc, proc.returncode))
OSError: Command ./configure "--prefix='E:\grtp.co\.vjs'" failed with error code 1

The only solution that comes into my mind is to use compiled binaries. I implemented this once for getting prerequisites for compiling Wesnoth. Perhaps this code can be reused here too:

https://bitbucket.org/techtonik/locally/src/59e387ead07120777fdbe77fd0d047904cea6b14/05.wesnoth.py?at=default&fileviewer=file-view-default

@ekalinin
Copy link
Owner

ekalinin commented Nov 3, 2015

Hi @techtonik

Thanks for report.
Yeah, nodeenv doesn't support Windows atm. (see #53)

But nodeenv is able to install node from compiled binaries.
Try this command (i'm not sure if it works under windows though):

E:\grtp.co>py -m nodeenv -v .vjs -n 4.2.1 --prebuilt

@techtonik
Copy link
Contributor Author

Nice. I'd switch to that option by default. Looks like problem with 32-bit Windows:

 * Install node (4.2.1Traceback (most recent call last):
  File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python27\lib\site-packages\nodeenv.py", line 1044, in <module>
    main()
  File "C:\Python27\lib\site-packages\nodeenv.py", line 892, in main
    create_environment(env_dir, opt)
  File "C:\Python27\lib\site-packages\nodeenv.py", line 733, in create_environment
    install_node(env_dir, src_dir, opt)
  File "C:\Python27\lib\site-packages\nodeenv.py", line 594, in install_node
    node_url = get_node_src_url(opt.node, get_node_src_url_postfix(opt))
  File "C:\Python27\lib\site-packages\nodeenv.py", line 502, in get_node_src_url_postfix
    postfix_arch = arches[platform.machine()]
KeyError: 'x86'

techtonik added a commit to techtonik/nodeenv that referenced this issue Nov 3, 2015
@techtonik
Copy link
Contributor Author

Download for Windows fails, because Windows downloads have different URL structure.
https://nodejs.org/en/blog/release/v4.2.1/

   Downloading https://nodejs.org/dist/v4.2.1/node-v4.2.1-windows-x86.tar.gz
Traceback (most recent call last):
...
urllib2.HTTPError: HTTP Error 404: Not Found

@msangel
Copy link

msangel commented Feb 9, 2016

So far, please make --prebuilt mode as default on windows.
If someone wish to build node.js, let him specify this explicitly.

@ekalinin
Copy link
Owner

ekalinin commented Feb 9, 2016

I believe, we need to do it for all platforms :)

@techtonik
Copy link
Contributor Author

It would be nice to merge #148 before moving further into downloads refactoring for all systems. It should be pretty easy then to take it and finish it from there.

@ekalinin
Copy link
Owner

ekalinin commented Feb 9, 2016

Done

@techtonik
Copy link
Contributor Author

One step closer. He-he..

@techtonik
Copy link
Contributor Author

Another fix is in #149

@techtonik
Copy link
Contributor Author

Well, the code is there, but coverage test fails, probably because Windows execution branch is not tested on Travis.

@neocris
Copy link

neocris commented Feb 11, 2016

for me the keyerror is 'amd64' although i have a i5 core. please add support for amd64 arch. perhaps it has something to do with python for 64 bit versions since the intel 64 bit architecture was licensed from amd, therefore the 'amd64' key; the python binaries for 64 bit all have the amd64 denomination

@techtonik
Copy link
Contributor Author

@neocris what is the exact output of this command on your machine?

python -c "import platform; print(platform.machine())"

@techtonik
Copy link
Contributor Author

@neocris also, do you use latest Github version?

@neocris
Copy link

neocris commented Feb 11, 2016

@techtonik the output is "AMD64". i don't get the github question, neither have it installed. i installed nodeenv trough 'pip install' if that's what you mean

@techtonik
Copy link
Contributor Author

Try pip install -e git+https://github.com/ekalinin/nodeenv.git#egg=nodeenv - you should get different error.

@neocris
Copy link

neocris commented Feb 11, 2016

now there's an error on opening tarfile.py in python '/lib' dir

@techtonik
Copy link
Contributor Author

@neocris can you post it here?

@neocris
Copy link

neocris commented Feb 12, 2016

here's the cmd i run for node 4.3.0:

nodeenv --node=4.3.0 --prebuilt node43

and here's the full traceback:

Install node (4.3.0)
Downloading https://nodejs.org/dist/v4.3.0/win-x64/node.exe
Traceback (most recent call last):
File "C:\tools\python2\Scripts\nodeenv-script.py", line 9, in
load_entry_point('nodeenv==0.13.6', 'console_scripts', 'nodeenv')()
File "c:\progs\portablegit\src\nodeenv\nodeenv.py", line 917, in main
create_environment(env_dir, opt)
File "c:\progs\portablegit\src\nodeenv\nodeenv.py", line 758, in create_enviro
nment
install_node(env_dir, src_dir, opt)
File "c:\progs\portablegit\src\nodeenv\nodeenv.py", line 630, in install_node
download_node_src(node_url, src_dir, env_dir, opt, prefix)
File "c:\progs\portablegit\src\nodeenv\nodeenv.py", line 519, in download_node
_src
with tarfile_open(fileobj=tar_contents) as tarfile_obj:
File "c:\tools\python2\lib\contextlib.py", line 17, in enter
return self.gen.next()
File "c:\progs\portablegit\src\nodeenv\nodeenv.py", line 507, in tarfile_open
tf = tarfile.open(_args, *_kwargs)
File "c:\tools\python2\lib\tarfile.py", line 1678, in open
raise ReadError("file could not be opened successfully")
tarfile.ReadError: file could not be opened successfully

i'm running this on python 2.7.11

@techtonik
Copy link
Contributor Author

@neocris yea, right, #149 fixes that.

@ekalinin
Copy link
Owner

#149 merged

@ekalinin
Copy link
Owner

please, try one more time.

@techtonik
Copy link
Contributor Author

It will fail with missing symlink - fixed in #150. Now Windows needs its own activate.bat

@ekalinin
Copy link
Owner

#150 merged

@neocris
Copy link

neocris commented Feb 17, 2016

ok, so i dig a little trough nodeenv.py and after it copies prebuilt node it tries to install npm trough a bash shell script, not native to windows by the way, from npmjs.org. so if only nodeenv can do in windows is to grab a piece of file and put it somewhere i don't see the advantage of its use since i can do that myself without much hassle

@ekalinin
Copy link
Owner

ok, so i dig a little trough nodeenv.py and after it copies prebuilt node it tries to install npm trough a bash shell script ...

It's only for the old versions of the nodes.
In the lasts versions of the nodejs npm is included.

     if node_version_from_opt(opt) < parse_version("0.6.3") or opt.with_npm:
        install_npm(env_dir, src_dir, opt)

@neocris
Copy link

neocris commented Feb 17, 2016

It's only for the old versions of the nodes.
In the lasts versions of the nodejs npm is included.

right, but the prebuilt version nodeenv is getting doesn't, it's only the engine not npm. the way i see it (and also guessed by previous comment of techtonik) the included npm comes only with node installer.

@ekalinin
Copy link
Owner

Prebuilt version of the node.js for Linux include both npm & node:

➥ git clone https://github.com/ekalinin/nodeenv.git && cd nodeenv
➥ virtualenv --no-site-packages env && . env/bin/activate && python setup.py install && nodeenv -j 4 -p --prebuilt
➥ . env/bin/activate
(env) ➥ node -v
v5.6.0
(env) ➥ npm -v
3.6.0

It seems like for Windows we have another content of the node.js archive.

@neocris
Copy link

neocris commented Feb 17, 2016

doesn't python setup.py install install from source?

@ekalinin
Copy link
Owner

python setup.py install installs nodeenv itself.
I added one more row in my previous comment.

@neocris
Copy link

neocris commented Feb 18, 2016

sorry, i didn't scroll the code block to the right and missed the nodeenv cmd. get it now. thx

@neocris
Copy link

neocris commented Feb 18, 2016

@ekalinin is it possible in any way that you might have another global node instance sneaking in your system so that the npm call is in fact a global one and not from virtual node environment?

@ekalinin
Copy link
Owner

@neocris nope, i haven't globaly installed node.js:

➥ aptitude search nodejs
p   nodejs                                             - evented I/O for V8 javascript                                
p   nodejs:i386                                        - evented I/O for V8 javascript                                
p   nodejs-dbg                                         - evented I/O for V8 javascript (debug)                        
p   nodejs-dbg:i386                                    - evented I/O for V8 javascript (debug)                        
p   nodejs-dev                                         - evented I/O for V8 javascript (development files)            
p   nodejs-dev:i386                                    - evented I/O for V8 javascript (development files)            
p   nodejs-legacy                                      - evented I/O for V8 javascript (legacy symlink) 

@techtonik
Copy link
Contributor Author

npm is not installed with my fixes for Windows. I didn't thought it is essential for Node environment.

@MCGallaspy
Copy link

Was looking at this issue, unfortunately I don't have time to completely solve it now, but I figure I would post my partial results.

  1. On Windows, you try to download the node src from a bad url. Fixed with this patch: MCGallaspy@4ab1f0b
  2. This line and possibly others will fail on Windows unless the cp binary exists (e.g. if the user has MinGW installed). But you could probably use shutil anyway.
  3. After applying the patch and ensuring the cp binary was available on my path, I got the following traceback:

Cmd: python -m nodeenv --prebuilt C:\Users\Mike\.pre-commit\repofmobal\node_env-default

 * Install prebuilt node (5.7.1) ..... done.
Traceback (most recent call last):
  File "C:\Python27\Lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Python27\Lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "D:\nodeenv\nodeenv.py", line 1071, in <module>
    main()
  File "D:\nodeenv\nodeenv.py", line 919, in main
    create_environment(env_dir, opt)
  File "D:\nodeenv\nodeenv.py", line 768, in create_environment
    install_activate(env_dir, opt)
  File "D:\nodeenv\nodeenv.py", line 742, in install_activate
    writefile(file_path, content, append=need_append)
  File "D:\nodeenv\nodeenv.py", line 380, in writefile
    with open(dest, 'wb') as f:
IOError: [Errno 2] No such file or directory: 'C:\\Users\\Mike\\.pre-commit\\repofmobal\\node_env-default\\bin\\activate'

@techtonik
Copy link
Contributor Author

@MCGallaspy installing from source is not an easy way. Easy way is to just download binaries, but it was reverted, because a4bf0e7 broke something on Linux.

@techtonik
Copy link
Contributor Author

@MCGallaspy try reverting code to revision MCGallaspy@cdbd415 to see what was made for prebuilt stuff. Basically node.exe is downloaded and executed ok, but it appears that npm is also needed, which was just not implemented.

@MCGallaspy
Copy link

Tried python -m nodeenv --prebuilt test from the given revision. The only contents of the test directory is an empty src directory, and I get the following traceback:

 * Install prebuilt node (5.7.1) ..Traceback (most recent call last):
  File "C:\Python27\Lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Python27\Lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "D:\nodeenv\nodeenv.py", line 1071, in <module>
    main()
  File "D:\nodeenv\nodeenv.py", line 919, in main
    create_environment(env_dir, opt)
  File "D:\nodeenv\nodeenv.py", line 760, in create_environment
    install_node(env_dir, src_dir, opt)
  File "D:\nodeenv\nodeenv.py", line 632, in install_node
    download_node_src(node_url, src_dir, opt, prefix)
  File "D:\nodeenv\nodeenv.py", line 521, in download_node_src
    with tarfile_open(fileobj=tar_contents) as tarfile_obj:
  File "C:\Python27\Lib\contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "D:\nodeenv\nodeenv.py", line 507, in tarfile_open
    tf = tarfile.open(*args, **kwargs)
  File "C:\Python27\Lib\tarfile.py", line 1672, in open
    raise ReadError("file could not be opened successfully")
tarfile.ReadError: file could not be opened successfully

@MCGallaspy
Copy link

It's because the parameter node_url in download_node_src has the value https://nodejs.org/dist/v5.7.1/win-x64/node.exe -- which obviously is not a tar file.

@MCGallaspy
Copy link

it appears that npm is also needed, which was just not implemented

Yeah, I see what you mean. Here's a work-in-progress: https://github.com/MCGallaspy/nodeenv/commits/windows-support-2

The command python -m nodeenv --prebuilt test at least finishes without error, but somehow I haven't unpacked the node binary into test\bin\node.exe (instead it goes to test\bin\node-<version>\node.exe) and also, as you say, npm binary needs to be downloaded. Looks like you can get them here: https://github.com/npm/npm/releases

Short on time again, will try again later!

@techtonik
Copy link
Contributor Author

@MCGallaspy you're not testing the right revision - line 632 in your trace doesn't correspond to https://github.com/MCGallaspy/nodeenv/blob/cdbd41594a6ac57547cd3684de2faf5b946b4c25/nodeenv.py#L632

@techtonik
Copy link
Contributor Author

I see that https://github.com/MCGallaspy/nodeenv/commits/windows-support-2 branch is on top of needed fixes, so yes - need a way to download and install npm, but the more pressing problem is to understand what had failed on Linux so that the changesets made so far were reverted in master branch.

@tylerlandas
Copy link

Hi all. Sorry if this is not the correct place to ask, but is nodeenv supported on 64bit Win10? From this thread it seems not yet, but want to confirm. Been trying to use it without success.

@techtonik
Copy link
Contributor Author

I don't have time/project to complete this, so it is not supported.

@ekalinin
Copy link
Owner

ekalinin commented Dec 8, 2016

#173

techtonik added a commit to techtonik/nodeenv that referenced this issue Jan 20, 2017
techtonik added a commit to techtonik/nodeenv that referenced this issue Jan 20, 2017
Final fix for ekalinin#140. `mklink` fails with
`You do not have sufficient privilege to perform this operation.`
on my system, so make it optional.
@techtonik
Copy link
Contributor Author

Can be closed for now. @ekalinin can you wrap a release with these changes?

@ekalinin
Copy link
Owner

@techtonik can you wrap a release with these changes?

Done:

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

6 participants