I wrote a python script which runs some Modelica scripts file for Gitlab pipeline continuous integration. I could get the python script to work from command line without any issues, however, whenever I trigger the pipeline in Gitlab, I got errors below, I am curious if anyone encountered similar issues and could provide a solution possibly?
No compiler selected. Please select a version of Visual C++ or GCC. For instructions on how to install a supported compiler, please visit www.dymola.com/compiler.
I tried to use SetDymolaCompiler method, but it still gives me the same error.
(BTW, the documentation in the python interface was incorrect. In the documentation, string lists (see marco's answer and my correction) were used to set compiler location, however, I figured that it should be a map actually).
Here's the code I was running:
dymola_obj = None
try:
dym_obj = DymolaInterface(dymola_exe)
dym_obj.cd(mc_work_dir)
dym_obj.SetDymolaCompiler("vs", {"CCompiler":"MSVC","MSVCDir":"C:/Program Files (x86)/Microsoft Visual Studio 11.0/Vc"})
success = dym_obj.ExecuteCommand("some command")
except DymolaException as ex:
success = False
finally:
if dym_obj is not None:
dym_obj.close()
dym_obj = None
return success
OS: Win 10 Pro (on a VM)
Dymola: 2018 FD01
Correction:
Python interface documentation is still incorrect, in order to change compiler settings one should use [] instead of { }.
Python interface documentation:
SetDymolaCompiler("vs", {"CCompiler=MSVC","MSVCDir=C:/Program Files (x86)/Microsoft Visual Studio 10.0/Vc"});
Should be changed to:
SetDymolaCompiler("vs", ["CCompiler=MSVC","MSVCDir=C:/Program Files (x86)/Microsoft Visual Studio 10.0/Vc"]);
I didn't try with gitlab, but I found an error when running your code on my machine with Dymola 2018 FD01 and python 2.7.
In fact SetDymolaCompiler really does require a list of strings. You have to replace the line
dym_obj.SetDymolaCompiler("vs", {"CCompiler":"MSVC","MSVCDir":"C:/Program Files (x86)/Microsoft Visual Studio 11.0/Vc"});
with
dym_obj.SetDymolaCompiler('vs', ['CCompiler=MSVC', 'MSVCDir="C:/Program Files (x86)/Microsoft Visual Studio 11.0/Vc'])
Some tips when working with the python interface:
activate the Dymola window during development with
DymolaInterface(showwindow=True)
set breakpoints and check after every command what Dymola writes to the command window. In your case it got obvious that SetDymolaCompiler was not executed due to syntax errors and the compiler was not set
And finally, your minimal example does not work, as python code lines must not end with ;
Related
I am using Pop_os! system (ubuntu based system) and just installed VS Code. I would like to use Julia with it and installed Julia Extension in the VS Code Extension Marketplace. In the extension settings, I typed in the Julia executable path as where I installed it (in my case is: /opt/julia-1.5.3-linux-x86_64/julia-1.5.3/bin/julia.exe). It is able to run code and print hello world in the output window. However, when I try to click "julia: Execute file" button and run it in Julia REPL, it shows me error message:
Command failed: "/opt/julia-1.5.3-linux-x86_64/julia-1.5.3/bin/" --startup-file=no --history-file=no -e "using Pkg; println(dirname(Pkg.Types.Context().env.project_file))"
/bin/sh: 1: /opt/julia-1.5.3-linux-x86_64/julia-1.5.3/bin/: ***Permission denied***
`"/opt/julia-1.5.3-linux-x86_64/julia-1.5.3/bin/" --startup-file=no --history-file=no -e "using Pkg; println(dirname(Pkg.Types.Context().env.project_file))"` (exited with error code 126)
I noticed in the previous error message it says "permission denied", so I change the path to where the static link is located "/usr/local/bin/julia.exe", but in this case it shows me the same "permission denied" error message.
Does anyone know how to get around this issue?
Thanks!
The cause of the issue is when I installed vs code on linux, I accidentally synced the accounted settings I used in a windows laptop, and that seems to mess up the Julia extension (I used to use Julia extension in windows vs code). I tried uninstall and reinstall vs code, and make sure I don't sync my windows account settings, this time julia extension works for me right after installing it. I don't even need to define any paths.
I'm working on a pure x64 version of my software. Our installer for the x86 version is NSIS and my software is built using VS2012. I found online that in order to build x64 installers using NSIS you have to build NSIS (and all plugins/etc) from source. That is the end goal. However, right now I'm having issues just building x86 (before moving on to x64) using the instructions in the NSIS docs. https://nsis.sourceforge.io/Docs/AppendixG.html#build_windows
I'm trying to build NSIS v3.0.4 which uses SCons to build. I've installed scons using pip (SCons version 3.1.1).
However, when trying to build NSIS, I get the following (using python 3.8.0).
C:\Source\nsis\nsis-code-r7069-NSIS-tags-v304>scons ZLIB_W32=C:\Source\zlib-1.2.7 MSTOOLKIT=yes
scons: Reading SConscript files ...
TypeError: cannot use a string pattern on a bytes-like object:
File "C:\Source\nsis\nsis-code-r7069-NSIS-tags-v304\SConstruct", line 263:
for v in re.compile(r'^\\H\{[v]?(\S+)\}', re.M).finditer(File('#/Docs/src/history.but').get_contents()): # Try to parse the Halibut history file
the section of the SConstruct file is as follows (starting at line 260 so the for loop starts at 263):
if not defenv.has_key('VER_PACKED'):
import re
found = None
for v in re.compile(r'^\\H\{[v]?(\S+)\}', re.M).finditer(File('#/Docs/src/history.but').get_contents()): # Try to parse the Halibut history file
if v and not found:
v = v.group(1).split('.')
if len(v) >= 2:
mi = int(re.search(r'\d+', v[1]).group())
if mi < 1: mi = 1 # Make sure we can subtract 1 from the minor number so trunk stays below the next release
defenv['VER_PACKED'] = '0x%0.2i%0.3i%0.2i%0.1i' % (int(re.search(r'\d+', v[0]).group()), mi - 1, 66, 6)
if int(defenv['VER_PACKED'], 0) >= int('0x03000000', 0):
found = v
if not found:
defenv['VER_PACKED'] = '0x%0.2i%0.3i%0.2i%0.1i' % (3, 3, 42, 0) # Default to a version number we never used
print('WARNING: VER_PACKED not set, defaulting to %s!' % defenv['VER_PACKED'])
At this point, I'm not sure if there is a dependency I'm missing or if this is an issue with the build script and needs to be reported at the NSIS issue tracker. Ideas?
-UPDATE 1-
Based on suggestions from #Anders, first I tried to build the head of the repo (r7132 trunk) instead of v3.0.4 using Python3. This got me farther but still failed on what appears to be Python2 vs 3 syntax errors in mstoolkit.py (might be a symptom of another issue rather than the cause though). I didn't investigate this too much further yet.
So next, I went back to Python 2.7. This got me further but the mstoolkit.py appears to be dependent on VS2003 implementation. I duplicated the VCToolkitInstallDir environment variable on my machine using the contents of the VS110COMNTOOLS (C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools) but that fails also:
File "C:\Source\IQClient_Interim\Shared\third_party\nsis\nsis-code-r7132-NSIS-tags-v304\SCons\Tools\mstoolkit.py", line 87, in get_msvctoolkit_paths
raise SCons.Errors.InternalError, "The Platform SDK directory was not found in the registry or in the `MSSdk` environment variable."
InternalError: The Platform SDK directory was not found in the registry or in the `MSSdk` environment variable.
I don't know what the VS2003 VCToolkitInstallDir ENVVAR was pointing to to fix this.
With all that said, I just noticed that Anders said that I might also have to use an older version of scons as well with python2.7 so I suppose I'll spend some time investigating that (along with looking into #bdbaddog's solution).
-UPDATE 2-
it was the mstoolkit directive (see #Anders answer's comments)
I got it working after that while using py 2.7 for NSIS 3.0.4.
Now on to x64 build but that's a different story so I'll post a different question.
NSIS v3.04 does not support Python 3, you have to grab the latest source code from SVN. v3.05 is coming out soon with support for Python 3.
VS2012 is old enough that you should be able to use Python 2.7 and a older version of SCons as an alternative.
As a final alternative, you can try to apply this diff to v3.04.
The issue you're running into is twofold.
Python > 3.0 strings are no longer bytes. They are unicode
SCons which supports Python > 3.0 (SCons >3.0 supports Python 2.7 and Python > 3.5.0)
In order to support this Node()'s (SCons's way of representing files, directories, and values which feed into a build) now have two methods get_contents() and get_text_contents().
Since you're using Python 3.8.0, get_contents() will return bytes, which explains the error you've received.
The proper way to resolve it is to change this line:
for v in re.compile(r'^\\H\{[v]?(\S+)\}', re.M).finditer(File('#/Docs/src/history.but').get_contents()): # Try to parse the Halibut history file
to:
for v in re.compile(r'^\\H\{[v]?(\S+)\}', re.M).finditer(File('#/Docs/src/history.but').get_text_contents()): # Try to parse the Halibut history file
Please let me know if this doesn't resolve the issue.
Also, if you're willing to install Python 2.7 and reinstall SCons via
py -2.7 -mpip install scons
(Assuming you've install the py launcher when installing Python. Not sure if that's default with Python 3.8 and/or Python 2.7. If not then /python -m pip install scons. You might have to install pip as well. Once again not sure on the default for that.)
Then you can avoid changing the SConstruct file.
Hope this helps!
I am trying to build Assimp to use in visual studio 2012.
Following the instructions on their website: http://assimp.sourceforge.net/lib_html/cmake_build.htm I have tried to build assimp, however I am stuck on the last step "Open the generated solution/project files and have fun"
This is the build folder which was created by CMake - http://puu.sh/fq8kp/cc16e985c3.png
Following the advice of another tutorial I opened this in the terminal and tried to type "make" and launch it. However there isnt a make file so this didnt work. I also typed "install" as there is an install file, however this also did not work.
The tutorial goes as follows:
Type "make" and launch it; you should see the build progressing without issues
When the build is finished, type "sudo make install"; it will ask for your password and install the library!
Any help would be much appreciated!
the 'generated solution/project' in your case (windows) would be the Assimp.sln file. You generated a visual studio solution, so you have to use Visual Studio to build the application.
According to your screenshot, the Assimp.sln file is the 9 KB sized file underneath the one with size 45,120 KB
The VS environment variable is set beforehand with vcvars32.bat, and VS is the only compiler that I use; the OS is win 7.
The error happens with cmake-gui; specifying the compiler with path results in error 'compiler failed to make simple test'; alternatively, cmake -i from command line succeeds initially with presenting an 'options' menu which then fails to allocate a 'cmakelists.txt' file (which is somewhere deeper in the cmake folder).
Where am I going wrong?
(I continued with building the solution files from VS 12, but there's other issues.)
The answer to your question from cmake mailing list
Run cmake-gui FROM the target environment, just like you run cmake...
i.e. : type "cmake-gui" in the cmd prompt that has your stuff set up
in it. Don't just launch it from a short-cut unless you're using the
"Visual Studio *" generators. Those do not need any special
environment. Many of the makefile ones do.
Today is officially my first day with C++ :P
I've downloaded Visual C++ 2005 Express Edition and Microsoft Platform SDK for Windows Server 2003 SP1, because I want to get my hands on the open source Enso Project.
So, after installing scons I went to the console and tried to compile it using scons, but I got this error:
C:\oreyes\apps\enso\enso-read-only\src\platform\win32\Include\WinSdk.h(64) : fatal error C1083: Cannot open include file: 'Windows.h': No such file or directory
scons: *** [src\platform\win32\InputManager\AsyncEventProcessorRegistry.obj] Error 2
scons: building terminated because of errors.
After checking these links:
VS ans PSDK
Include tiffi.h
Wndows.h
I've managed to configure my installation like this:
And even run this script
And I managed to compile the file below in the IDE.
// Test.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <Windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
But I still get that exception in the console. Does anyone have scons experience?
EDIT
Actually (and I forgot to tell you this) I started the command prompt with the link "Visual Studio 2005 Command Prompt".
I assume this will include the paths in environment variables. Well after printing them I find that it didn't:
echo %INCLUDE%
echo %LIB%
echo %PATH%
And they were not present, so I created this .bat file:
set PATH=%PATH%;"C:\Program Files\Microsoft Platform SDK\Bin"
set INCLUDE=%INCLUDE%;"C:\ Program Files\Microsoft Platform SDK\Include"
set LIB=%LIB%;"C:\ Program Files\Microsoft Platform SDK\Lib"
Still, scons seeems not to take the vars... :(
Using the above recommendations will not work with scons: scons does not import the user environment (PATH and other variables). The fundamental problem is that scons does not handle recent versions of SDKs/VS .
I am an occasional contributor to scons, and am working on this feature ATM. Hopefully, it will be included soon in scons, but the feature is much harder to implement reliably than I first expected, partly because every sdk/compiler combination is different (and sometimes even MS does not get it right, some of their .bat files are broken), so I can't give you a date. I hope it will be included in 1.2 (to be released in approximatively one month).
You need to set the include file path (and possibly other things). At the command line this is typically done using a batch file that Visual Studio installs called vsvars32.bat (or vcvars32.bat for compatibility with VC6).
I'm not familiar with scons so I don't know the best way to get these settings configured for that tool, but for standard makefiles there's usually a line in the makefile which sets a macro variable with the include directory path and that macro is used as part of a command line parameter in the command that invokes the compiler.
Another possibility might be to have the scons process invoke vsvars32.bat or run the scons script from a command line that has been configured with the batch file.
In short you need to get the things that vsvars32.bat configures into the scons configuration somehow.
There will be a batch file similar to this one (for MSVC 2005) that sets up the environment variables:
c:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat
Step 1: Find a similar file in the Express installation folders
Step 2: Create a shortcut on the desktop with these target details and a suitably modified path:
cmd.exe /K "c:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat"
Step 3: Open the DOS prompt via this shortcut
The command line build should now work from within this console window.
You show us how you configured Visual Studio for compilations within Visual Studio but you didn't show us what command line environment you tried. Sorry I haven't tried Express versions so I don't know if they create additional Start menu shortcuts like Pro and above do. If you open a suitable command prompt with its environment variables already set then you can compile on the command line. Otherwise you have to set variables yourself or execute a batch script to set them, each time you open a command prompt.
It'll be nice when scons does this automatically. For now, I use this (run from an SDK command prompt, not sure if there is a difference if run after vsvars32.bat):
import os
env = Environment(ENV={'PATH': os.environ['PATH']})
env['ENV']['TMP'] = os.environ['TMP']
env.AppendUnique(CPPPATH=os.environ['INCLUDE'].split(';'))
env.AppendUnique(LIBPATH=os.environ['LIB'].split(';'))
This works for me while compiling wxwidgets with Visual C++ 2005 Express using the command line prompt:
REM Fix Error error C1083 'windows.h'
(Use /useenv option when compiling.)
set PDSKWIN=C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2
(Change to the right one.)
set INCLUDE=%PDSKWIN%\Include;%INCLUDE%
set LIB=%PDSKWIN%\Lib;%LIB%
Then I use this line when compiling. I believe just add /useenv to your lines and everything should work fine:
vcbuild /useenv /nohtmllog /nologo name.proj (or any file to compile)