Is it possible to pip install package which provides optional C-extension, but specifically disable process of compiling those extensions?
Sample examples of such packages are:
_speedups in markupsafe
_posixsubprocess32 in subprocess32
It's not because it's setup.py that decides what and how to build. You have to download sources, unpack and edit setup.py to avoid building extensions.
Related
I'm developing my own conda package. I'm using a setup.py in the process of generating that package. When developing, it can be useful to conda install --no-deps package and ./setup.py develop in the repo. The install works, but setup.py errors out because it cannot satisfy a dependency. There is another package with the same name but to low version on pypi. However, the correct version of this dependency is already installed via conda. Why does it first try to install the package before checking if it is already installed? How can I make setup.py realize that nothing needs to be installed?
How is the package built?
I have this blt.bat:
"%PYTHON%" setup.py install --single-version-externally-managed --record=record.txt
if errorlevel 1 exit 1
and the dependencies listed in the meta.yaml. It falls to setup.py to define the package version (read from a .py file), define the entry points and the included non-Python files. It gets the dependencies by parsing the meta.yaml.
What is the error message?
This is the output of setup.py develop:
$ python setup.py develop
running develop
C:\ProgramData\Miniconda3\envs\my_env\lib\site-packages\setuptools\command\easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
C:\ProgramData\Miniconda3\envs\my_env\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running egg_info
writing my_package.egg-info\PKG-INFO
writing dependency_links to my_package.egg-info\dependency_links.txt
writing entry points to my_package.egg-info\entry_points.txt
writing requirements to my_package.egg-info\requires.txt
writing top-level names to my_package.egg-info\top_level.txt
reading manifest file 'my_package.egg-info\SOURCES.txt'
writing manifest file 'my_package.egg-info\SOURCES.txt'
running build_ext
Creating c:\programdata\miniconda3\envs\my_env\lib\site-packages\my_package.egg-link (link to .)
my_package 6.1.0 is already the active version in easy-install.pth
Installing entry_point0-script.py script to C:\ProgramData\Miniconda3\envs\my_env\Scripts
Installing entry_point0.exe script to C:\ProgramData\Miniconda3\envs\my_env\Scripts
Installing entry_point1-script.py script to C:\ProgramData\Miniconda3\envs\my_env\Scripts
Installing entry_point1.exe script to C:\ProgramData\Miniconda3\envs\my_env\Scripts
Installed c:\users\jpoppinga\my_git_repository
Processing dependencies for my_package==6.1.0
Searching for my_dep<13.1,>=13.0.1
Reading https://pypi.org/simple/my_dep/
C:\ProgramData\Miniconda3\envs\my_env\lib\site-packages\pkg_resources\__init__.py:123: PkgResourcesDeprecationWarning: is an invalid version and will not be supported in a future release
warnings.warn(
No local packages or working download links found for my_dep<13.1,>=13.0.1
error: Could not find suitable distribution for Requirement.parse('my_dep<13.1,>=13.0.1')
Every time I boot up terminal on VSCode, I get the following prompt. This does not happen on Terminal.app.
/usr/local/lib/python3.9/site-packages/setuptools/command/install.py:34:
SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip
and other standards-based tools.
How do I resolve this?
Install the setuptools 58.2.0 version using the following command
pip install setuptools==58.2.0
I assume you stumbled across this issue when you was building your .whl-file doing something like python Setup.py bdist_wheel --dist-dir .. (If not: This answer probably not applies to your problem.)
The warning you see wants to say that calling python Setup.py ... is obsolete now.
Solution, in short:
Replace setup.py with pyproject.toml. In pyproject.toml you enter all values from setup.py in an INI-file-like-structure. Then you create your .whl-file using the command python -m build.
Further information about python-packages and pyproject.toml: https://packaging.python.org/en/latest/tutorials/packaging-projects/
Further information about how to use pyproject.toml using setuptools:
https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html
Upgrade the setuptools. The versions greater than 58.2.0 is not showing the deprecation warning as of Oct 18, 2022.
pip install -U setuptools
Note, there are many ways to package Python. You will want to evaluate where your target deployment is. Working with the TOML files is a trend that allows better integration with many software languages. Reference: Overview of Packaging for Python
Install the setuptools 58.2.0 version using the following command
pip install setuptools==58.2.0
Don't upgrade the setuptools. Only the version 58.2.0 worked for me. Though I tried upgrading the version to 65.5.0 but it was showing the deprecation warning.
I was having same issue for my data science project. I got same error while running pip install -r requirements.txt. This Worked for me.
Calling setup.py directly is being deprecated, as explained here.
I did as the message told me and now build the wheel using pip (it still calls setup.py internally):
pip wheel --no-deps -w dist .
This replaced my old equivalent code:
python setup.py bdist_wheel
Note that the pip wheel command creates the wheel into your current directory by default, which is why I specify -w/--wheel_dir to match the old behavior of using the ./dist directory.
I also specify --no-deps so pip does not download the wheel files of all dependencies.
I'm following this guide to create a setup.py
Doing this I used install requires to specify sqlalchemy like so:
install_requires=['sqlalchemy']
Now when I run the setup.py install I get the message that there is no C extension is installed and the python alternative will be used. Which implicates that the sqlalchemy code is downloaded as dist and compiled instead of being downloaded as a wheel. If the packages is installed via pip there is no error/warning and the c version of sqlalchemy is installed using a precompiled wheel.
Why is this and how do i get around it?
I know that wheels are binary version of a module uploaded on PyPI.
with pip install
On Windows: I get wheels downloaded and installed.
On Ubuntu: I should get the source distribution of the package BUT in some cases I get wheels.
On fedora: Tricky I have to install with dnf
I tried to add wheels to my package as well. But I am only able to upload wheels for windows.
Why do some packages provide wheels for Linux platform?
Is this okay? Providing binaries instead of the source?
Why I cannot provide wheels?
Note: I know a bit about Fedora rpm packages. I am interested now in wheels on Ubuntu.
Why do some packages provide wheels for Linux platform?
Why shouldn't they, as long as source distributions are available as well? :)
Your question is not clear. If you meant
Why do some packages provide platform-specific wheels for Linux platform instead of platfom-independent ones?
then take a look at this question and its answers. If not, please clarify your question.
On Ubuntu: I should get the source distribution of the package BUT in some cases I get wheels.
Try using:
pip install --no-binary :all: somepackage
This should make pip download a source distribution if it exists on PyPI. I don't know why there are no source packages for PyQt5 on PyPI, probably because they are not installable with pip and need a whole toolchaing for compilation.
Is this okay? Providing binaries instead of the source?
It's okay as long as you provide both binaries and the source. I suggest you doing so.
Why I cannot provide wheels?
Try python setup.py bdist_wheel. You need to install wheel package (on PyPI) to make it work. If your package supports both Python 2 and 3 and contains no C extensions, append the --universal option to make a "universal wheel".
Replace bdist_wheel with sdist to make a source distribution. It will create an archive in dist directory.
sdist creates the archive of the default format for the current platform. The default format is a gzip’ed tar file (.tar.gz) on Unix, and ZIP file on Windows.
You can specify as many formats as you like using the --formats option, for example:
python setup.py sdist --formats=gztar,zip
to create a gzipped tarball and a zip file
(Quote from https://docs.python.org/3/distutils/sourcedist.html)
More info about packaging and wheels is available here: https://packaging.python.org/distributing/#packaging-your-project
I'm building a small app that uses PyQt and tought it'd be nice to declare that dependency in setup.py.
However, according to this blog (first hit on google for pyqt setuptools) says it can't be done, and the last paragraph here doens't try to do it either.
Ideas? Perhaps I should switch to PySide which is on PyPi?
Update:
The obvious install_requires = [ 'pyqt >= 0.7' ] in setup.py gives me:
D:\3rd\BuildBotIcon\my-buildboticon\python>setup.py test
running test
install_dir .
Checking .pth file support in .
C:\Python26-32\pythonw.exe -E -c pass
Searching for pyqt>=4.7
Reading http://pypi.python.org/simple/pyqt/
Reading http://www.riverbankcomputing.com/software/pyqt/
Reading http://www.riverbankcomputing.com/software/pyqt/download
No local packages or download links found for pyqt>=4.7
error: Could not find suitable distribution for Requirement.parse('pyqt>=4.7')
Right, the PyQT packages are not using distutils / setup.py for it's installation, so they can't be installed with easy_install or pip. You need to download and install it manually.
That also means you should not put it in your requires metadata, as easy_install and pip then will try to install it and fail.
I don't know if PySide is any good, but is also has not setup.py, and also refuse to install with easy_install/pip, so not a good option. :)
Another option is to repackage PyQt with distutils, but that may be a lot of work.
While you can pip install pyqt5 thanks to the now available wheels (as suggested by #mfitzp), it cannot be required from setup.py via install_requires. The reason is that setuptools doesn't know how to install wheels which pip knows how to, and PyQT5 is only available as wheels on PyPI (there is no source distribution, i.e. no tar.gz file). See this email and that bug report for details.
While the accepted answer was originally correct Python Wheels now provide a means to install C extension packages such as PyQt5 without the need for compilation from source.
PyPi currently has .whl files for PyQt5 on Python3 for multiple platforms, including MacOS X, Linux (any), Win32 and Win64. For example, this is the output when pip-installing PyQt5 on Python3 on a Mac:
mfitzp#MacBook-Air ~ $ pip3 install pyqt5
Collecting pyqt5
Downloading PyQt5-5.6-cp35-cp35m-macosx_10_6_intel.whl (73.2MB)
100% |████████████████████████████████| 73.2MB 2.5kB/s
Collecting sip (from pyqt5)
Downloading sip-4.18-cp35-cp35m-macosx_10_6_intel.whl (46kB)
100% |████████████████████████████████| 49kB 1.8MB/s
Installing collected packages: sip, pyqt5
Successfully installed pyqt5-5.6 sip-4.18
If you are targeting Python3+PyQt5 then you should have no problem specifying PyQt5 as a normal dependency in setup.py.
Setuptools >= 38.2.0 now knows how to install wheels. The trivial answer, therefore, is to install a recent version of setuptools and require that your enlightened userbase does so as well. To enforce usage of setuptools >= 38.2.0 at installation time, see this relevant answer elsewhere.
Since setuptools 38.2.0 was released over a year ago, all prior answers to this question are horrifyingly obsolete, blatantly wrong, and less than useful.