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

Linux only tutorial fails to identify as such #151

Open
Znunu opened this issue Sep 27, 2020 · 9 comments
Open

Linux only tutorial fails to identify as such #151

Znunu opened this issue Sep 27, 2020 · 9 comments

Comments

@Znunu
Copy link
Contributor

Znunu commented Sep 27, 2020

This tutorial using this code only works on linux. Unfortunately I had to find out myself, since the tutorial doesn't really make it clear. To make this work with MSVC a lot needs to be changed, including all the compiling, the C/C++ source files, some of file path stuff and more. Even when using GCC most of the issues remain.

I suggest adding a big disclaimer that the tutorial is only for linux or even better, expanding it so that the rest of us can follow along too :(

@jima80525

@Znunu
Copy link
Contributor Author

Znunu commented Oct 4, 2020

Anyone?

@jima80525
Copy link
Contributor

I'm sorry this was disappointing for you. I don't have access to a Windows development machine, but I'd love to expand the build information to include doing this on Windows. The details of setting up a C++ compiler on Windows are not something I've dealt with in a long time.
Perhaps you can create a pull request?

@Znunu
Copy link
Contributor Author

Znunu commented Oct 4, 2020

I wouldn't mind to give it a try! I only really bothered with the ctypes module though, since just getting that to work ended up taking way too long. Fortunately the other approaches seem more portable anyway... ? The article would also have to be updated, since the differences are too significant not to be mentioned.

Please give this article a read. It's really good, and what saved me. It's also exposes you to the compiler(s), instead of hiding it away.

@jima80525
Copy link
Contributor

Cool. I didn't think gcc was available for windows - did you run it under the linux subsystem, or does it run in straight windows? (again, it's been a long time.)

When you got it running, did you get the tasks.py updated to use the command lines to build the app?

Sorry for the long response times - gotta keep up my day job, too :)

@Znunu
Copy link
Contributor Author

Znunu commented Oct 8, 2020

I'm not actually completely sure about GCC, I ended up using the MSVC compiler. Though both should be possible.

Originally I just used cmd to build the app. For ctypes, task.py pretty much boils down to 3 commands anyway. Not that tasks.py couldn't easily be updated to do it..... with a catch. The compiler isn't really added to PATH by default. So either (1) the user needs to do that (2) they need to specify the full path or (3) we rely on some fragile guesswork. There's probably a better way, but I don't know.

@jima80525
Copy link
Contributor

I'm not actually completely sure about GCC, I ended up using the MSVC compiler. Though both should be possible.
That's even better. I suspect most windows devs are using MSVC.
I vaguely remember that MSVC does put a .bat file on the bath which puts the compiler on the path. Is that true? If not, I'd propose putting a reasonable guess into the tasks.py file and then add a comment where it's set or used to indicate that it might need to be adjusted.

Thanks again for being willing to look at this! I appreciate it and again, apologize for my slow pace. Been a long week.

@Znunu
Copy link
Contributor Author

Znunu commented Oct 18, 2020

I created a PR, it should show above this comment. Try and run this in linux. I tried my best not to break it for linux, but I've only tested it on windows. For this to work on windows you need to add, as an option, your path to vcvars64.bat when building with invoke. tbh it's clumsy, sorta complicated (finding vcvars64.bat) and feels very fragile. (probably wouldn't have to be, if I knew what I was doing, but hey good luck finding someone experienced with VS). I think it'd be a much better idea to teach readers how to compile themselves. On windows it's rather straightforward: Open x86 Native Tools Command Prompt for VS 2019, change dir and finally run cl /LD cmult.c. Anyway, it's up to you. The most important thing is to update the article, so that readers can actually make use of this update.

@Vahid44
Copy link

Vahid44 commented Nov 15, 2020

Hi, @Znunu
I have the same problem I guess!
I am trying to import a C++ library in Python using Cython following this tutorial, but there are some issues I mentioned in #169
Have you any idea how to do it?

Thank you.

@Znunu
Copy link
Contributor Author

Znunu commented Nov 15, 2020

I left a reply on your issue

@jima80525 it'd be nice to update the tutorial with all the new stuff and also to make it clear that the PyBind11 and Cython stuff still doesn't work on windows. Right now, if you try to invoke build on win, it just returns "path missing". Readers have little chance to know what path it is and where to find it.

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

3 participants