Installing a Tar.Gz on Linux

How to install Python packages from the tar.gz file without using pip install

Thanks to the answers below combined I've got it working.

  • First needed to unpack the tar.gz file into a folder.
  • Then before running python setup.py install had to point cmd towards the correct folder. I did this by pushd C:\Users\absolutefilepathtotarunpackedfolder
  • Then run python setup.py install

Thanks Tales Padua & Hugo Honorem

Installing downloaded tar.gz files with pip

You can install tar.gz with pip Install a particular source archive file.

pip install ./Package-1.0.4.tar.gz

You can also install it with extracting tar.gz file. First you should extract it using using tar command.

tar -xzvf PyGUI-2.5.4.tar.gz
cd PyGUI-2.5.4.tar.gz

And then use the setup.py file to install the package .

python setup.py install

or

sudo python setup.py install

( use sudo only in linux )

Source: https://pip.readthedocs.io/en/stable/reference/pip_install/#git

How to install tar.gz package to Yocto by adding new layer?

First, before answering your questions

Let me mention some best practices advice for you:

Rename the recipe to some significant name related to you compressed package.

Naming the recipe to mylayer confuses Yocto users, because there is the term layer also.

Regarding you recipe:

There is no need for FILESEXTRAPATHS because the recipe path is added automatically to Yocto paths.

FILESEXTRAPATHS it is required for .bbappend files.

You need to override the do_install task function, it does nothing by default.

do_install is the first essential task to make sure that your sources are included in the final image.

Beside that, when specifying a compressed source file into SRC_URI, yocto automatically decompresses it.

This is mentioned here.

So, here what your recipe should look like:

SUMMARY = ""
LICENSE = "CLOSED"

# Prevent Yocto from decompressing the file
SRC_URI = "file://mypackage.tar;unpack=0"

do_install(){
# Create the opt folder into the final image, ${D} is ${WORKDIR}/image
install -d ${D}/opt
# Copy the compressed file there; You can change permissions as you want
install -m 0755 ${WORKDIR}/mypackage.tar ${D}/opt
}

# Very important to specify what you installed in (do_install)
FILES_${PN} = "/opt/*"

Now, when you run IMAGE_INSTALL_append += " mylayer" your file will be installed.

Regarding your questions:

  1. You mentioned that your compressed file contains .deb files, I assume that no license checksum is needed. Also, I understand that you may wanted to point to SRC_URI[md5sum] or other checksums for the full package. That is also not needed for local files, it is used to check for the integrity of online sources.

  2. PACKAGE_CLASSES as mentioned here, is used by the system to know in what type the data should be packaged. By the data I mean the data that you installed with do_install. That data get packaged for according to your PACKAGE_CLASSES variable, for example, to deb file. And that is used, along side with all other recipes packages, to build the final rootfs.

  3. Yes, if you are installing the tar file into the image and then unpack it to install all deb files, for example, with dpkg. You can use the bin_package class to do that, now the recipe must be changed for that reason:

  • Decompress the tar file and provide the deb files in the local files folder.

  • Add all deb files to SRC_URI

  • Inherit the bin_package class

  • Specify the files to be packaged.

Your recipe should look like this:

SUMMARY = ""
LICENSE = "CLOSED"

SRC_URI = "file://deb_file1.deb \
file://deb_file2.deb"

# No need to `do_install` , it is invoked by the (bin_package) class

FILES_${PN} = ""

Important:

About FILES_${PN}, you need to add all what the deb installed into the image folder

Example, if your deb file installs this:

/usr/bin/hello
/etc/hello.cfg

Specify them:

FILES_${PN} = "/usr/bin/*"
FILES_${PN} += "/etc/*"

Use * so if other deb files install files into the same folder as others it will include all.

Installable Python tar.gz package depends on OS used to build tarball

There are various dialects / flavors of tar that are largely similar. In this case we're looking at GNU tools commonly used on Linux systems and BSD tools used on BSD (-> Darwin -> MacOS X).

If you want run BSD tar on Linux try bsdtar and if you want to use GNU tar on BSD (but also some other U*X systems), try gtar.

This also translate into other consumers of tarballs and it seems to be what trips pip which apparently expects GNU version (gtar) flavored inputs.

How to install Tomcat8 tar.gz on Linux?

Done:

sudo tar xvzf /opt/file_path/apache-tomcat-7.0.54.tar.gz -C /opt/extracted_folder_path --strip components=1--

It will extract tar file into extracted_folder_path.

Installing python pip package from tar.gz with extra includes

From the pip changelog:

7.0.0 (2015-05-21)

  • Allowing using extras when installing from a file path without requiring the use of an editable (PR #2785).

Some Linux distros bundle very old versions of pip when using the system packages for virtualenv or venv. Update pip after creating your env.

pip install -U pip
pip install package.tar.gz[name]

Installing modules to Anaconda from .tar.gz

There are several ways to achieve this, I'm describing one here, which should be relatively straight forward, even if your default python variable is not anaconda's.

  1. Check what is your desired anaconda environment (if you're not sure what does this mean, it probably means that you are using root, the default environment)
  2. Run: conda info --envs to see the path where your environment is installed
  3. Go to that path, and find the absolute path to python.exe, for example:
    "C:\Program Files\Anaconda3\python.exe"
  4. Now, run the following command:

<absolute path to python.exe> -m pip install <path to tar.gz>

for example:

C:\Program Files\Anaconda3\python.exe -m pip install c:\mymodule\great.tar.gz

Note that <path to tar.gz> can be relative, absolute and even an online link.



Related Topics



Leave a reply



Submit