> On 4 Mar 2022, at 13:03, Hartmut Goebel <h.goe...@goebel-consult.de> 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 <main>.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

Reply via email to