Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use python3's venv module instead of virtualenv #1396

Merged
merged 3 commits into from
Dec 24, 2022

Conversation

dongcarl
Copy link
Contributor

@dongcarl dongcarl commented Nov 4, 2022

Python 3.3 and above provide a standard venv module which provides all the functionality that install.sh needs from virtualenv.

Detect its existence and use it, fallback to virtualenv if not.

@PulpCattel
Copy link
Member

I've always used python3 -m venv myself when installing manually.

Could we replace virtualenv entirely? Are there any advantages to keep it?

@AdamISZ AdamISZ added dependencies Pull requests that update a dependency file Installation labels Nov 4, 2022
@dongcarl
Copy link
Contributor Author

dongcarl commented Nov 4, 2022

Would be happy to expand on this patch to remove it entirely, I don't see any major distros using Python < 3.3: https://repology.org/project/python/versions

@kristapsk
Copy link
Member

I don't see any major distros using Python < 3.3

That wouldn't be important at all, as JM itself requires Python 3.6+.

@dongcarl dongcarl changed the title install: Use python3's venv module when available Use python3's venv module instead of virtualenv Nov 4, 2022
@dongcarl
Copy link
Contributor Author

dongcarl commented Nov 4, 2022

That wouldn't be important at all, as JM itself requires Python 3.6+.

Great, updated to just remove virtualenv and replace all mentions of "virtualenv" with "virtual environment" to avoid confusion.

install.sh Outdated Show resolved Hide resolved
@kristapsk
Copy link
Member

Seems to be working for me. Tested both with default install.sh settings and also switching to non-default Python version (install.sh -p python3.8).

@dongcarl
Copy link
Contributor Author

dongcarl commented Nov 5, 2022

Let me know if anything else needs to be done

@AdamISZ
Copy link
Member

AdamISZ commented Nov 5, 2022

@dongcarl thanks for the extra pair of eyes on our installation :) Looks like a good change.

conceptACK based on a quick read up on venv which I was dumb enough not to even know about before. Our usage as can be seen is very vanilla so if there is some obscure functionality of virtualenv which the former doesn't have, it doesn't matter. And the removal of an extra dependency is of course great.

review: ACK based on file search/grep; I believe this covers all references to virtualenv. And the changes to the install.sh script appear correct. I won't comment on the Dockerfiles though they look correct to me, as I never used them.

partial tACK f960ee1 on Ubuntu 20.04 , specifically testing install and script running. The usual pain point here that apart from Debian and Ubuntu I can't really test anything else, but I guess this should be OK.

@kristapsk feel free to merge whenever you think is reasonable.

Btw @dongcarl do you have any thoughts or knowledge about the possibility of building an AppImage for our Qt app here? (obviously not directly related to the PR but thought I'd throw it out there).

@kristapsk
Copy link
Member

The usual pain point here that apart from Debian and Ubuntu I can't really test anything else, but I guess this should be OK.

I tested on Gentoo.

@PulpCattel
Copy link
Member

I didn't have time to test this yet, but I remember in the past having to install the python3-venv package on Debian and Ubuntu.
The error message was the same as in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=816740
In particular:

$ python3 -m venv venv
The virtual environment was not created successfully because ensurepip
is not
available.  On Debian/Ubuntu systems, you need to install the python3-
venv
package using the following command.

I don't know if it's still a thing, but it might be prudent to add python3-venv to the dependencies?

@PulpCattel
Copy link
Member

I can reproduce the above on a clean Debian Bullseye. After installing python3-venv, everything else worked for me too.

Python 3.3 and above provide a standard venv module which provides all
the functionality that install.sh needs from virtualenv.

As of this commit, JM itself requires Python 3.6+ anyway.
@dongcarl
Copy link
Contributor Author

dongcarl commented Nov 7, 2022

Thanks @PulpCattel! Didn't know that was the case for Debian/Ubuntu. Fixed now.


@AdamISZ

Btw @dongcarl do you have any thoughts or knowledge about the possibility of building an AppImage for our Qt app here? (obviously not directly related to the PR but thought I'd throw it out there).

Unfortunately not, I don't have any experience with AppImage :-/

@kristapsk
Copy link
Member

Can somebody test this on macOS?

@PulpCattel
Copy link
Member

11ddec7 fixes the Debian issue mentioned above. Tested successful installation and basic JM scripts.

@AdamISZ
Copy link
Member

AdamISZ commented Dec 17, 2022

Proposal: merge this and see if a Mac user complains? And if they do they can stay on the 0.9.8 for now (it's not as if we're planning actual functionality changes, for the next release).

Our inability to do testing on Mac has hurt us quite a bit. Have heard user reports recently about not being able to install on Mac, but as usual, we are not getting anyone helping us out in this area. It's probably hurting the project a fair bit.

Personally while I have messed around with Mac VMs in the past, I have no intention of doing so now, so I will not be giving input on it.

In the extreme we could just say that this software is unsupported on Mac, if we still cannot get anyone to test and report on it. But I don't want to do that because I know how many software devs use it as their main environment.

@kristapsk
Copy link
Member

Our inability to do testing on Mac has hurt us quite a bit. Have heard user reports recently about not being able to install on Mac, but as usual, we are not getting anyone helping us out in this area. It's probably hurting the project a fair bit.

We could try adding macos-latest in addition to ubuntu-latest in CI. I've done this recently for my bitcoin-scripts project. kristapsk/bitcoin-scripts@2eedf0a. But there were discussions about compute cost in #1218.

My brother has a MacBook, will try to get my hands on it.

@AdamISZ
Copy link
Member

AdamISZ commented Dec 18, 2022

Our inability to do testing on Mac has hurt us quite a bit. Have heard user reports recently about not being able to install on Mac, but as usual, we are not getting anyone helping us out in this area. It's probably hurting the project a fair bit.

We could try adding macos-latest in addition to ubuntu-latest in CI. I've done this recently for my bitcoin-scripts project. kristapsk/bitcoin-scripts@2eedf0a. But there were discussions about compute cost in #1218.

My brother has a MacBook, will try to get my hands on it.

Thanks. Additionally, though, do you agree with my proposal?

@kristapsk
Copy link
Member

It looks I will not be able to test on mac this year, probably not worth waiting for so long, agree we can merge this.

About being unsupported officially on mac - as I said above, we could add macos-latest to the CI.

@kristapsk
Copy link
Member

Merging. And will open a new PR that adds macOS testing to CI. Wanted to add macOS testing on top of current master, but had errors because of not having virtualenv installed and getting rid of it simplifies macOS install.

@kristapsk kristapsk merged commit 71c0a84 into JoinMarket-Org:master Dec 24, 2022
@theborakompanioni
Copy link
Contributor

Just fyi, this broke the Jam dev environment where JM is installed inside docker (base image debian:bullseye-20220801-slim) with --docker-install.
See also: joinmarket-webui/jam#581

Step 8/27 : RUN ./install.sh --docker-install --with-local-tor --without-qt
 ---> Running in f665e77112db
./install.sh: line 10: python: command not found
  Installed: (none)
TERM environment variable not set.
Reading package lists...
Building dependency tree...
Reading state information...
Package python3-venv is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'python3-venv' has no installation candidate
Dependecies could not be installed. Exiting.
The command '/bin/sh -c ./install.sh --docker-install --with-local-tor --without-qt' returned a non-zero code: 1

Installing python3-venv manually seems to fix the problem. However, it should not be needed, right?

@kristapsk
Copy link
Member

Yes, this should not break install.sh --docker-install, we should fix install.sh.

@kristapsk
Copy link
Member

@theborakompanioni Could you check wasn't #1414 instead that broke Jam dev environment setup?

@theborakompanioni
Copy link
Contributor

@theborakompanioni Could you check wasn't #1414 instead that broke Jam dev environment setup?

Did not test yet, but I can tell you that it did work, once I installed python3-venv explicitly. See changes in joinmarket-webui/jam#585.

@AdamISZ
Copy link
Member

AdamISZ commented Jan 3, 2023

@theborakompanioni I'm curious that the error you have is:

./install.sh: line 10: python: command not found

Maybe I just don't understand the environment it's being run in, but why would that happen? And how would manually installing python3-venv fix it? The set of symptoms seems weird, especially considering we have https://github.com/JoinMarket-Org/joinmarket-clientserver/blob/master/install.sh#L70 also; why would manual be different?

@theborakompanioni
Copy link
Contributor

theborakompanioni commented Jan 3, 2023

@theborakompanioni I'm curious that the error you have is:

./install.sh: line 10: python: command not found

Maybe I just don't understand the environment it's being run in, but why would that happen? And how would manually installing python3-venv fix it? The set of symptoms seems weird, especially considering we have https://github.com/JoinMarket-Org/joinmarket-clientserver/blob/master/install.sh#L70 also; why would manual be different?

Was surprising for me as well that this really fixed the build. Did not investigate more, as it was working again. Just wanted to let you know.

This is the Dockerfile: https://github.com/joinmarket-webui/jam/blob/aa2b237e5208d867fd5c108da7a0a89d92d15b38/docker/regtest/dockerfile-deps/joinmarket/latest/Dockerfile (Note: it is for a local testing environment only). The file did not change lately and only a bug report of another user made me rebuild the images, thereby reproducing the error.
Running Docker version 20.10.21, build baeda1f.

Edit: Note that ./install.sh: line 10: python: command not found is not fixed with this. But it does not terminate the whole build.

@kristapsk
Copy link
Member

Edit: Note that ./install.sh: line 10: python: command not found is not fixed with this. But it does not terminate the whole build.

I modified Dockerfile to run bash -x ./install.sh --docker-install --with-local-tor --disable-secp-check --without-qt, that line actually doesn't terminate script, just gives error. It means there is no python available at the run of install.sh, dep_deps_install, which installs Python is called later. Real problem is E: Package 'python3-venv' has no installation candidate.

Step 8/27 : RUN bash -x ./install.sh --docker-install --with-local-tor --disable-secp-check --without-qt
 ---> Running in b7b6450818f0
++ dirname ./install.sh
+ cd .
+ check_exists gmake
+ command -v gmake
+ make=gmake
+ main --docker-install --with-local-tor --disable-secp-check --without-qt
+ python=python3
+ build_local_tor=
+ no_gpg_validation=
+ use_os_deps_check=1
+ use_secp_check=1
+ with_qt=
+ with_jmvenv=1
+ with_sudo=1
+ reinstall=false
+ parse_flags --docker-install --with-local-tor --disable-secp-check --without-qt
+ :
+ case $1 in
+ with_sudo=0
+ with_jmvenv=0
+ shift
+ :
+ case $1 in
+ build_local_tor=1
+ shift
+ :
+ case $1 in
+ use_secp_check=0
+ shift
+ :
+ case $1 in
+ with_qt=0
+ shift
+ :
+ case $1 in
+ break
+ [[ 0 == '' ]]
+ jm_source=/src
+ '[' 0 == 1 ']'
+ jm_root=
+ export PKG_CONFIG_PATH=/lib/pkgconfig:
+ PKG_CONFIG_PATH=/lib/pkgconfig:
+ export LD_LIBRARY_PATH=/lib:
+ LD_LIBRARY_PATH=/lib:
+ export C_INCLUDE_PATH=/include:
+ C_INCLUDE_PATH=/include:
++ num_cores
++ python -c 'import multiprocessing as mp; print(mp.cpu_count())'
./install.sh: line 10: python: command not found
+ MAKEFLAGS='-j '
++ install_get_os
++ os_is_deb
++ echo debian
+ install_os=debian
+ deps_install
+ debian_deps=('curl' 'build-essential' 'automake' 'pkg-config' 'libtool' 'python3-dev' 'python3-pip' 'python3-setuptools' 'python3-venv' 'libltdl-dev')
+ '[' 0 == 1 ']'
+ darwin_deps=('automake' 'libtool')
+ is_python3
+ [[ python3 == python3* ]]
+ return 0
+ [[ 1 != \1 ]]
+ [[ debian == \d\e\b\i\a\n ]]
+ deb_deps_install curl build-essential automake pkg-config libtool python3-dev python3-pip python3-setuptools python3-venv libltdl-dev
+ deb_deps=("${@}")
+ deb_deps_check
+ apt-cache policy curl build-essential automake pkg-config libtool python3-dev python3-pip python3-setuptools python3-venv libltdl-dev
+ grep 'Installed.*none'
  Installed: (none)
+ clear
TERM environment variable not set.
+ sudo_command=
+ '[' 0 == 1 ']'
+ apt-get install -y --no-install-recommends curl build-essential automake pkg-config libtool python3-dev python3-pip python3-setuptools python3-venv libltdl-dev
Reading package lists...
Building dependency tree...
Reading state information...
Package python3-venv is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'python3-venv' has no installation candidate
+ return 1
+ return 1
+ echo 'Dependecies could not be installed. Exiting.'
Dependecies could not be installed. Exiting.
+ return 1
The command '/bin/sh -c bash -x ./install.sh --docker-install --with-local-tor --disable-secp-check --without-qt' returned a non-zero code: 1

@kristapsk
Copy link
Member

What I don't understand is why Python is not available when https://github.com/joinmarket-webui/jam/blob/0a7b709d597469951aa670b9f2008e2435c4e782/docker/regtest/dockerfile-deps/joinmarket/latest/Dockerfile runs apt-get install with python3-dev in list before running JM install.sh. Some Docker or Debian magic I don't get.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file Installation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants