I am using AWS Pipeline to deploy a .NET Framework application but I am stuck while trying to create the zip file for Code Deploy.
The source and build steps are passing but when trying to create the package for Code Deploy, something odd is happening.
Here is my folder structure:
Project
-Source
-Base
-CoreAPI
-Api
- bin
- scripts
- appspec.yml
- ...
-Database
- ...
-Nuget
- ...
After the build, I want to create a zip file with all files and folders within "Project\Source\Base\CoreAPI\Api"
Here is a part of the buildspec.yml which relates to artifacts:
artifacts:
files:
- '**/*'
name: "api-build-artifact"
base-directory: .\Source\Api\CoreAPI\Api
As a result code build creates a zip file with all the files and folders within "Source", basically it discards the "base-directory".
I tried some variations like these:
artifacts:
files:
- '.\Source\Base\CoreAPI\Api\**\*'
But then I get a zip with the folder structure Source\Base\CoreAPI\Api + all files and folders and obviously, Code Deploy fails because the "appspec.yml" file is not in the root folder.
Any idea what might be wrong here?
Your indentation under artifacts is wrong. Try this:
artifacts:
files:
- '**/*'
name: "api-build-artifact"
base-directory: .\Source\Api\CoreAPI\Api
discard-paths: yes
Ref:
https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html
I wanted to run some code in IronPython using c#. In this code I needed to use numpy. So I tried to install it using the command below:
ipy -X:Frames -m pip install -U numpy
Unfortunately, I get an error and a return message telling me it was a unsuccessful installation. The error message is bellow:
Using cached https://files.pythonhosted.org/packages/3a/20/c81632328b1a4e1db65f45c0a1350a9c5341fd4bbb8ea66cdd98da56fe2e/numpy-1.15.0.zip
Installing collected packages: numpy
Running setup.py install for numpy ... error
Complete output from command "C:\Program Files\IronPython 2.7\ipy.exe" -u -c "import setuptools, tokenize;__file__='c:\\users\\mbhamida\\appdata\\local\\temp\\pip-build-t61kxu\\numpy\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\mbhamida\appdata\local\temp\pip-y91bz0-record\install-record.txt --single-version-externally-managed --compile:
Running from numpy source directory.
Note: if you need reliable uninstall behavior, then install
with pip instead of using `setup.py install`:
- `pip install .` (from a git repo or downloaded source
release)
- `pip install numpy` (last NumPy release on PyPi)
C:\Program Files\IronPython 2.7\Lib\distutils\dist.py:1: UserWarning: Unknown distribution option: 'python_requires'
"""distutils.dist
blas_opt_info:
blas_mkl_info:
customize MSVCCompiler
libraries mkl_rt not found in ['C:\\Program Files\\IronPython 2.7\\lib']
NOT AVAILABLE
blis_info:
customize MSVCCompiler
libraries blis not found in ['C:\\Program Files\\IronPython 2.7\\lib']
NOT AVAILABLE
openblas_info:
customize MSVCCompiler
customize MSVCCompiler
libraries openblas not found in ['C:\\Program Files\\IronPython 2.7\\lib']
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\setup.py", line 410, in <module>
File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\numpy\distutils\core.py", line 135, in setup
File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\numpy\distutils\system_info.py", line 625, in get_info
File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\numpy\distutils\system_info.py", line 433, in get_info
File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\numpy\distutils\system_info.py", line 625, in get_info
File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\numpy\distutils\system_info.py", line 1758, in calc_info
File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\numpy\distutils\fcompiler\__init__.py", line 61, in <module>
File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\setup.py", line 402, in setup_package
File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\setup.py", line 167, in configuration
File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\numpy\distutils\misc_util.py", line 1032, in add_subpackage
File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\numpy\distutils\misc_util.py", line 998, in get_subpackage
File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\numpy\distutils\misc_util.py", line 940, in _get_configuration_from_setup_py
File "numpy\setup.py", line 10, in configuration
File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\numpy\distutils\misc_util.py", line 1032, in add_subpackage
File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\numpy\distutils\misc_util.py", line 998, in get_subpackage
File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\numpy\distutils\misc_util.py", line 940, in _get_configuration_from_setup_py
File "numpy\core\setup.py", line 832, in configuration
File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\numpy\distutils\system_info.py", line 433, in get_info
File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\numpy\distutils\system_info.py", line 1621, in calc_info
TypeError: a new-style class can't have only classic bases
----------------------------------------
Command ""C:\Program Files\IronPython 2.7\ipy.exe" -u -c "import setuptools, tokenize;__file__='c:\\users\\mbhamida\\appdata\\local\\temp\\pip-build-t61kxu\\numpy\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\mbhamida\appdata\local\temp\pip-y91bz0-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\
I searched a lot about a solution, but I guess it is a very common problem.
Ps: I face the same problem with many other packages.
What can be the solution?
Python is first and foremost a language and has a default implementation in C: CPython. IronPython is another implementation of the language, based on .NET. As such, it implements the default core language and most of the standard library.
Some Python packages available through PIP are pure Python and rely on elements supported by IronPython. Some other modules are, however, specific to the implementation. In particular, numpy uses native C code, which is supported by CPython but not by IronPython. More info on the IronPython issue tracker: https://github.com/IronLanguages/ironpython2/issues/
For it to work, numpy would have to offer compatibility with .NET. I have seen a .NET refactor of numpy, but never got it working.
A solution for your problem? Avoid mixing numpy and .NET. If you find a way to make it work, though, I'm interested.
[Edit:] You might want to have a look at this answer on how to install numpy: https://stackoverflow.com/a/51900761/6690989
I am trying to install several packages to use it in a C# app via IronPython. However I get the following error when I run ipy -X:Frames -m pip install package_name from the windows console:
Exception:
Traceback (most recent call last):
File "c:\Program Files (x86)\IronPython 2.7\Lib\site-packages\pip\basecommand.py", line 209, in main
status = self.run(options, args)
File "c:\Program Files (x86)\IronPython 2.7\Lib\site-packages\pip\commands\install.py", line 299, in run
requirement_set.prepare_files(finder)
File "c:\Program Files (x86)\IronPython 2.7\Lib\site-packages\pip\req\req_set.py", line 356, in prepare_files
discovered_reqs.extend(self._prepare_file(
File "c:\Program Files (x86)\IronPython 2.7\Lib\contextlib.py", line 35, in __exit__
self.gen.throw(type, value, traceback)
File "c:\Program Files (x86)\IronPython 2.7\Lib\site-packages\pip\utils\logging.py", line 36, in indent_log
yield
ValueError: too many values to unpack
Update: Before the exception I see two warnings. Maybe they have to do with the problem.
C:\Program Files (x86)\IronPython 2.7\Lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py:1: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
from __future__ import absolute_import
C:\Program Files (x86)\IronPython 2.7\Lib\site-packages\pip\_vendor\requests\packages\urllib3\connection.py:1: SubjectAltNameWarning: Certificate for pypi.python.org has no `subjectAltName`, falling back to check for a `commonName` for now. This feature is being removed by major browsers and deprecated by RFC 2818. (See https://github.com/shazow/urllib3/issues/497 for details.)
from __future__ import absolute_import
I can install NLTK via pip in my separate python installation. I tried to reference these packages via sys.path.append() but it doesn't work either. However, I don't think it would be a good solution anyway.
I have a C# project used as PowerShell cmdlet - this should be the API to the main function of a product - so I have to reference a lot of dll's in my PowerShell library.
My problem is that customers want to load the PowerShell dll from any location without settings the working directory to the program folder where all dll's are located. But I only can use my PowerShell commands if I open Powershell by a shortcut where the working dir is set to the program files folder like this:
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -noexit -command "[reflection.assembly]::loadFrom('.\PSAPI.dll') | import-module"
and set also the working dir to my program files folder where the product is already installed.
If I just use
[Reflection.Assembly]::LoadFile("C:\Program Files(x86)\MyProduct\PSAPI.dll")
or
[Reflection.Assembly]::LoadFrom("C:\Program Files(x86)\MyProduct\PSAPI.dll")
it always fails. Is there a solution for that (without copying all files to PowerShell folder)?
Here is what I try and the error I get - I can't set the referenced dll's in other way - the .NET application is looking in the working dir for referenced dll's - I set the working dir in powershell to ensure I'm in the right directory, but it won't load my module
[reflection.assembly]::loadFrom( 'C:\Program Files (x86)\ASG-Remoteesktop 2016\ASGRD-PSAPI.dll' ) | import-module
Exception calling "LoadFrom" with "1" argument(s): "Could not load file or
assembly 'file:///C:\Program Files (x86)\ASG-Remoteesktop
2016\ASGRD-PSAPI.dll' or one of its dependencies. The system cannot find the
file specified."
At line:1 char:1
+ [reflection.assembly]::loadFrom( 'C:\Program Files (x86)\ASG-Remoteesktop
2016\A ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FileNotFoundException
Guessing here as you haven't provided the error but if it works from the same directory and not from another, it's probably that the C# DLL uses relative paths.
When the current directory is C:\Program Files(x86)\MyProduct it doesn't matter if you use the full path or just Resources\MyFile.dat, both will end up at the same place. However if you are in root C: the relative path will look for C:\Resources\MyFile.dat which of course doesn't exist. When you use C:\Program Files(x86)\MyProduct\Resources\MyFile.dat it doesn't matter what the current directory is, it will always work.
Check your C# DLL for any relative paths and either temporarily change the working directory or use absolute paths instead.
One approach could be: add your assembly path C:\Program Files(x86)\MyProduct to PSModulePath environment variable. Once that is done, you can execute import-module -name <name of your module> and it will load it from your folder. In that case you won't need to load your assembly explicitly (most probably).
For more details execute following command in powershell and check the details given for -name parameter.
get-help import-module -detailed
Hey there I could really use a guru on msbuild.
Ultimate goal: Build web deployment packages with TeamCity
I'm trying to call the Package target in TeamCity on my build server and it fails as path: Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.5 doesn't exist. 10.5 doesn't exist on my dev laptop either, I am using VS 2012, yet I can call MSbuild package target on the command line of my laptop with no problem.
I could make a copy of Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0 that does exist on the build server and rename it 10.5, but this just feels wrong.
Any pointers gratefully received.
EDIIT
For now I have just:
created the path: "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.5"
Copied contents of V10.0 into it.
Copied "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\web\Microsoft.WebSite.Publishing.targets" into it.
It's a case of getting the VisualStudioVersion right, override it on the command line and all is good.
C:\>msbuild web_site.publishproj /T:Package /P:Configuration=Release;PackageLocation=C:\packages;VisualStudioVersion=11.0