The legacy app i'm working on is downloading classes on windows to the users AppData:
${installer:sys.userHome}/AppData/Local/TheOrg/${installer:productName}/Lib
'productName' is a installer variable that is configurable as a step in the installer
This is given as an argument to the main class by the installer and at that point
${installer:sys.userHome} and ${installer:productName} resolves correctly
However when I use the same location (${installer:sys.userHome}/AppData/Local/TheOrg/${installer:productName}/Lib) as a Class Path as value of an 'Scan Directory" entry something seems off. If I hard code this to
C:/Users/MyUser/AppData/Local/TheOrg/MyApp/Lib everything works fine.
What is the difference between 'Directory' and 'Scan Directory', and are there any reasons why the Classpath isn't picked up correcly when I'm using variables?
You cannot use installer variables in the class path entries of a launcher. You can see that in the variable selector which does not offer installer variables.
The technical reason is that the class path is constructed by the native launcher which does not have access to installer variables because they are read and instantiated by the Java part of the installer.
On Windows, you can use the environment variable ${LOCALAPPDATA} in class path entries to refer to the local app data directory.
Btw, use ${installer:sys.localAppdataDir} instead of ${installer:sys.userHome}/AppData/Local, the location of that directory might not be in the user home directory.
Related
Ive downloaded QGIS 3.22
according to documentation, I need to set PYTHONPANTH and PATH to make pyqgis visible from python for a stand alone application:
set PYTHONPATH=c:<qgispath>\python
such folder doesnt exist. Specificly c:\program files\qgis 3.22\python
I set the path to many folders in the directory (\apps\qgis\bin, apps\qgis\python\qgis....) but it doesnt work.
Im checking the sys.path and the new PYTHONPATH is there.
still when importing qgis.core , i get "no module qgis"
what am I missing?
Check the docs for Running Custom Applications. Make sure you have the DLL and lib folders in your PYTHONPATH. Check the environment variables using the built-in interpreter (the order of directories in PATH matters) and make sure they match your standalone environment. Also, your install should come with a python-qgis-ltr.bat or python-qgis.bat bootstrap file which is a nice starting point for setting up your own environment (on windows).
SQLAPI++ has an unusual feature where you set a string to tell it where to find the ODBC shared library. In my case this is libtdsodbc.so, and my application actually links that library at build time, but at runtime this is not enough for SQLAPI++ to work.
My code is:
SAConnection conn;
conn.setOption("ODBC.LIBS") = "libtdsodbc.so";
conn.Connect("SERVER=...", "", "", SA_ODBC_Client);
ODBC.LIBS is documented like this:
Forces SQLAPI++ Library to use specified ODBC manager library.
The above code works if you set LD_LIBRARY_PATH to a directory containing libtdsodbc.so. But if you don't, Connect() fails:
libtdsodbc.so: cannot open shared object file: No such file or directory
DBMS API Library 'libtdsodbc.so' loading fails
This library is a part of DBMS client installation, not SQLAPI++
Make sure DBMS client is installed and
this required library is available for dynamic loading
Linux/Unix:
1) The directories in the user's LD_LIBRARY_PATH environment variable
2) The list of libraries cached in /etc/ld.so.cache
3) /usr/lib, followed by /lib
It works again if you set ODBC.LIBS to a full path rather than just a filename. But how can the application know which path?
My application (outside of SQLAPI++) finds libtdsodbc.so via its RUNPATH which is set at build time. This path is not a system path like /usr/lib. I'd like to have SQLAPI++ use the same library which is loaded in the application at runtime.
One idea is for the application to inspect its own RUNPATH, search for libtdsobc.so, and use that path. But this requires quite a bit of fiddly code to basically reimplement what ld.so already does.
I don't want to bake the path into the executable at build time separately from RUNPATH, because I sometimes edit RUNPATH before deployment (and then I'd need to edit two things).
Ideally I would like to tell SQLAPI++ to just use the library which is already loaded. I can figure this path out by running lsof -p PID | grep libtdsodbc.so but running shell commands from within the executable is not a good solution (and again I would rather not reimplement lsof).
You could either use dl_iterate_phdr (the link also includes a sample code which prints out lib names) or manually parse /proc/self/maps.
Is there a good technical or other reason why the MS hard-coded the Documents folder as the default location for WindowsPowerShell? MS has been criticized for too much configuration over convention in the past (WCF?), but a case can be made for more configuration in PowerShell. I, and I presume most developers, like to keep their development work centralized in a separate folder or volume away from personal and system files.
For instance, if you install PoshGit, it will install itself in C:\Users\Your Name\WindowsPowerShell\Modules. I don't want it to install itself there but in my own development partition d:\Dev\PowerShellScripts. There's no environment variable that controls this location.
Is there a reason for this or I just don't get it?
Can you explain yourself a bit more.
According to my understanding PowerShell.exe interpreter base directory is the one defined by $env:HOMEDRIVE, $env:HOMEPATH, that can be change using the user profile.
As shown in the screen shots here under :
Edited :
Ok, the screenshot comes from the user property in Active Directory MMC, you've got a simplest one in your windows seven user properties. But this has nothing to do with your problem.
Your problem is around the module installation. The think that you have to know is that Modules can be installed quite everywhere (even on a shared directory with some tricks). By default the environnement variable $env:PSModulePath points to the paths where Get-Module -ListAvailable look for them. So you can add d:\Dev\PowerShellScripts\Modules in this path and then copy the subfolder of C:\Users\Your Name\WindowsPowerShell\Modules created by PoshGit inside your Modules directory and it should work. Modules as opposite to Snapins don't need to be registered.
Now the reason why PoshGit choose to put module in user profile, raser than let you choose the place is PoshGit installer problem.
For more explanations read about Modules and about_environment_variables.
I want to run my working pydev project python code by double clicking the main module (outside of eclipse): xxx.py
The problem is that due to my imports being in different packages:
from src.apackage.amodule import obj
when xxx.py is double clicked it complains it doesn't know where the imports are (even though when I run xxx.py in pydev it magically knows what I'm importing).
A simple workaround is to remove all of the packages and move all of the modules into one directory (that obviously works but is very inconvenient)
How can I run my code in the file system without doing that work around?
This page answers my question excellently:
http://blog.habnab.it/blog/2013/07/21/python-packages-and-you/
Bottom line is always execute your code from the top, highest level, root directory (e.g. using a minimal main.py file that executes the main script of your program). Then, use absolute imports always and you never have a missing module issue since you start the program from the top directory and all imports are based off that 'home' path.
The problem you encountered is the natural behavior of most languages. A programm only knows about its working path (the path it is started in), the paths which are registered in the environment variables and at least relative paths.
The "magic" of the executable you created is therefore: It collects all scripts/modules needed, and copies/combines them next to/in the executable. The Executable then runs within the directory where all other scripts also reside and voila ...
If you are not happy with your workaround of creating an executable every time you want to run your project without PyDev there are two alternatives.
First but not the one I would suggest is registering the working path into in the environment variables.
Second and the one I think is much better: Create a link to the python executable and alter the calling string of the textfield "Target:". Append the path to your script you would like to run. Then alter the textfield "Start in:" and enter the project directory. After you did this you should be able to start your project with a simple double click.
(If you rely on external libraries which are neither on the path nor in you project you could search for appending paths temporarily to the pythonpath via the sys module.)
I hope I could help a bit.
I have build an executable that has the same body (the name is tree.exe) with one that windows is provided at C:\WINDOWS\system32 (tree.com).
I have set my Environment Variables that the path where my .exe resides and normally it eould be executed run, though as the same name appears in a different location the tree.com is run instead.
The question is, is it possible to set the priorities where my tree.exe can be executed instead of tree.com. Furthermore, as after the build the tree.exe is dumped to a server other users have the same problem, they cannot just run directly, they need to locate the actual item and double click it.
Any ideas?
Thanks.
I'm not quite sure, but i think you should have the path to your executable before the system paths in PATH variable. Don't forget to reopen the console after the variables have been changed.