Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

There is no royal road to geometry. -- Euclid


devel / comp.lang.python / Re: virtualenv and make DESTDIR=

SubjectAuthor
o Re: virtualenv and make DESTDIR=Barry Scott

1
Re: virtualenv and make DESTDIR=

<mailman.203.1646561986.2329.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17392&group=comp.lang.python#17392

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: bar...@barrys-emacs.org (Barry Scott)
Newsgroups: comp.lang.python
Subject: Re: virtualenv and make DESTDIR=
Date: Sun, 6 Mar 2022 10:19:41 +0000
Lines: 131
Message-ID: <mailman.203.1646561986.2329.python-list@python.org>
References: <05a5b570-d917-2b25-33ea-560fcbd76ce8@goebel-consult.de>
<F926CB1C-79DE-4833-A551-119B64B94675@barrys-emacs.org>
<7d513446-ca0e-cbc4-36dd-09007af51a83@goebel-consult.de>
<AAB60D27-58C8-434C-B290-4B58E56A970A@barrys-emacs.org>
Mime-Version: 1.0 (Mac OS X Mail 15.0 \(3693.60.0.1.1\))
Content-Type: text/plain;
charset=us-ascii
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de CxaV5jssYmoBoGK1Vveg6gqam0Km6sKeqkZyAxJv0bhQ==
Return-Path: <barry@barrys-emacs.org>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'url-ip:140.82/16': 0.03;
'pypi': 0.05; 'assumes': 0.07; 'exit': 0.07; 'mar': 0.07; 'cc:addr
:python-list': 0.09; 'dependencies': 0.09; 'from:addr:barry':
0.09; 'git': 0.09; 'received:217.70': 0.09; 'received:gandi.net':
0.09; 'received:mail.gandi.net': 0.09; 'schrieb': 0.09; 'skip:[
20': 0.09; 'steps': 0.11; 'url:github': 0.14; 'import': 0.15;
'url-ip:140/8': 0.15; '2022,': 0.16; 'barry': 0.16; 'cat': 0.16;
'command:': 0.16; 'defaults': 0.16; 'from:addr:barrys-emacs.org':
0.16; 'from:name:barry scott': 0.16; 'hartmut': 0.16; 'license:':
0.16; 'message-id:@barrys-emacs.org': 0.16; 'python3': 0.16;
'seconds.': 0.16; 'skip:> 20': 0.16; 'something.': 0.16;
'something?': 0.16; 'spec': 0.16; 'wrote:': 0.16; 'python': 0.16;
'installing': 0.19; 'cc:addr:python.org': 0.20; 'basically': 0.22;
'progress': 0.22; 'install': 0.23; 'code': 0.23; 'run': 0.23;
'skip:- 10': 0.25; 'cannot': 0.25; 'cc:2**0': 0.25; 'library':
0.26; 'port': 0.26; 'etc': 0.28; 'default': 0.31; 'script': 0.33;
'header:In-Reply-To:1': 0.34; 'fix': 0.36; 'built': 0.36;
'source': 0.36; 'name:': 0.37; 'means': 0.38; 'added': 0.39;
'use': 0.39; 'master': 0.39; 'file:': 0.40; 'skip:o 10': 0.61;
'miss': 0.62; 'skip:o 20': 0.63; 'skip:b 10': 0.63; 'service':
0.64; 'your': 0.64; 'skip:t 20': 0.66; 'received:217': 0.67;
'skip:/ 10': 0.69; 'skip:/ 30': 0.69; 'skip:/ 60': 0.69; 'within':
0.69; 'skip:f 30': 0.71; 'skip:f 20': 0.75; 'skip:% 30': 0.84;
'subject:make': 0.84; 'doing.': 0.91; 'number.': 0.91; 'turned':
0.95
In-Reply-To: <7d513446-ca0e-cbc4-36dd-09007af51a83@goebel-consult.de>
X-Mailer: Apple Mail (2.3693.60.0.1.1)
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <AAB60D27-58C8-434C-B290-4B58E56A970A@barrys-emacs.org>
X-Mailman-Original-References: <05a5b570-d917-2b25-33ea-560fcbd76ce8@goebel-consult.de>
<F926CB1C-79DE-4833-A551-119B64B94675@barrys-emacs.org>
<7d513446-ca0e-cbc4-36dd-09007af51a83@goebel-consult.de>
 by: Barry Scott - Sun, 6 Mar 2022 10:19 UTC

> On 5 Mar 2022, at 19:56, Hartmut Goebel <h.goebel@goebel-consult.de> wrote:
>
> Am 05.03.22 um 17:34 schrieb Barry Scott:
>> Have the RPM install all the pythone code and dependencies and also install a short script that
>> sets up PYTHONPATH, LD_LIBRARY_PATH, etc and execs the python3 <main>.py.
> The scripts are already created by entry-points. So basically this means to reinvent the wheel. Or did I miss something?
>
I see what are getting at - I did miss the something.
It is the setup.py that will create your entry point!

For my own understanding I turned one of my PyPI projects into an RPM.

The project source is on https://github.com/barry-scott/CLI-tools.git <https://github.com/barry-scott/CLI-tools.git>

First I turned the this into a tarball:

$ git archive --format=tar --prefix=cli-tools-3.1.0/ master >cli-tools-3.1.0.tar
$ gzip cli-tools-3.1.0.tar

Then I created a RPM spec file:

Summary: cli-tools example packaging for python
Name: cli-tools
Version: 3.1.0
Release: 1

BuildArch: noarch
Source: %{name}-%{version}.tar.gz
License: APL2.0
Prefix: /opt/barry-example

BuildRequires: python3
BuildRequires: python3-setuptools

Requires: python3

%description
cli-tools example packaging for python

%prep
# unpack Source tarball
%setup

%build
cd Source
python3 setup_ssh_wait.py build

%install
cd Source
python3 setup_ssh_wait.py install --prefix=%{prefix} --root=%{buildroot}

# need to add the site-packages folder to the sys.path as
# setup.py assumes it is installing into the systems python library
cat <<EOF
import sys
import os

site_packages = 'python%d.%d/site-packages' % (sys.version_info.major, sys.version_info.minor)
extra_python_path = os.path.join(sys.argv[2], site_packages)

with open(sys.argv[1]) as f:
script_lines = f.read().split('\n')

index = script_lines.index('import sys')
script_lines[index+1:index+1] = ['sys.path.insert(0, "%s")' % (extra_python_path,)]

with open(sys.argv[1]+'.new', 'w') as f:
f.write('\n'.join(script_lines))
EOF >fix_bin.py

python3 fix_bin.py %{buildroot}%{prefix}/bin/ssh-wait %{buildroot}%{prefix}/opt/barry-example/lib

%files
/opt/barry-example/*

%changelog

Then only thing I needed to fix up was that the entry point code needs to have the
lib folder in /opt/barry-example added to sys.path. That is what the fix_bin.py is
doing.

I then use rpmbuild to create the RPM.

$ rpmbuild -bb cli-tools.spec

To use mock the steps are:

$ rpmbuild -bs cli-tools.spec
$ mock --rebuild --root fedora-35-x86_64 .../SRPMS/cli-tools-3.1.0.arc.rpm

Then I install the built file:

$ dnf install /var/lib/mock/fedora-35-x86_64/result/cli-tools-3.1.0-1.noarch.rpm

And then I can run the command:

$ /opt/barry-example/bin/ssh-wait
Usage: ssh-wait <options> <host>

ssh-wait will wait for the service to be available
on <host>.

--verbose
- print progress messages
--nowait
- check one and exit 0 if can connect 1 if cannot
--wait-limit=<limit>
- exit 1 if service is not avaiable within <limit> seconds.
defaults to 600.
--service=<service>
- check the service <service>. Can be a service
name of a port number. Default is ssh.

Barry

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor