How do I specify build option:
python setup.py build --fcompiler=gnu95
when I build rpm package:
python setup.py bdist --format=rpm
bdist seems to be building it all over again.
python setup.py build --fcompiler=gnu95 bdist --format=rpm
Related
I'm trying to install ansible-pylibssh on an Apple Silicon based Mac.
ansible is already installed.
When running pip3 install ansible-pylibssh I get the following error:
pip3 install --user ansible-pylibssh 1 ✘ took 3s at 00:36:15
Collecting ansible-pylibssh
Using cached ansible-pylibssh-1.0.0.tar.gz (97 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: ansible-pylibssh
Building wheel for ansible-pylibssh (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for ansible-pylibssh (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [18 lines of output]
[1/1] Cythonizing /private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/pylibsshext/_libssh_version.pyx
running build_ext
creating /private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/tmpa3ax4nf7/private
creating /private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/tmpa3ax4nf7/private/var
creating /private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/tmpa3ax4nf7/private/var/folders
creating /private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/tmpa3ax4nf7/private/var/folders/6l
creating /private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/tmpa3ax4nf7/private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn
creating /private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/tmpa3ax4nf7/private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T
creating /private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/tmpa3ax4nf7/private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa
creating /private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/tmpa3ax4nf7/private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b
creating /private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/tmpa3ax4nf7/private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src
creating /private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/tmpa3ax4nf7/private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/pylibsshext
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -I/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/include/python3.9 -c /private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/pylibsshext/_libssh_version.c -o /private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/tmpa3ax4nf7/private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/pylibsshext/_libssh_version.o
/private/var/folders/6l/48k83hdn30bc24655lbtzgx80000gn/T/pip-install-lme1njwa/ansible-pylibssh_0b7185d13e5244b3982c6d892f55319b/src/pylibsshext/_libssh_version.c:757:10: fatal error: 'libssh/libssh.h' file not found
#include "libssh/libssh.h"
^~~~~~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for ansible-pylibssh
Failed to build ansible-pylibssh
ERROR: Could not build wheels for ansible-pylibssh, which is required to install pyproject.toml-based projects
However libssh is already installed:
brew install libssh
Warning: libssh 0.10.4 is already installed and up-to-date.
To reinstall 0.10.4, run:
brew reinstall libssh
I have tried reinstalling ansible, libssh, none of them worked.
I'm having the same problem as you, this issue was finally solved today.
When i manually building and installing from source, still run into this problem:
#include "libssh/libssh.h"
^~~~~~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
This is because the libssh library was not discovered by clang, so we manually added a softlink to solve it.
Find out the lib dir:
% clang -E -x c - -v < /dev/null
Apple clang version 14.0.0 (clang-1400.0.29.102)
Target: arm64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
......
ignoring nonexistent directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
/Library/Developer/CommandLineTools/usr/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.
......
Create a softlink for libssh:
% cd /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
% sudo ln -s /opt/homebrew/Cellar/libssh/0.10.4/include/libssh/ libssh
Rebuilding and installing from source, Worked!
Install libssh:
brew install libssh
Use a python virtual environment :
python3 -m venv .venv
source .venv/bin/activate
EDIT:
Install with correct compiler flags:
CFLAGS="-I $(brew --prefix)/include -I ext -L $(brew --prefix)/lib -lssh" pip install ansible-pylibssh
Thanks, #webknjaz!
OLD Additional steps not needed (preserved for history):
Install tox build tool:
pip install 'tox >= 3.19.0'
Build from source on ARM-based Macs, per the ansible-pylibssh docs:
#git clone https://github.com/ansible/pylibssh.git ~/src/github/ansible/pylibssh
# or, if you use SSH:
git clone ssh://git#github.com/ansible/pylibssh.git ~/src/github/ansible/pylibssh
cd ~/src/github/ansible/pylibssh
Use libraries installed by brew with clang:
export CFLAGS="-I $(brew --prefix)/include -I ext -L $(brew --prefix)/lib -lssh"
Build ansible-pylibssh:
tox -e build-dists
Install built ansible-pylibssh wheel:
pip install ~/src/github/ansible/pylibssh/dist/ansible_pylibssh*.whl
Additional resources that lead to this answer:
Kristof Rado's answer
ansible/pylibssh GitHub issue 207 provides background on why this package is not available for macOS on ARM from PyPi (symlink/softlink to point to the libraries did not help. Correct compiler flags were the needed answer.)
If you prefer not to work with a virtual environment, this may work: replace pip commands python3 -m pip --user and python commands with python3.
The problem was with the package not my computer.
It seems that Github Actions are not available for ARM Macs so no dists were built for this platform.
Manually building and installing from source worked:
$ git clone https://github.com/ansible/pylibssh.git
$ cd pylibssh
$ pip install tox
$ tox -e build-dists
Installing:
cd dist
pip3 install ansible_pylibssh-1.0.1.dev47+g75289d4-cp39-cp39-macosx_12_0_arm64.whl
Defaulting to user installation because normal site-packages is not writeable
Processing ./ansible_pylibssh-1.0.1.dev47+g75289d4-cp39-cp39-macosx_12_0_arm64.whl
Installing collected packages: ansible-pylibssh
Successfully installed ansible-pylibssh-1.0.1.dev47+g75289d4
I 'm fighting 3 days now to setup my venv...
I need cython, openmp....
My IDE is PyCharm Prof in macOS... I have tried plenty solutions with no result...
when i try to build with PyCharm... the building result is:
UserWarning: Unknown distribution option: 'cmd_class' warnings.warn(msg)
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: no commands supplied
so, when i try with:
python setup.py install build_ext --inplace
No build again.... The error is following:
ld: warning: directory not found for option '-L/install/prefix/lib'
ld: warning: -L path '/usr/local/Cellar/llvm/9.0.1/lib/libomp.dylib' is not a directory
ld: warning: directory not found for option '-L/install/prefix/lib'
ld: warning: directory not found for option '-L/usr/local/Cellar/gcc/9/gcc/x86_64-apple-darwin19/9.3.0/include/omp.h'
ld: library not found for -lomp
clang-9: error: linker command failed with exit code 1 (use -v to see invocation)
error: command '/usr/local/opt/llvm/bin/clang++' failed with exit status 1
i have already install:
brew install llvm
brew install libomp
clang version 9.0.1
Target: x86_64-apple-darwin19.3.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin
The setup.py is according to https://cython.readthedocs.io/en/latest/src/userguide/parallelism.html but i have try a lot of differents mods... i am trying to setup 3-days now...
Finally... i know that the compilation is completed with errors. Although if i try to run it... i have the following resutlts... maybe it helps...
ImportError: dlopen(myfile.pyx, 2): Symbol not found: _omp_get_num_threads
Referenced from: myfile.pyx
Expected in: flat namespace
in myfile.pyx.cpython-36m-darwin.so
I 've read somewhere that there is no way to implement in OSX Cython-App with usage of openMP but i m still believe that there is a way...
My system is macOS Catalina 10.15.3 ...
I need your help!!!
Finally i find the solution...
In your venv:
pip install Cython setuptools
Find where is your gcc compiler... if you have already install do as follows, in other case find and install one...
$ mdfind gcc | grep gcc
Put the whole gcc directory in your project's venv.
(path: /My_Project/venv/gcc)
and setup.py should be the following... (path: /My_Project/package/setup.py)
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
from Cython.Distutils import build_ext
import os
os.environ["CC"]="../venv/gcc/9.3.0/bin/gcc-9"
os.environ["CXX"]="../venv/gcc/9.3.0/bin/gcc-9"
ext_modules = [Extension(
"filename",
["filename.pyx"],
language='c',
extra_compile_args=['-fopenmp',"-Os",],
extra_link_args=['-fopenmp', ],
)
]
setup(
name='filename',
cmd_class = {'build_ext': build_ext},
ext_modules= cythonize(ext_modules),
)
Your cython file: filename.pyx ... could starts with a compiler directive comment at the top of filename.pyx as following:
# distutils: extra_compile_args = -fopenmp
# distutils: extra_link_args = -fopenmp
Run in your venv the compilation command:
$ python setup.py build_ext -i
Finally you can import your cython file in your code... at the top of your python file etc. mycode.py :
import filename
filename.myCythonFunc()
The above gives the solution for OSX-10.15.3 macOS Catalina.
I am trying to create a docker container for my python application (this is the first time I am trying to use docker). I looked at the online tutorials and created a DockerFile as follows:
FROM python:3.6-alpine
COPY . /app
WORKDIR /app
RUN apk --update add --no-cache \
lapack-dev \
gcc \
freetype-dev
# Install dependencies
RUN apk add --no-cache --virtual .build-deps \
gfortran \
musl-dev \
g++
RUN pip3 install -r requirements.txt
RUN python3 setup.py install
RUN apk del .build-deps
ENTRYPOINT python3 testapp.py
My project requirements are:
numpy==1.13.3
Cython==0.28.2
nibabel==2.2.1
scipy==1.0.0
I build the docker file as: docker build -t myimg .
So, the docker file progresses but scipy fails to build with the following error:
Collecting numpy==1.13.3 (from -r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/bf/2d/005e45738ab07a26e621c9c12dc97381f372e06678adf7dc3356a69b5960/numpy-1.13.3.zip (5.0MB)
Collecting Cython==0.28.2 (from -r requirements.txt (line 2))
Downloading https://files.pythonhosted.org/packages/79/9d/dea8c5181cdb77d32e20a44dd5346b0e4bac23c4858f2f66ad64bbcf4de8/Cython-0.28.2.tar.gz (1.9MB)
Collecting nibabel==2.2.1 (from -r requirements.txt (line 3))
Downloading https://files.pythonhosted.org/packages/d7/de/1d96fd0b118c9047bf35f02090db8ef8fd3927dfce635f09a6f7d5b572e6/nibabel-2.2.1.zip (4.2MB)
Collecting scipy==1.0.0 (from -r requirements.txt (line 4))
Downloading https://files.pythonhosted.org/packages/d0/73/76fc6ea21818eed0de8dd38e1e9586725578864169a2b31acdeffb9131c8/scipy-1.0.0.tar.gz (15.2MB)
Collecting six>=1.3 (from nibabel==2.2.1->-r requirements.txt (line 3))
Downloading https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Building wheels for collected packages: numpy, Cython, nibabel, scipy
Running setup.py bdist_wheel for numpy: started
Running setup.py bdist_wheel for numpy: still running...
Running setup.py bdist_wheel for numpy: still running...
Running setup.py bdist_wheel for numpy: still running...
Running setup.py bdist_wheel for numpy: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/b6/10/65/189b772e73b4505109d5a1e6671b07e65797023718777295e0
Running setup.py bdist_wheel for Cython: started
Running setup.py bdist_wheel for Cython: still running...
Running setup.py bdist_wheel for Cython: still running...
Running setup.py bdist_wheel for Cython: still running...
Running setup.py bdist_wheel for Cython: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/6f/24/5d/def09ad0aed8ba26186f2a38070906f70ab4b2287bf64d4414
Running setup.py bdist_wheel for nibabel: started
Running setup.py bdist_wheel for nibabel: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/46/50/8d/bcb0b8f7c030da5bac1752fbe9cc375cbf5725fa93ba79ad84
Running setup.py bdist_wheel for scipy: started
Running setup.py bdist_wheel for scipy: finished with status 'error'
Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-boosbyfg/scipy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-cczhwdqj --python-tag cp36:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-boosbyfg/scipy/setup.py", line 418, in <module>
setup_package()
File "/tmp/pip-install-boosbyfg/scipy/setup.py", line 398, in setup_package
from numpy.distutils.core import setup
ModuleNotFoundError: No module named 'numpy'
Not sure why it is having issue finding numpy as it was installed as part of the requirements?
Because to build scipy wheel you need to have numpy installed. However, only numpy wheel build was complete by the time pip attempts to build scipy wheel.
You will have to install the dependencies first. There are multiple ways to do this.
1) Use a shell script like the one below, copy it and RUN it instead of RUN pip install -r requirements.txt:
#!/bin/sh
while read module; do
pip install $module
done < requirements.txt
2) Install scipy in a seperate RUN command.
3) apk add py-numpy#community as discussed in this answer.
I have created a pypi package for educational purposes, and I wanted to do an upgrade. I did through the usual steps(do the changes, run setup.py etc)
but when I do:
python3 setup.py bdist_wheel
I am getting the error
python3 setup.py build bdist_wheel
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: invalid command 'bdist_wheel'
Wheel and pip are installed and up to date:
pip3 install wheel
Requirement already satisfied: wheel in /usr/local/lib/python3.4/dist-
packages (0.31.0)
The help of the command, does not seem to support bdist_wheel.
Am I missing something?
python3 setup.py --help-commands
Standard commands:
build build everything needed to install
build_py "build" pure Python modules (copy to build directory)
build_ext build C/C++ extensions (compile/link to build directory)
build_clib build C/C++ libraries used by Python extensions
build_scripts "build" scripts (copy and fixup #! line)
clean clean up temporary files from 'build' command
install install everything from build directory
install_lib install all Python modules (extensions and pure Python)
install_headers install C/C++ header files
install_scripts install scripts (Python or otherwise)
install_data install data files
sdist create a source distribution (tarball, zip file, etc.)
register register the distribution with the Python package index
bdist create a built (binary) distribution
bdist_dumb create a "dumb" built distribution
bdist_rpm create an RPM distribution
bdist_wininst create an executable installer for MS Windows
check perform some checks on the package
upload upload binary package to PyPI
Extra commands:
alias define a shortcut to invoke one or more commands
bdist_egg create an "egg" distribution
develop install package in 'development mode'
easy_install Find/get/install Python packages
egg_info create a distribution's .egg-info directory
install_egg_info Install an .egg-info directory for the package
rotate delete older distributions, keeping N newest files
saveopts save supplied options to setup.cfg or other config file
setopt set an option in setup.cfg or another config file
test run unit tests after in-place build
upload_docs Upload documentation to PyPI
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
EDIT:
python3 --version
Python 3.6.3
pip3 --version
pip 10.0.1 from /usr/local/lib/python3.4/dist-packages/pip (python 3.4)
Looks like pip version and python version didnt match...fixing this removed the problem.
I am running the following command
pip install -r .\requirements.txt
in the project directory and get the following error
Using cached psycopg2-2.5.3.tar.gz
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info\psycopg2.egg-info
writing pip-egg-info\psycopg2.egg-info\PKG-INFO
writing top-level names to pip-egg-info\psycopg2.egg-info\top_level.txt
writing dependency_links to pip-egg-info\psycopg2.egg-info\dependency_links.txt
writing manifest file 'pip-egg-info\psycopg2.egg-info\SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
Error: pg_config executable not found.
Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\eugene~1\appdata\local\temp\pip-build-mil943\psy
copg2
C:\Program Files\PostgreSQL\9.4\bin has to been in environment path