using cmath special functions extending Python with C++ - c++

I am trying to build a Python package in C++, and when I build, I get no errors; however, when I use pip install, I get the following result:
----- Installing 'D:\GitHub\dir\dir\ --user' -----
Processing d:\github\dir\dir
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'done'
Building wheels for collected packages: package_name
Building wheel for package_name (pyproject.toml): started
Building wheel for package_name (pyproject.toml): finished with status 'error'
error: subprocess-exited-with-error
Building wheel for package_name (pyproject.toml) did not run successfully.
exit code: 1
[14 lines of output]
Failed to build package_name
running bdist_wheel
running build
running build_ext
building 'package_name' extension
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\Users\etcto\AppData\Local\Programs\Python\Python310\include -IC:\Users\etcto\AppData\Local\Programs\Python\Python310\Include "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\ATLMFC\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\cppwinrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" /EHsc /Tpmodule.cpp /Fobuild\temp.win-amd64-cpython-310\Release\module.obj
module.cpp
module.cpp(28): error C2039: 'comp_ellint_1f': is not a member of 'std'
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include\cmath(710): note: see declaration of 'std'
module.cpp(28): error C3861: 'comp_ellint_1f': identifier not found
module.cpp(28): error C2039: 'comp_ellint_1f': is not a member of 'std'
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include\cmath(710): note: see declaration of 'std'
module.cpp(28): error C3861: 'comp_ellint_1f': identifier not found
module.cpp(61): warning C4244: 'argument': conversion from 'double' to 'float', possible loss of data
error: command 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.33.31629\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for package_name
ERROR: Could not build wheels for package_name, which is required to install pyproject.toml-based projects
----- Failed to install 'D:\GitHub\dir\dir\ --user' -----
I have a feeling it's trying to use C++ 14 (which didn't include comp_ellint_1f) because I see the number in the directories listed, but in my properties page (for both Release and Debug), I have the "C++ Language Standard" set to "ISO C++ 20 Standard (/std:c++20)".
When I remove that function from the project, pip installs the package just fine, and I can import it into Python without issue. I am not sure how to tell it to use C++ 20 for the pip install portion.
MRE:
#include <Python.h>
#include <Windows.h>
#include <cmath>
PyObject* k_func(PyObject* /* unused module reference */, PyObject* args) {
double k, integral;
PyArg_ParseTuple(args, "d", &k);
double integral = std::comp_ellint_1(k);
return PyFloat_FromDouble(integral);
}
static PyMethodDef package_name_methods[] = {
// The first property is the name exposed to Python, k
// The second is the C++ function with the implementation
// METH_O means it takes a single PyObject argument
{ "ellipticK", (PyCFunction)k_func, METH_VARARGS, "Calculate elliptic integral" },
// Terminate the array with an object containing nulls.
{ nullptr, nullptr, 0, nullptr }
};
static PyModuleDef package_name_module = {
PyModuleDef_HEAD_INIT,
"package_name",
"Module Description",
0,
package_name_methods
};
PyMODINIT_FUNC PyInit_package_name() {
return PyModule_Create(&package_name_module);
}
pyproject.toml is
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
setup.py is
from setuptools import setup, Extension
sfc_module = Extension('package_name', sources = ['module.cpp'])
setup(
name='package_name',
version='0.0',
description='Description',
ext_modules=[sfc_module]
)

Thanks for the compiler flag suggestion; the following worked:
from setuptools import setup, Extension
sfc_module = Extension('package_name', sources = ['module.cpp'],
extra_compile_args=["/std:c++20"],
)
setup(
name='package_name',
version='0.0',
scripts=[],
ext_modules=[sfc_module]
)

Related

wrong version of expo-cli after upgrade

for many time i get the following info message after start expo projects, and it seems its not possible to upgrade expo-cli:
There is a new version of expo-cli available (4.2.1). You are currently using expo-cli 3.28.0 Install expo-cli globally using the package manager of your choice; for example: npm install -g expo-cli to get the latest version
This seems easier as it looks. After installing expo-cli globally without errors
+ expo-cli#4.2.1
OK, now im typing expo -V to check the new Version but wait: its 3.28.0
My project package.json dont have expo-cli in. Is there a way to locate the used expo version?
edit:
i found 1 PATH file till now.
(C:\Users\myuser.expo) it contents:
C:\Users\SYSTEM~1\AppData\Local\Temp\yarn--1615049876273-0.687029522126771;
C:\Users\myuser\WfManager\fmapp\node_modules\.bin;
C:\Users\myuser\AppData\Local\Yarn\Data\link\node_modules\.bin;
C:\Program Files\libexec\lib\node_modules\npm\bin\node-gyp-bin;
C:\Program Files\lib\node_modules\npm\bin\node-gyp-bin;
C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;
C:\Program Files (x86)\Lenovo\FusionEngine;
C:\Windows\system32;
C:\Windows;
C:\Windows\System32\Wbem;
C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\Program Files (x86)\Common Files\lenovo\easyplussdk\bin;
C:\Program Files (x86)\Common Files\Apple\Apple Application Support;
C:\WINDOWS\system32;
C:\WINDOWS;
C:\WINDOWS\System32\Wbem;
C:\WINDOWS\System32\WindowsPowerShell\v1.0\;
C:\WINDOWS\System32\OpenSSH\;
C:\xampp\php;
C:\Program Files\Git\cmd;
C:\Program Files\PuTTY\;
C:\Program Files\Symfony;
C:\Program Files (x86)\Yarn\bin\;
C:\Program Files\nodejs\;
C:\composer;
C:\Users\myuser\AppData\Local\Microsoft\WindowsApps;
C:\Users\myuser\AppData\Local\Programs\Microsoft VS Code\bin;
C:\Users\myuser\AppData\Roaming\Composer\vendor\bin;
C:\Users\myuser\AppData\Local\Yarn\bin;
C:\Users\myuser\AppData\Local\GitHubDesktop\bin;
C:\Users\myuser\AppData\Roaming\npm
after writing this down and check the entries i found one entry which
links to an old version:
C:\Users\myuser\AppData\Local\Yarn\Data\link\node_modules\.bin; //old version
C:\Users\myuser\AppData\Roaming\npm //new version`
i want to update expo-cli with xarn global now and we will see what happens.
You can check path to binary with command -v expo.
In this case you most likely installed expo-cli globally both with npm and yarn, version 3.28.0 is just earlier in your PATH. It's also possible that you have two node versions (and 2 npm versions) installed, but it's less likely.

Jhipster failure build war file

I use this mvn -Pprod and I get errors like this:
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.6:yarn (webpack build prod) on project jhi: Failed to run task: 'yarn run webpack:prod' failed. org.apache.commons.exec.ExecuteE
xception: Process exited with an error: 1 (Exit value: 1) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Arguments:
E:\vaqtinchalik\Vaqf\jhiProject\node\node.exe E:\vaqtinchalik\Vaqf\jhiProject\node\yarn\dist\bin\yarn.js install --force
PATH:
E:\vaqtinchalik\Vaqf\jhiProject\node;E:\vaqtinchalik\Vaqf\jhiProject\node\yarn\dist\bin;E:\vaqtinchalik\Vaqf\jhiProject\node_modules.bin;C:\Program Files (x86)\Google\Chrome\Application;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Java\jdk1.8.0_66\bin;E:\maven\apache-maven-3.5.4\bin;C:\Program Files (x86)\Yarn\bin\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files (x86)\Windows Kits\8.0\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\nodejs\;C:\Program Files\PuTTY\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\WinMerge;C:\Program Files\Git\cmd;C:\Users\JavaProgUZ\AppData\Local\Microsoft\WindowsApps;C:\Users\JavaProgUZ\AppData\Local\Yarn\bin;C:\Users\JavaProgUZ\AppData\Roaming\npm;
Yarn version:
1.3.2
Node version:
8.9.4
Trace:
Error: EPERM: operation not permitted, unlink 'E:\vaqtinchalik\Vaqf\jhiProject\node_modules\node-sass\vendor\win32-x64-57\binding.node'

error of compilation wiringPi.h in visual studio

I'm asking for help. I can't compile the app in visual Studio for Windows.
wiringPi.h needed to work with RaspberryPI GPIO
(raspberry pi 3b+ worked on ARM)
GIF
https://pp.userapi.com/c849336/v849336202/789a8/2d6RIDT4S28.jpg
https://pp.userapi.com/c849336/v849336202/789ba/tvBF_VF9M5M.jpg
1>H:\ВГУшное облако\OneDrive - ВГУ\Visual studio\BlinkPI\BlinkPI\main.cpp(1,127): error : C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\Linux\include\wiringPi\2.32\wiringPi.h: No such file or directory
1>Сборка проекта "BlinkPI.vcxproj" завершена с ошибкой.
or https://pp.userapi.com/c850324/v850324544/341e5/vzb2HHJYT78.jpg
1>H:\ВГУшное облако\OneDrive - ВГУ\Visual studio\BlinkPI\BlinkPI\main.cpp(1,22): error : wiringPi.h: No such file or directory
1>H:\ВГУшное облако\OneDrive - ВГУ\Visual studio\BlinkPI\BlinkPI\main.cpp(1,22): error : #include <wiringPi.h>
1>H:\ВГУшное облако\OneDrive - ВГУ\Visual studio\BlinkPI\BlinkPI\main.cpp(1,22): error : ^
1>H:\ВГУшное облако\OneDrive - ВГУ\Visual studio\BlinkPI\BlinkPI\main.cpp(1,22): error : compilation terminated.
Thank you in advance
Add "wireingPi.h" to Visual Studio header src Path And Click Apply
I've had the same problem and found a solution here (in German). Basically, the tutorial states to clone the wiringPi.h from git and build it.
Hint: It is not the fault of VisualStudio (see my comment below the answer of Huseyin Meric Yigit), but it is a missing library on the Raspberry Pi.
The commands I typed in the console of the RasPi were (please adapt the paths to your needs):
cd /home/pi
mkdir lib
chmod 0777 lib
cd lib
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install git-core
git clone git://git.drogon.net/wiringPi
git pull origin
./build
Plan to have a coffee while executing the command on line 6 (upgrade). After it is finished, I could successfully compile the project in VisualStudio. Hope, this helps you, too.

pip install mod_wsgi failed. Window server 12, python 3.6.4 64 bit vc++14

I am trying to deploy my django app to a win server12 64bit. The latest apache is installed on the server( from apacheloung distro). build tool is vc15 build tool. Python 3.6.4 64bit. I follow the instruction of https://github.com/GrahamDumpleton/mod_wsgi/blob/develop/win32/README.rst
But I kept getting the error message like
....
src/server\mod_wsgi.c(4417): error C2065: 'wsgi_daemon_process':
undeclared identifier
src/server\mod_wsgi.c(4417): error C2223: left of '->group' must point to struct/union
src/server\mod_wsgi.c(6052): warning C4244: 'return': conversion from '__int64' to 'long', possible loss of data
error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe' failed with exit status 2
---------------------------------------- Command ""d:\program files\python36\python.exe" -u -c "import setuptools,
tokenize;file='C:\Users\ccsadmin\AppData\Local\Temp\pip-build-3ktbwpy9\mod-wsgi\setup.py';f=getattr(tokenize,
'open', open)(file);code=f.read().replace('\r\n',
'\n');f.close();exec(compile(code, file, 'exec'))" install --recor
d
C:\Users\xxx\AppData\Local\Temp\pip-aw2siwjx-record\install-record.txt
-- single-version-externally-managed --compile" failed with error code 1 in C:\Users\xxx\AppData\Local\Temp\pip-build-3ktbwpy9\mod-wsgi\
I have researched online and couldn't find anything similar to my situation. I have compiled successfully on my dev machine(win 10, python 3.64 32 bit)
Please advise.

Execute package failed in Sitecore Azure deployment

I have started the deployment of Editing farm and after some time got this error. Before that Databases are created in Azure.
Execute package failed System.ApplicationException: advaiyawebsiteDevScusCe01Role01SSc5e3Staging [S]
Execute package failed ---> System.ApplicationException: Execute package is failed ---> System.InvalidOperationException:
Build Package failed: Searching for imported module Caching at
C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.5\bin\plugins\Caching\Caching.csplugin...
Copying 'C:\InetPub\Sitecoredemo\Data\AzurePackages\(7) Azure\Sitecore.Azure.CacheWorkerRole'
to C:\Windows\TEMP\odbndccq.v4c\roles\SitecoreCacheWorkerRole\approot... Copying
'C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.5\bin\runtimes\base\x64'
to C:\Windows\TEMP\odbndccq.v4c\roles\SitecoreCacheWorkerRole\base\x64... Copying
'C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.5\bin\runtimes\base\x86'
to C:\Windows\TEMP\odbndccq.v4c\roles\SitecoreCacheWorkerRole\base\x86... Copying
'C:\InetPub\Sitecoredemo\Data\AzurePackages\(7) Azure\SitecoreWebSite' to
C:\Windows\TEMP\odbndccq.v4c\roles\SitecoreWebRole\approot... Copying
'C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.5\bin\runtimes\base\x64'
to C:\Windows\TEMP\odbndccq.v4c\roles\SitecoreWebRole\base\x64... Copying
'C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.5\bin\runtimes\base\x86'
to C:\Windows\TEMP\odbndccq.v4c\roles\SitecoreWebRole\base\x86... Copying
'C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.5\bin\plugins\Caching'
to C:\Windows\TEMP\odbndccq.v4c\roles\SitecoreCacheWorkerRole\plugins\Caching...
UCPack_Command_Line: Error : CloudServices41 : The entrypoint Sitecore.Azure.CacheWorkerRole.dll is not a valid assembly.
Please provide a relative path to the binary that implements the entrypoint.
at Sitecore.Diagnostics.Assert.IsFalse(Boolean condition, String message)
at Sitecore.Azure.Pipelines.CreateAzurePackage.Azure.ExecutePackage.Action(RolePipelineArgsBase arguments)
at Sitecore.Azure.Pipelines.BasePipeline.RolePipelineProcessor.Process(RolePipelineArgsBase args)
--- End of inner exception stack trace --- --- End of inner exception stack trace ---
It looks like you have incorrect version of Microsoft Azure SDK installed.
Sitecore Azure 8.0 rev. 150522 supports only version 2.5.1
Sitecore Azure 8.0 rev. 150522 Hotfix 68545-1 supports only version 2.7.1
Sitecore Azure 8.0 rev. 161110 supports only version 2.9.1
For more details, please check the following article: https://kb.sitecore.net/articles/026831