Re: virtualenv and make DESTDIR=

2022-03-06 Thread Barry


> On 6 Mar 2022, at 16:53, Peter J. Holzer  wrote:
> 
> On 2022-03-05 17:59:48 +0100, Marco Sulla wrote:
>>> On Sat, 5 Mar 2022 at 17:36, Barry Scott  wrote:
>>> Note: you usually cannot use pip when building an RPM with mock as the 
>>> network is disabled inside the build for
>>> security reasons.
>> 
>> Can't he previously download the packages and run pip on the local packages?
> 
> That shouldn't be necessary. Any packages needed by that new package
> should be dependencies of that package, so they must also already exist
> as RPMs. The rpm build process will automatically install them if they
> aren't already.
> 
> (That may not be true for build dependencies, though.)

In the spec file use BuildRequires: to pull in an rpm package that is needed to 
do the build.
For example python3-setuptools.

Barry

> 
>hp
> 
> -- 
>   _  | Peter J. Holzer| Story must make more sense than reality.
> |_|_) ||
> | |   | h...@hjp.at |-- Charles Stross, "Creative writing
> __/   | http://www.hjp.at/ |   challenge!"
> -- 
> https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: virtualenv and make DESTDIR=

2022-03-06 Thread Peter J. Holzer
On 2022-03-05 17:59:48 +0100, Marco Sulla wrote:
> On Sat, 5 Mar 2022 at 17:36, Barry Scott  wrote:
> > Note: you usually cannot use pip when building an RPM with mock as the 
> > network is disabled inside the build for
> > security reasons.
> 
> Can't he previously download the packages and run pip on the local packages?

That shouldn't be necessary. Any packages needed by that new package
should be dependencies of that package, so they must also already exist
as RPMs. The rpm build process will automatically install them if they
aren't already.

(That may not be true for build dependencies, though.)

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: virtualenv and make DESTDIR=

2022-03-06 Thread Barry Scott



> On 5 Mar 2022, at 19:56, Hartmut Goebel  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 .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 


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 

Re: virtualenv and make DESTDIR=

2022-03-05 Thread Barry Scott


> On 5 Mar 2022, at 19:56, Hartmut Goebel  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 .py.
> The scripts are already created by entry-points. So basically this means to 
> reinvent the wheel. Or did I miss something?
> 

 For example I assume you need something like this:

#!/bin/bash
export PYTHONPATH=/opt//lib
exec /usr/bin/python3 /opt//lib/main.py "$@"

I'm assuming you put all the python code into /opt//lib
and any runnable command into /opt//bin

Barry

> -- 
> Schönen Gruß 
> Hartmut Goebel 
> Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer
> Information Security Management, Security Governance, Secure Software 
> Development
> Goebel Consult, Landshut 
> http://www.goebel-consult.de 
> Blog: 
> https://www.goe-con.de/blog/eilt-petition-auf-weact-gegen-vds-jetzt-unterschreiben
>  
> 
>  
> Kolumne: 
> https://www.goe-con.de/hartmut-goebel/cissp-gefluester/2011-11-in-troja-nichts-neues
>  
> 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: virtualenv and make DESTDIR=

2022-03-05 Thread Barry Scott


> On 5 Mar 2022, at 19:56, Hartmut Goebel  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 .py.
> The scripts are already created by entry-points. So basically this means to 
> reinvent the wheel. Or did I miss something?
> 
Are you saying that the only thing you want from the venv is a script that sets 
up PYTHONPATH?

That a trivia thing to write and far easier then battling with packaging a venv 
I'd expect.

Did I miss something?

Barry

> -- 
> Schönen Gruß 
> Hartmut Goebel 
> Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer
> Information Security Management, Security Governance, Secure Software 
> Development
> Goebel Consult, Landshut 
> http://www.goebel-consult.de 
> Blog: 
> https://www.goe-con.de/blog/eilt-petition-auf-weact-gegen-vds-jetzt-unterschreiben
>  
> 
>  
> Kolumne: 
> https://www.goe-con.de/hartmut-goebel/cissp-gefluester/2011-11-in-troja-nichts-neues
>  
> 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: virtualenv and make DESTDIR=

2022-03-05 Thread Hartmut Goebel

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 .py.


The scripts are already created by entry-points. So basically this means 
to reinvent the wheel. Or did I miss something?


--
Schönen Gruß
Hartmut Goebel
Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer
Information Security Management, Security Governance, Secure Software 
Development


Goebel Consult, Landshut
http://www.goebel-consult.de

Blog: 
https://www.goe-con.de/blog/eilt-petition-auf-weact-gegen-vds-jetzt-unterschreiben 

Kolumne: 
https://www.goe-con.de/hartmut-goebel/cissp-gefluester/2011-11-in-troja-nichts-neues 


--
https://mail.python.org/mailman/listinfo/python-list


Re: virtualenv and make DESTDIR=

2022-03-05 Thread Kirill Ratkin

Hi,

As far I know there is tool rpmvenv 
(https://github.com/kevinconway/rpmvenv).


Try it, maybe ot helps.

04.03.2022 16:03, Hartmut Goebel wrote:

Hi,

How can I make installing a virtual environment honor DESTDIR? How can 
I install a virtual environment in $(DESTDIR)$(PREFIX), which behaves 
as being set-up in $(PREFIX)? (Of course, this virtual environment can 
not be used. My aim is to ship it as part of a rpm package)


In Makefiles is good practice to honor DESTDIR in the "install" 
target, like this


install:
    install -t $(DESTDIR)$(PREFIX)/bin build/bin/my-tool

Now when running

    python3 -m venv $(DESTDIR)$(PREFIX)

all paths in this virtual environment refer to $(DESTDIR)$(PREFIX) 
instead of just $$(PREFIX)


Any ideas?


Background:

More about DESTDIR: 
https://www.gnu.org/prep/standards/html_node/DESTDIR.html


Following Redhat's commendations, I want to install my (somewhat 
complex) software into /opt/my-software. To make it easier for users 
to use the software, my idea was to setup a virtual environment in 
/opt/my-software. Thus users can easily use 
/opt/my-software/bin/python and have the library provided by 
my-software available. My Software also includes some scripts, which 
will also reside in /opt/my-software/bin and refer to 
/opt/my-software/bin/python. This will avoid to require users to set 
up PYTHONPATH when thy want to use MY Software.




--
https://mail.python.org/mailman/listinfo/python-list


Re: virtualenv and make DESTDIR=

2022-03-05 Thread Barry Scott



> On 5 Mar 2022, at 16:59, Marco Sulla  wrote:
> 
> On Sat, 5 Mar 2022 at 17:36, Barry Scott  wrote:
>> Note: you usually cannot use pip when building an RPM with mock as the 
>> network is disabled inside the build for
>> security reasons.
> 
> Can't he previously download the packages and run pip on the local packages?
> 

I guess that can work. In this case I would install with pip install --user and 
move the
files out of .local into an appropriate place in /opt/.

At work I package a lot of packages for python and what we do is get the 
sources, 
review them then turn them into an RPM using the setup.py to do the file 
placement.

We do not use the wheels from PyPI ever. They may not match the claimed sources.
Which I have seen a few times; the version on PyPI can contain helpful patches 
that
are not in the sources.

Barry


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: virtualenv and make DESTDIR=

2022-03-05 Thread Marco Sulla
On Sat, 5 Mar 2022 at 17:36, Barry Scott  wrote:
> Note: you usually cannot use pip when building an RPM with mock as the 
> network is disabled inside the build for
> security reasons.

Can't he previously download the packages and run pip on the local packages?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: virtualenv and make DESTDIR=

2022-03-05 Thread Barry Scott


> On 4 Mar 2022, at 13:03, Hartmut Goebel  wrote:
> 
> Hi,
> 
> How can I make installing a virtual environment honor DESTDIR? How can I 
> install a virtual environment in $(DESTDIR)$(PREFIX), which behaves as being 
> set-up in $(PREFIX)? (Of course, this virtual environment can not be used. My 
> aim is to ship it as part of a rpm package)
> 
> In Makefiles is good practice to honor DESTDIR in the "install" target, like 
> this
> 
> install:
> install -t $(DESTDIR)$(PREFIX)/bin build/bin/my-tool
> 
> Now when running
> 
> python3 -m venv $(DESTDIR)$(PREFIX)
> 
> all paths in this virtual environment refer to $(DESTDIR)$(PREFIX) instead of 
> just $$(PREFIX)
> 
> Any ideas?
> 
> 
> Background:
> 
> More about DESTDIR: https://www.gnu.org/prep/standards/html_node/DESTDIR.html
> 
> Following Redhat's commendations, I want to install my (somewhat complex) 
> software into /opt/my-software. To make it easier for users to use the 
> software, my idea was to setup a virtual environment in /opt/my-software. 
> Thus users can easily use /opt/my-software/bin/python and have the library 
> provided by my-software available. My Software also includes some scripts, 
> which will also reside in /opt/my-software/bin and refer to 
> /opt/my-software/bin/python. This will avoid to require users to set up 
> PYTHONPATH when thy want to use MY Software.

If you are packaging the code then I do not see the need to use a venv at all.

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 .py.

Note: you usually cannot use pip when building an RPM with mock as the network 
is disabled inside the build for
security reasons.

I package two of my projects this was for Fedora as RPMs.

Barry


> 
> 
> -- 
> Schönen Gruß
> Hartmut Goebel
> Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer
> Information Security Management, Security Governance, Secure Software 
> Development
> 
> Goebel Consult, Landshut
> http://www.goebel-consult.de
> 
> Blog: https://www.goe-con.de/blog/why-a-pki-is-barely-trustworthy
> Kolumne: 
> https://www.goe-con.de/hartmut-goebel/cissp-gefluester/2011-11-in-troja-nichts-neues
>  
> -- 
> https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


virtualenv and make DESTDIR=

2022-03-04 Thread Hartmut Goebel

Hi,

How can I make installing a virtual environment honor DESTDIR? How can I 
install a virtual environment in $(DESTDIR)$(PREFIX), which behaves as 
being set-up in $(PREFIX)? (Of course, this virtual environment can not 
be used. My aim is to ship it as part of a rpm package)


In Makefiles is good practice to honor DESTDIR in the "install" target, 
like this


install:
    install -t $(DESTDIR)$(PREFIX)/bin build/bin/my-tool

Now when running

    python3 -m venv $(DESTDIR)$(PREFIX)

all paths in this virtual environment refer to $(DESTDIR)$(PREFIX) 
instead of just $$(PREFIX)


Any ideas?


Background:

More about DESTDIR: 
https://www.gnu.org/prep/standards/html_node/DESTDIR.html


Following Redhat's commendations, I want to install my (somewhat 
complex) software into /opt/my-software. To make it easier for users to 
use the software, my idea was to setup a virtual environment in 
/opt/my-software. Thus users can easily use /opt/my-software/bin/python 
and have the library provided by my-software available. My Software also 
includes some scripts, which will also reside in /opt/my-software/bin 
and refer to /opt/my-software/bin/python. This will avoid to require 
users to set up PYTHONPATH when thy want to use MY Software.



--
Schönen Gruß
Hartmut Goebel
Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer
Information Security Management, Security Governance, Secure Software 
Development


Goebel Consult, Landshut
http://www.goebel-consult.de

Blog: https://www.goe-con.de/blog/why-a-pki-is-barely-trustworthy
Kolumne: 
https://www.goe-con.de/hartmut-goebel/cissp-gefluester/2011-11-in-troja-nichts-neues 


--
https://mail.python.org/mailman/listinfo/python-list