Paranoid-Dev / ParanoidFFD

Undetectable fanfiction.net Downloader with Parallel Downloading
Apache License 2.0
10 stars 1 forks source link

Does this work on MacOS? #1

Closed dreamer540 closed 3 years ago

dreamer540 commented 3 years ago

Hi,

I see installation instructions for Linux and Windows, but I have a Mac. Any chance that it will work for me? Thanks!

Paranoid-Dev commented 3 years ago

I have never used a mac before (and they are so hard to run on VMs), so that's why there's no mac support, but I would l would love to try and make it work with you!

I am currently reworking the writing-to-file part so I'll commit that first later today, and research on macs The current code won't work on mac without a few edits because of that part, but the rework will probably make it work on mac as well

(btw, the portable code won't use the portable chrome version and just use the installed version because I got confused and commented out the portable part right before commiting - that will also be fixed later in today's commit)

dreamer540 commented 3 years ago

Ai, you could fill a thimble with my knowledge of command line things! I'm currently taking a class on python and in the mood to tinker (not to mention that the allure of being able to dl things yourself, with the way things have been going); but at best, I'd be of no help at all on a good day, and possibly detrimental on a bad one. Thanks for all your work developing and sharing this, though!

Paranoid-Dev commented 3 years ago

Please, you can just test the new releases to see if they work or not. I have no way of testing for macs because I don't own a single Mac device and can't run a VM. And btw, your Python skills may be better than mine lol. I have never formally learned Python, just C. (Though I really like using Pyhon.h for some projects)

dreamer540 commented 3 years ago

Oh, well in that case, I don't mind helping! Although I should again emphasize that my knowledge of coding is nearly non-existent - I can, however, follow instructions and tell you if/what errors I get and help with testing that way! I'm a tad busy the next few days, but let me know what next steps would be here and I'll get back :)

Paranoid-Dev commented 3 years ago

I just uploaded the new version! (New option feature update as well as removing OS specific code as much as possible for multi-OS support) Would you please test it?

If you get Python related errors on compile, tell me the errors and google instructions on how to compile Python.h on Mac

dreamer540 commented 3 years ago

ok, so:

pikaur -S google-chrome-stable # just here to demonstrate you need the latest stable google-chrome / chromium I skipped this because I have chrome

pacman -S python3 # install Python3 i skipped this because I have python 3.9

pip3 install undetected-chromedriver this worked fine

(base) user ~ % gcc downloader-dynamic.c -o ParanoidFFD -I/usr/include/python3.9 -lpython3.9 this didn't work at first, and threw the following error:

gcc downloader-dynamic.c -o ParanoidFFD -I/usr/include/python3.9 -lpython3.9
clang: error: no such file or directory: 'downloader-dynamic.c'

which I thought might be because I didn't have gcc, so i installed that with homebrew: https://formulae.brew.sh/formula/gcc

Then ran it again and got the same error:

(base) user ~ % gcc downloader-dynamic.c -o ParanoidFFD -I/usr/include/python3.9 -lpython3.9
clang: error: no such file or directory: 'downloader-dynamic.c'

I don't know what "downloader-dynamic.c" is, and google gave me nothing - is this a file I need to download?

Paranoid-Dev commented 3 years ago

Oh did you git clone my repo? downloader-dynamic.c is this git clone https://github.com/Paranoid-Dev/ParanoidFFD.git or download this and compile inside ParanoidFFD dir

(And those pikaur and pacman commands are for Archlinux only - I only put them there to show that you needed to install them - were they confusing? Should I change them to just install google-chrome-stable and python3?

And should I add git clone instructions? If you think other people would be confused...

Edit; updated README because of this

dreamer540 commented 3 years ago

omg askdf i downloaded it but was working in the wrong directory >.> trying again today, I'll let you know!

dreamer540 commented 3 years ago

Nope, the directions were rad! It's always easier to have a "just do this" rather than an "insert your own here" explanation, because it makes the directions seem simpler and more try-able.

So, I think I found the correct python.h file (on my mac, it was in the directory under Macintosh HD

/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9/

as you helpfully linked in this post: https://stackoverflow.com/questions/16454129/python-h-header-file-missing-on-mac-os-x-10-6). Having found that, I ran the code as follows:

(base) user ParanoidFFD-main % gcc downloader-dynamic.c -o ParanoidFFD -I/Library/Frameworks/Python.framework/Headers -lpython3.9
downloader-dynamic.c:31:1: warning: non-void function does not return a value
      [-Wreturn-type]
}
^
downloader-dynamic.c:78:1: warning: non-void function does not return a value
      [-Wreturn-type]
}
^
downloader-dynamic.c:103:16: warning: format string is not a string literal
      (potentially insecure) [-Wformat-security]
                sprintf(buf2,buf1);
                             ^~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/secure/_stdio.h:47:56: note: 
      expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
                                                       ^~~~~~~~~~~
downloader-dynamic.c:103:16: note: treat the string as an argument to avoid this
                sprintf(buf2,buf1);
                             ^
                             "%s", 
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/secure/_stdio.h:47:56: note: 
      expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
                                                       ^
downloader-dynamic.c:130:1: warning: non-void function does not return a value
      [-Wreturn-type]
}
^
downloader-dynamic.c:184:1: warning: non-void function does not return a value
      [-Wreturn-type]
}
^
5 warnings generated.
ld: library not found for -lpython3.9
clang: error: linker command failed with exit code 1 (use -v to see invocation)

OMG, i have no idea what went wrong?! Point me in the direction and I will fix. I also didn't know what the invocation was but was curious, so i re-ran the code with an additional -v, with the following results:

(base) user ParanoidFFD-main % gcc downloader-dynamic.c -o ParanoidFFD -I/Library/Frameworks/Python.framework/Headers -lpython3.9 -v
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
 "/Library/Developer/CommandLineTools/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.15.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name downloader-dynamic.c -mrelocation-model pic -pic-level 2 -mthread-model posix -mframe-pointer=all -fno-strict-return -masm-verbose -munwind-tables -target-sdk-version=10.15.6 -fcompatibility-qualified-id-block-type-checking -target-cpu penryn -dwarf-column-info -debugger-tuning=lldb -target-linker-version 609.8 -v -resource-dir /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -I /Library/Frameworks/Python.framework/Headers -I/usr/local/include -internal-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/local/include -internal-isystem /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include -internal-externc-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include -internal-externc-isystem /Library/Developer/CommandLineTools/usr/include -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -fdebug-compilation-dir /Users/rachel/Documents/Rae/projects/test_project/Paranoidffd/ParanoidFFD-main -ferror-limit 19 -fmessage-length 80 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fobjc-runtime=macosx-10.15.0 -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/0w/4gh_51yx6rlgtzbsy51dqxg40000gn/T/downloader-dynamic-466ba5.o -x c downloader-dynamic.c
clang -cc1 version 12.0.0 (clang-1200.0.32.29) default target x86_64-apple-darwin19.6.0
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/local/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
 /Library/Frameworks/Python.framework/Headers
 /usr/local/include
 /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include
 /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include
 /Library/Developer/CommandLineTools/usr/include
 /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks (framework directory)
End of search list.
downloader-dynamic.c:31:1: warning: non-void function does not return a value
      [-Wreturn-type]
}
^
downloader-dynamic.c:78:1: warning: non-void function does not return a value
      [-Wreturn-type]
}
^
downloader-dynamic.c:103:16: warning: format string is not a string literal
      (potentially insecure) [-Wformat-security]
                sprintf(buf2,buf1);
                             ^~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/secure/_stdio.h:47:56: note: 
      expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
                                                       ^~~~~~~~~~~
downloader-dynamic.c:103:16: note: treat the string as an argument to avoid this
                sprintf(buf2,buf1);
                             ^
                             "%s", 
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/secure/_stdio.h:47:56: note: 
      expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
                                                       ^
downloader-dynamic.c:130:1: warning: non-void function does not return a value
      [-Wreturn-type]
}
^
downloader-dynamic.c:184:1: warning: non-void function does not return a value
      [-Wreturn-type]
}
^
5 warnings generated.
 "/Library/Developer/CommandLineTools/usr/bin/ld" -demangle -lto_library /Library/Developer/CommandLineTools/usr/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -platform_version macos 10.15.0 10.15.6 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -o ParanoidFFD -L/usr/local/lib /var/folders/0w/4gh_51yx6rlgtzbsy51dqxg40000gn/T/downloader-dynamic-466ba5.o -lpython3.9 -lSystem /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/lib/darwin/libclang_rt.osx.a
ld: library not found for -lpython3.9
clang: error: linker command failed with exit code 1 (use -v to see invocation)
dreamer540 commented 3 years ago

i'm gonna go check out installing CommandLineTools on xcode and re-run and see if that helps.

Paranoid-Dev commented 3 years ago

Okay, the warnings are the results of my sloppy code, but they shouldn't stop the code from compiling. (I've committed the new improved code to avoid the errors now) What is stopping the code from compiling is the error at the end, ld: library not found for -lpython3.9

https://stackoverflow.com/questions/11015877/mac-os-x-ld-library-not-found-for-lpython3 I found this - which seems to be the question for the same error

So I would guess that this would work (hopefully) gcc downloader-dynamic.c -o ParanoidFFD -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -L/Library/Frameworks/Python.framework/Versions/3.9/lib -lpython3.9 I used a different include path than what you used - if this doesn't work, revert to yours.

(And thanks for adding the verbose log - it's really helpful, seeing what gcc does on Macs - like those warnings, which doesn't happen on Linux gcc)

Paranoid-Dev commented 3 years ago

And please git clone again when you try to compile. I added lots of new features in the last 2 days. (And I'm almost done implementing save to epub feature, so another big update will take place soon - check updates with --check-update)

(And I thought I removed this link from README?? https://stackoverflow.com/questions/16454129/python-h-header-file-missing-on-mac-os-x-10-6 I included how to find Python.h in the updated README instead)

Paranoid-Dev commented 3 years ago

https://github.com/Paranoid-Dev/ParanoidFFD#installation-mac Tested by minimaul#5512 on discord Since minimaul#5512 proved that it works on MacOS, by compiling and downloading a 170 chapter monster with it, on both Intel and Apple Silicon, I'll say that ParanoidFFD now officially works on Mac and Linux I'll close this issue once you've succeeded too. And Epub support is almost there!

dreamer540 commented 3 years ago

woot! you're moving fast :o 'kay, I'm gonna try it out.

dreamer540 commented 3 years ago

update: used

sudo find / -iname "Python.h"

to find the Python.h file for my Python. 3.9 install; FOUND the file, but I still keep getting a "file not found" error. :( the file is on my Macinstosh HD drive rather than my local user, but I'm not sure if that makes a difference. Currently investigating according to this thread: https://stackoverflow.com/questions/49437900/fatal-error-python-python-h-file-not-found-while-installing-couchapp

% clang downloader-dynamic.c -o ParanoidFFD -l/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -L/Library/Frameworks/Python.framework/Versions/3.9/lib -lpython3.9
downloader-dynamic.c:1:10: fatal error: 'Python.h' file not found
#include <Python.h>     //      >= Python3.6
         ^~~~~~~~~~
1 error generated.
dreamer540 commented 3 years ago

update: still investigating. I think this is related to my PATH and having multiple instances of Python installed (3.8 via anaconda, 2.7 native to mac, and 3.9 [i think with homebrew, but i may be remembering incorrectly]). no matter what i do (change the PATH, change the -I and -L locations to the various usr/ or the opt/ (from anaconda) or the Library/ locations of the Python.h file), it's still giving me the same error (from above, file not found).

next option: wipe my laptop, reinstall my operating system, and only install python3.9 once using homebrew. 🙄 that or use pyenv??? i need anaconda for the python course I'm taking, but at this point idec.

Thanks for the support, though, and I'm glad you got it to work with a mac user! :)

dreamer540 commented 3 years ago

I DID THE THING!!!! ~~~~ !!!!

After 5472 years, behold!

Screen Shot 2021-02-19 at 2 30 24 PM

probably a multiple installs thing, but I solved by using

export C_INCLUDE_PATH=/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9

and then

clang downloader-dynamic.c -o ParanoidFFD -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -L/Library/Frameworks/Python.framework/Versions/3.9/lib -lpython3.9

and it worked!!!! 🎉 🎉

Only now, it gives me "command not found" when I try to run it.

ParanoidFFD -h
-bash: ParanoidFFD: command not found

:( probably another path/multiple installs thing, i'll look into it.


edit: it would be impossible to credit the thousands of SO pages I looked at to get here, but the following were most helpful in the end; i'm posting here with the thought that someone else might quickly avail themselves of these pages before spending days looking up the issue if they're in the same sorry python install situation I'm in:

1) the first, second, and fifth answers in this SO thread for helping to use export C_INCLUDE_PATH https://stackoverflow.com/questions/35778495/fatal-error-python-h-file-not-found-while-installing-opencv/35778751

2) using which python and which python3 to figure out which version of python/python3 is in your path https://apple.stackexchange.com/questions/273774/my-mac-has-python3-and-2-7-installed-how-do-i-uninstall-python3-but-keep-2-7

3) in case it's an xcode CommandLineTools problem OR if your path is in usr/local/Cellar https://stackoverflow.com/questions/49437900/fatal-error-python-python-h-file-not-found-while-installing-couchapp

4) how to add a directory to your PATH and using echo $PATH to see what's currently in your PATH https://osxdaily.com/2014/08/14/add-new-path-to-path-command-line/

5) in case you need to add multiple directories to the PATH OR edit the LIBRARY_PATH variable too https://stackoverflow.com/questions/5846804/how-to-add-multiple-header-include-and-library-directories-to-the-search-path-in

note: after much trial and error, I think you have to set export C_INCLUDE_PATH = <path_to_Python.h> and then use clang downloader-dynamic.c -o ParanoidFFD -I<path_to_Python.h> -L<path_to_lib> -lpython3.9

where the is something like /Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 and is something like /Library/Frameworks/Python.framework/Versions/3.9/lib

Paranoid-Dev commented 3 years ago
ParanoidFFD -h
-bash: ParanoidFFD: command not found

I may not know about Macs, but if you're on bash, the correct syntax would be ./ParanoidFFD --help if you're in the same directory And I think you're almost there!!! If you've succeeded on compiling

Edit; Would you consider joining the discord server? It would be really nice to hear direct feedback

dreamer540 commented 3 years ago

ai, was not kidding when I said I was busy, I'm only getting back to this today! I dunno, I've never joined a discord server, what's it for?

Paranoid-Dev commented 3 years ago

Just for talking, since github issues isn't the best place for chats. I'm debugging the epub saving feature now

Edit; Support for Epub feature added! - in beta testing

Paranoid-Dev commented 3 years ago

Closing as compilation worked, and seemingly no further interest. You can always reopen it or add comments