Archive for the ‘Package’ tag
The – externally-managed-environment – in Python
To avoid this message which is to force you somehow to create a virtual environment in python:
$ pip install .
error: externally-managed-environment
× This environment is externally managed
??> To install Python packages system-wide, try 'pacman -S
python-xyz', where xyz is the package you are trying to
install.
If you wish to install a non-Arch-packaged Python package,
create a virtual environment using 'python -m venv path/to/venv'.
Then use path/to/venv/bin/python and path/to/venv/bin/pip.
If you wish to install a non-Arch packaged Python application,
it may be easiest to use 'pipx install xyz', which will manage a
virtual environment for you. Make sure you have python-pipx
installed via pacman.
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
Just remove this in Linux:
sudo rm /usr/lib/python3.11/EXTERNALLY-MANAGED
If you are using Homebrew just go to:
cd /home/linuxbrew/.linuxbrew/Cellar/python@3.12/3.12.2_1/lib/python3.12
and remove the file EXTERNALLY-MANAGED as well.
If on the other side, prefer to create a virtual environment, this is the way, install this package:
python3-venv
In the environment you prefer to work with, use this command:
python3 -m venv .venv
You can check all the installed packaged here:
user@server# ls .venv/
bin include lib lib64 pyvenv.cfg
Then you have to activate the environment:
source .venv/bin/activate
Then it’s possible to use pip to install packages in that environment:
pip install -r requirements.txt
pip install openai
That’s it.
To deactivate the environment:
deactivate
Streamline Package Distribution with AUR and Brew: Leveraging the Power of GitHub
It’s crucial to have a repository on GitHub for seamless development and collaboration. In the case of Arch Linux’s AUR, creating an account on aur.archlinux.org is essential. Additionally, generating and configuring an SSH key pair linked to the AUR account is crucial. Here’s how you can set it up:
Create the ~/.ssh/config
file with the following content:
Host aur.archlinux.org
IdentityFile ~/.ssh/aur
User aur
Generate the SSH keys:
ssh-keygen -f ~/.ssh/aur
ssh-keygen -b 4096 (RSA) This command will create a public key in the specified folder. Next, let's create the AUR repository (which is separate from the GitHub repository for our project):
git -c init.defaultbranch=master clone ssh://aur@aur.archlinux.org/pkgbase.git
You may receive a warning about cloning an empty repository, but don’t worry. Now, you can place the binaries, tarball, or any files related to the installation of the project inside this folder.
To proceed, add a remote label to your repository (Inside of it):
git remote add label ssh://aur@aur.archlinux.org/pkgbase.git
Replace pkgbase
with the name of the package you wish to publish on AUR.
Finally, follow these steps to complete the AUR package creation:
$ makepkg --printsrcinfo > .SRCINFO
$ git add PKGBUILD .SRCINFO
$ git commit -m "Updates"
$ git push origin master
Example of a PKGBUILD:
# Maintainer: Tu nombre <usuario@mail.ch>
pkgname=nombre-del-proyecto
pkgver=v.1.0.2
pkgrel=1
pkgdesc="Descripción de la aplicación o software"
arch=('x86_64')
url="https://github.com/usuario/proyecto"
license=('MIT')
depends=('gcc' 'vim' 'nano')
source=("https://github.com/usuario/repo-proyecto/archive/refs/tags/$pkgver.tar.gz")
build() {
cd "$srcdir/proyecto-$pkgver"
#make
./setup
}
package() {
cd "$srcdir/proyecto-$pkgver"
install -Dm755 term_notes "$pkgdir/usr/bin/proyecto"
}
sha256sums=('e1ae65286b64c3466d5749524c79df1063ec9db35b265f0359d24cc76397d88c')
Make sure to review the PKGBUILD file, ensuring it matches the provided template and contains the correct sha256sums
. You can generate the sha256sums
by running sha256sum -b * > SHA256SUMS
. Open the resulting SHA256SUMS
file with a text editor to verify the sha256sums for the tarball versions in the GitHub repository.
In Mac OS is:
shasum -a 256 src/file-project.c
Moving on to Brew:
Inside the root folder of your GitHub project, create a folder called Formula
. Within this folder, create a file named project.rb
, where project
represents the name of your project in Brew.
Here’s an example of a formula in Ruby:
class TermNotes < Formula
desc "Description of the application"
homepage "https://github.com/user/repoproject"
url "https://github.com/user/repoproject/archive/refs/tags/v.1.0.2.tar.gz"
sha256 "e1ae65286b64c3466d5346346345634634634563464536d24cc76397d88c"
license "MIT"
depends_on "gcc"
depends_on "vim"
depends_on "nano"
def install
if OS.mac?
bin.install "named-project" => "renamed-project"
else
bin.install "project"
end
end
def caveats
<<~EOS
'Term Notes' has been installed!
On macOS, you can run the program using 'term-notes'.
On Linux, you may need to create a symbolic link to make it accessible globally.
Run the following command:
sudo ln -s #{opt_bin}/project-name /usr/local/bin/renamed-project
Enjoy taking notes with 'Term Notes'!
EOS
end
test do
# Add your test logic here
end
end
To utilize the tap functionality, ensure you have Homebrew installed on your Mac or Linux system. Visit brew.sh for installation instructions. Once installed, use tap
as follows:
brew tap <username>/<repository> <full-github-url-repoproject>
To install the project using brew, run:
brew install name-project
Replace name-project
with the same name used for the file inside the Formula
folder in your GitHub project’s root directory.
Once your tap is installed, Homebrew will automatically update it whenever a user runs brew update
. Outdated formulas will be upgraded when a user runs brew upgrade
along with core formulas.
Remember to update the AUR repository by replacing the sha256sum and adjusting the tag’s version to reflect the changes in the GitHub repository inside the .rb
formula file in the Formula
folder.
For more information about maintaining a tap, refer to the official Homebrew documentation. To learn about the AUR submission guidelines and sha256sums, visit the Arch Linux wiki and this Super User post.