Find path to Application Support directory in python in MacOS - python-3.x

I've been working on a mac app for a long time now, under the assumption that everyone has their Application Support folder located at /Users/[user_name]/Library/Application Support. However, I recently learned this is not true. I need something I can do in python to get the path to the Application Support directory on anyone's computer. Everything I've seen so far has been very outdated with respect to python. The only leads I have are some PyPi packages, PyCocoa and pyobjc-framework-Cocoa. I intend for this to work across several recent OS versions (one person has Monterey, one has Catalina, one has Big Sur, I have Mojave), and it seems that the path to the Application Support folder has changed across versions. What is the accepted way to find this folder on any computer?
Thanks!

Might be a bit slow, but the os library has a walk function which may help. You could loop through the most likely places i.e., $HOME, etc. Then read through the subfolders...something like this should identify the directories - obviously, you will need to check them against your expectation.
[x[0] for x in os.walk(top-directory)]

Related

How to manage multiple haskell installations on macOS?

I have on my computer (macOS High Sierra) multiple installations of the standard (Glasgow) Haskell compiler. The oldest one (as far as I can remember) is a minimal installation, while I obtained the most recent version form the "Platform" installer, something like five or six months ago. I'm trying to get rid of the whole ecosystem (ghc, stack, cabal, and friends), mostly because I don't know what tools I will be using in the case I'll plan to get back using the language.
So my questions are:
Where does the minimal/"Platform" installer installs Haskell and all related stuff?
How can one remove the whole Haskell language and all its components mentioned above (in the case of a "Platform" install, and even in the case of a minimal installation)?
EDIT: I've just remembered of the uninstall-hs command (see also here), should I run this instead of removing files manually?
I think I have come up with a solution and I'll answer the latter question first:
All the details I was looking for (what effectively is installed after launching the minimal / "Platform" installer, and, most importantly, where these guys were placed) can be found in the documentation welcome file at /Library/Haskell/Doc/Start.html. More precisely:
On Mac OS X, the Haskell Platform is installed in two major pieces: GHC and Haskell Platform. They are installed respectively in: /Library/Frameworks/GHC.framework and /Library/Haskell. Executables are symlinked in /usr/local/bin [...].
There are also another two or three directories in the home folder, namely ~/.ghc and ~/.stack.
As said in the OP, the script uninstall-hs done its work, showing a (at least I hope so) comprehensive list of all the files that constitutes the Haskell "sdk" actually installed.
Feel free to post your answers, I hope this post will be useful to the community.

Is it OK to modify the default location for Python-3.6.0.exe to just the C drive?

I am a 65 year old "newbie" and generally use default options when downloading. Python.org wants to download to an obscure directory such as
C:\Users\Facdev\AppData\Local\Programs\Python\Python36-32".
Is there anything wrong with downloading instead to "C:"?
This should not pose a problem, as long as the directory is specified correctly in you PATH.
It is OK to modify the location where you will download and install Python. However, I would advise against doing so if you are unfamiliar with how system environment variables and PATH locations work in Windows.
Why does it matter?
Once you have the python executable (in your case Python-3.6.0.exe) on your system, your computer needs to know where it is in order to execute it! If you place the executable in a location like the main directory on the C: drive your computer does not care. Your computer also does not care if the executable is deep down in the AppData\ directory.
By changing the default behavior you run a risk when troubleshooting unexpected behavior that instructions will not be written for your situation. This is OK as long as you understand what you will need to change in order to apply the troubleshooting techniques listed on documentation, blog posts, and forums.
Because of those factors and this being a new process for you, I recommend sticking to the default. You can change the location later, once you understand what doing so means. Learning to program can be frustrating and trying to grasp managing the software environment only adds to the frustration. Tackle that issue later.
Good luck on your new adventure! I hope you learn to enjoy writing your own programs in python!

How to tell Node.JS to use modules from global by default?

Is there any chance to tell Node.Js to also look in the global modules folder by default, without changing sources?
I am trying to avoid that my project folders (up to a hundred packages) gets messed with thousands of sub-folders (also, it slows most IDEs into their knees too). I am aware about the npm link trick but it doesn't work on all platforms or its causing other problems. Also, npm/npm3 is sometimes so slow that i have to wait an entire day that my project is ready for actually working on it (i have a top speed computer and broadband).
known solutions:
changing NODE_PATH environment is out for some other reasons, shell .rc changes are little bad too.
changing core files is easy but requires also patches in many other places (when using nodejs. as dependency for instance )
patching node.js's require function as in other versions like require-js which supports require({cache:{}}) or require({config:{}})
At the end I went with https://github.com/h2non/requireg. It doesn't need any kiddie hacks like npm link or special environment variables and works fantastic. It comes with a globalize function which makes subsequent require calls also looking in the global folders.

Installing GLPK (GNU Linear Programming Kit) on Windows

This could be an annoying question. But I was hoping someone could provide me with step by step instructions on how to get GLPK up and running on a Windows machine. I have Windows 7 64-bit.
I have tried looking at some instructions on various websites but keep running into problems. I am not very versed in creating directories, working with binaries (e.g. what is a binary), etc.... Even running commands is a little foreign to me.
To get an idea of what kind of detail I need in the instructions, here are some I have tried (and failed) to use:
http://winglpk.sourceforge.net/
http://en.wikibooks.org/wiki/GLPK/Windows
As you can see, I need something fairly detailed. I have read an example of a GLPK program in action, and I believe that once I get the program up and running I should be able to write the code to use it.
Can anyone help me? I would be so grateful.
EDIT: As a parallel question, I would also be interested in suggestions for other programs that will do the similar things as GLPK, but are more straightforward to install and use.
here an easy step-by-step explanation of "how to make glpk work":
To download GLPK , first go to the GLPK windows download page and then follow the instructions here from 1:
Go to control panel to determine whether you have 32-bit or 64-bit Windows (assume 64-bit from now on).
Download the latest version of GLPK, 4.65 at the time of writing, from the following address Sourceforge.
Extract the Zip folder by: right clicking on the folder and then>> 7-Zip >> Extract Here as shown. Move the glpk-4.65 folder from your downloads folder to your C: drive.
Assuming you’re using 64-bit Windows, click on the C:\glpk-4.65 folder in Windows explorer, click on the w64 folder, and select and copy the file path, which should be C:\glpk-4.65\w64.
Search and open your Control Panel, select System and Security>>System>>Advanced system settings>>Environment Variables. Then click on ‘path’ in the top window, click the ‘Edit’ button, then ‘New’.
Paste the file path you copied above and save.
DONE.
Here are a few suggestions to get you moving forward:
If you are having difficulty with running Windows command-line, then maybe GLPK (installing by yourself) is not the best bet.
See if you can find someone more experienced in Windows help you with the installation? (Once installed the LP modules are fairly easy to use, no more complex than any of the others)
Do you have access to any commercial solvers? (MATLAB and CPLEX can be great)
If you are going to be working with Windows for some time to come, it is a good idea to invest some time to learn how to download and install software
This SO question has links to lots of other LP/IP solvers such as Gurobi and COIN-OR.
If you don't mind learning a bit of R programming language, I'd recommend downloading R and RStudio, both of which are straightforward. Next, what you want is the lpSolveAPI package. The examples are decent and you can get going in a day or two. (You'll have to learn the basics of R)
If none of these help you progress, post some details of where you are getting stuck in the GLPK download (post the errors you are getting) and someone will try and assist you.
Hope that helps
In my opinion, it would be way easier for you to install e.g. ubuntu, especially if you are interested in other GNU programs. You can use every open-source program on windows, but it will not be easy if you don't understand what is a "search path for binaries"...
Installing softwares and libraries on windows is not easy, which is why windows program usually come with a setup.exe installer that does everything for you (but GNU programs don't).
On the other hand, ubuntu has a beginner-friendly documentation, and once you have installed it on your computer (it won't take you more than 2 hours at most, and 10G of disk space), installing GLPK or any GNU program is pretty straigtforward (just type sudo apt-get install glpk on the command-line).
There is no drawback in having the two systems on the same computer (except for the small amount of disk space used), and getting to know another operating system will certainly teach you more than following any step-by-step guide anyway.
That would be my "general advice". Now if you just want help on how to install glpk on windows, please post more details about what "doesn't work" for you (where did you "failed" to use those instruction? what happened?) because I don't think you can find something more detailed than the second link you posted.
have you set the PATH correctly once you have unziped the files?
To check it, run the cmd.exe and put "echo %path%", if in the list does not appears your glpk folder then you are unnable to execute it right since windows does not find the glpk executables.
more info:
http://en.wikibooks.org/wiki/GLPK/Windows_executables
https://superuser.com/questions/284342/what-are-path-and-other-environment-variables-and-how-can-i-set-or-use-them

synchronizing files and symlinks between two linux os

I am facing with the bug following:
https://bugzilla.samba.org/show_bug.cgi?id=4531
rsync will always get the older symlink of the other side overwrite
the newer one on the local side.
Wayne has suggested to use unison, however it is a non-developing old
project that I have suspect to use.
What can you suggest me for ?
My main aim is to syncronize file, directories, links for 2 nodes.
unison is ok, as long as your file/folders name don't use unicode, especially cross platform. Can't hurt to give it a try.
See Here for the limitation on unicode in filename.

Resources