How to build whl package for pandas? - python

Hi I have a built up Python 2.7 environment with Ubuntu 19.10.
I would like to build a whl package for pandas.
I pip installed the pandas but do not know how to pack it into whl package.
May I ask what I should do to pack it.
Thanks

You cannot pack back an installed wheel. Either you download a ready-made wheel with pip download or build from sources: python setup.py bdist_wheel (need to download the sources first).

Related

what does pip install actually do?

Super newb question here..
What does pip install actually do?
Assuming the pypi package is a tarball...
Does it just download the tar.gz, unpack it and run setup.py?
Does it add the downloaded package to the site_packages folder?
I want to create a pip installable pkg using pypiserver so my colleagues can download my pkg in a painless way, but am a little unsure exactly what to include beyond the actual .py scripts.
Any guidance would be appreciated
The tar.gz file is a source archive whereas the .whl file is a built
distribution. Newer pip versions preferentially install built
distributions, but will fall back to source archives if needed. You
should always upload a source archive and provide built archives for
the platforms your project is compatible with. In this case, our
example package is compatible with Python on any platform so only one
built distribution is needed.
See: https://packaging.python.org/tutorials/packaging-projects/
You would typically not manually create the source archive and wheel, but use setuptools and wheel to do so for you.
Nowadays, many packages are wheels. While installing these wheels using pip, pip will:
[...] unpack the archive in your current site packages directory and install any console scripts contained in the wheel.
See: https://wheel.readthedocs.io/en/stable/user_guide.html#installing-wheels

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.

Python Re-packaging an Existing Package for Distribution

I'm using Python 3.6.3 on Windows 7 Enterprise and when I tried to pip install the Python package "bitarray", the output indicated the need for Microsoft Visual C++ Build Tools. I downloaded and installed the build tools and installed bitarray with no problems.
Here's where the problem comes in: I now need to distribute bitarray to other employees within the company who don't have Microsoft Visual C++ Build Tools installed, but do have Python installed (and can use pip).
Can I just simply "re-package" the bitarray folder in "C:\Python363\Lib\site-packages\bitarray" (which contains the already compiled .pyd file) and just make it a local package? This way I can use pip with "file:///" to pull down a local copy of the package without the need for the build tools step?
Also, do I need to incorporate the information in the folder "C:\Python363\Lib\site-packages\bitarray-0.8.1.dist-info" to re-package?
Thanks in advance for any help!!!!
Scott
Instead of trying to work around the already installed package, why not building a distribution from source yourself? After all, you've already done the hardest part setting up the C compiler, the rest is just a sequence of commands you have to type. This is what you can do:
Clone bitarray's repository:
$ git clone https://github.com/ilanschnell/bitarray
Navigate into the cloned repository:
$ cd bitarray
Checkout the version tag you want to build (the latest one is 0.8.1):
$ git checkout 0.8.1
Ensure you have wheel installed to be able to build a static wheel:
$ pip install wheel
Build the static wheel:
$ python setup.py bdist_wheel
A new directory dist was created in the current one, check what's inside:
$ ls dist
bitarray-0.8.1-cp36-cp36m-macosx_10_6_intel.whl
(Note: This is what I would enter on my system, list the directory with dir on Windows, also your file should be either bitarray-0.8.1-cp36-cp36m-win_amd64.whl if you are building on a 64 bit system, or bitarray-0.8.1-cp36-cp36m-win32.whl on a 32 bit one).
Now you have built a static wheel that contains the C extensions compiled for Python 3.6 on Windows. It can be installed on Windows without needing to setup the C compiler on the target machine. Just enter
$ pip install bitarray-0.8.1-cp36-cp36m-win_amd64.whl
Note, however, that this wheel file can be installed only on Windows and only with Python 3.6. Should you need to provide a wheel for another setup (like Python 3.5 on Windows 32 bit), you would need to build another wheel file using the correct Python version on a correct target system, but the steps would be just the same.
Building without Git
If you don't have Git installed and you can't/don't want to install it, just download the zipped repository from Github, unzip it, navigate to the extracted directory and perform steps 4-6.

Python Wheels on linux (how? and why?)

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

Which scipy wheel to install for Windows 7?

I'm running 64 bit python 2.7 on Windows 7.
There are wheels for scipy at https://pypi.python.org/pypi/scipy
In the above link, which wheel is for scipy for 64-bit Windows?
Try installing through-
scipy-0.19.0.zip (md5, pgp)
extract the folder and run following command after setting the directories-
python setup.py install
(setup.py is contained in extracted folder)
If you not able to install it, try doing it through wheel-
http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy
Download scipy-0.19.0-cp27-cp27m-win_amd64.whl and place it in python folder.
Install scipy by-
pip install scipy-0.19.0-cp27-cp27m-win_amd64.whl
As it is mentioned here:
Windows does not have any package manager analogous to that in Linux, so installing one of the scientific Python distributions mentioned above is preferred. However, if that is not an option, Christoph Gohlke provides pre-built Windows installers for many Python packages, including all of the core SciPy stack, which work extremely well.
-- Source
Here is the link for windows installers(unofficial) for scipy. Also, check this link too.

Categories

Resources