setup.py install_requires not installing sqlalchemy wheel - python

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?

Related

Creating a Python module with its dependencies self contained

When creating a Python module, you can specify dependencies of your module by using the install_requires List.
Lets look at this basic example.
setup(name='some_module',
version='0.0.1',
packages=find_packages(),
install_requires=[
'requests==2.21.0'
])
I package my module python3 setup.py sdist and upload it to a package repository.
But when I go to install pip3 install some_module==0.0.1 it will install requests==2.21.0 globally in my python3 site-packages/.
To my question, how do I get similar functionality to npm, with nested node_modules/ where my Python module would have its own site-packages/ and it would reference its local version of requests instead of overwriting my global version.
Thanks!
I would consider using PyInstaller for this task!
Directly from the Pyinstaller's documentation:
PyInstaller bundles a Python application and all its dependencies into a single package. The user can run the packaged app without installing a Python interpreter or any modules. PyInstaller supports Python 2.7 and Python 3.4+, and correctly bundles the major Python packages such as numpy, PyQt, Django, wxPython, and others.
You can install it with a simple pip install:
pip install PyInstaller
For a more detailed tutorial check out this link
Hopefully that helps!

in virtualenv, pip installing locally from source fails

I am trying to install a library in a virtualenv instance with pip. The library version I want (wxPython 3.0.2)
is not available on PyPi; it is only available for download from SourceForge. Thus, I have the source tarball downloaded on my machine and I am trying to install it in such a way that it will play nicely with virtualenv.
(I am on a Windows computer, running Python 2.7.)
I have tried the following:
doing a direct install: pip install wxPython-src-3.0.2.0.tar.bz2
extracting the files from the tarball to wxPython-src-3.0.2.0, then installing from the extracted directory: pip install wxPython-src-3.0.2.0
extracting the files from the tarball, then navigating into the extracted folder to the nested wxPython directory, which holds the setup.py file, and then installing from there: pip install wxPython
The last attempt seems the most promising, but I get the following traceback:
Processing \wxpython-src-3.0.2.0\wxpython
Complete output from command python setup.py egg_info:
Setuptools must be installed to build an egg
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\__MY_USERNAME__\appdata\local\temp\pip-req-build-q0pxlt\
This is also strange, because it suggests I don't have setuptools even though I can run pip list and see version 40.6.3 installed.
Any help appreciated.
Why not install a precompiled version? There are a lot of .exe files at SF. You probably need wxPython3.0-win64-3.0.2.0-py27.exe.
Also take a look at Christoph Gohlke's collection.
If you still insist on installing from sources please bear in mind that wxPython 3 is so old it predates pip. Forget about pip.
First, you need to install wxWidgets as wxPython is just a Python wrapper for wxWidgets C++ library. Extract wxPython-src-3.0.2.0.tar.bz2 and follow instructions in wxPython-src-3.0.2.0/docs/msw/install.txt.
After compiling and installing wxWidgets compile wxPython. See wxPython-src-3.0.2.0/wxPython/docs/BUILD.txt.
My eventual solution was the easy way out: installing my package (wxPython) locally as #phd suggested, and opting for local package access via either virtualenv --system-site-packages env or deleting the "no-global-site-packages.txt" file in an existing environment folder.
Not what I expected to do, but it works so no complaints.

rasa core installation existing package found

I am downloading rasa core and the NLU. But installing rasa core is presenting a frustrating error I do not understand.
pip install rasa_core
Results in an error
Installing collected packages: pyparsing, kiwisolver, matplotlib, rasa-nlu, graphviz, redis, fakeredis, decorator, networkx, fbmessenger, click, itsdangerous, flask, jsonpickle, h5py, Keras, tzlocal, apscheduler, websocket-client, slackclient, python-telegram-bot, ply, pandoc, packaging, snowballstemmer, alabaster, sphinxcontrib-websupport, babel, imagesize, sphinx, nbsphinx, monotonic, humanfriendly, coloredlogs, docopt, pykwalify, ConfigArgParse, ruamel.ordereddict, ruamel.yaml, rasa-core
Found existing installation: pyparsing 1.5.6
Cannot uninstall 'pyparsing'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
I can not find any information on this error or a work around?
My python version is 2.7 but I don't think that would make a difference.
I also don't under stand why it would want to uninstall the package to then re install it (Upgrade?).
Either remove the package manually or overwrite it:
pip install pyparsing --ignore-installed
If you want to uninstall python package which is part of distutils, you can manually remove the folder from 'site-packages' folder. If it is Anaconda distribution, it will be in following folder. I suggest to cut the folder and paste it somewhere else for backup purpose.
C:\Users\<WindowsUser>\AppData\Local\Continuum\Anaconda3\Lib\site-packages
Following 2 items needs to be removed.
Folder [package version no.]
File - [package>.egg-info]

How to pip install package without building its' C extensions?

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.

Creating a python package with dependency

I created a python package with a dependency that fails to install using pip due to some missing wheels and non pure-pythonic code (needs a Microsoft Visuals Compiler). Other dependencies are installed normally using pip.
the problematic dependency (geopandas->pyproj) is only used in part of my package so I was wondering if I could allow the user to install my package using pip with all functionality except the functions that require the dependency. If the user wants to use the functions in the package that requires the dependency one could simply install it in addition to my package allowing for more flexibility (make use of pip, conda, compile etc.):
pip install mypackage
conda install dependency
and then
import mypackage
import dependency
bar = mypackage.function_that_requires_dependency(foo)
If the user cannot install the dependency, it can still use all parts of my package that do not rely on it.
pip install mypackage
and then
import mypackage
bar = mypackage.function_that_does_not_require_dependency(foo)
Is there a way to accomplish this? I currently have all my imports at the beginning of my init.py file.
package github
package PyPi

Categories

Resources