Conversation
|
Out of curiosity, when you say modernize, do you perhaps mean accepting the perhaps-unpleasant change in pip3 that prevents (or very strongly discourages) one from installing Python packages in system-wide directories? Perhaps considering using a Python virtual environment? |
Yes. We might have to go with the times here because the workarounds are quite aggressive/invasive. I am exploring using poetry + virtualenv. If I work the kinks out you should be able to set up the entire Python environment in few commands: sudo applications can be run using |
|
FYI, my install-p4dev-v8.sh script here: https://github.com/jafingerhut/p4-guide/blob/master/bin/install-p4dev-v8.sh can run as a normal user, with liberal I doubt that exactly what it does is what you need for this work, but just wanted to point it out as a working example of using a venv for all these tools together. I believe I also needed LD_LIBRARY_PATH=$LD_LIBRARY_PATH in addition to PATH=$PATH from some sudo commands, perhaps ones like Oh, and sometimes I found that instead of a command like |
Yes, I am aware of these and have recommended it to students I work with! But for the sake of the compiler installation we can stay be much simpler. Nonetheless, the changes here should definitely integrate with your scripts. I'll explore further. |
bca3a83 to
cefdc44
Compare
ac75baf to
eceef54
Compare
|
@jafingerhut Poetry works really well for managing Python dependencies. It was not difficult at all to set this up for all our distributions. All you need to do is call Poetry also exposes a bunch of small issues we had hidden in the environment. For example, we are relying on the external One thing: It looks Poetry is not supported well Ubuntu18.04. This might be a good opportunity to finally deprecate this version. |
eb1ef3d to
1c1268d
Compare
6f47c5f to
d75e137
Compare
257e094 to
99f3b3e
Compare
|
|
||
| sudo apt-get install -y python3-poetry python3-venv | ||
| poetry install | ||
| poetry shell |
There was a problem hiding this comment.
Is my understanding correct that uv is a poetry replacement, and if we use uv, there is no need to install poetry at all?
There was a problem hiding this comment.
Yeah, I am trying out uv as an alternative and it is pretty neat for dependency management so far.
f53547b to
29a9bd8
Compare
|
@vbnogueira Trying to refactor the Python setup for TC STF I am seeing timeouts. Do you know possible reasons for that? Could be a simple fix. |
I tested it out and I believe the VM is not getting started because the runner is not finding the |
Thanks, that already helps me. I can likely fix this. |
| @@ -0,0 +1 @@ | |||
| 3.12 | |||
There was a problem hiding this comment.
Is adding this .python-version intentional? What uses it?
There was a problem hiding this comment.
Yes, this picks the default Python version for this particular project. It's optional, I might remove it once I clean up these particular files.
I finally found a way to fix the P4-TC tests, by using virtme-ng provided by the Debian repositories. Let me know whether that works for you. |
|
@jafingerhut The transition to Ubuntu 24.04 is almost completed with this. #5183 is a prerequisite, I will clean up that PR later this afternoon and then it is ready for review. The Fedora failures are unrelated and happen because of the distro changes. |
I think I tried that, but it didn't work at the time (probably because the virtme-ng for the previous ubuntu version was too outdated). Glad to see it works now, makes things easier to setup. |
Signed-off-by: fruffy <fruffy@nyu.edu>
| export CC=gcc-9 | ||
| export CXX=g++-9 | ||
| else | ||
| elif [[ "${DISTRIB_RELEASE}" != "24.04" ]] ; then |
There was a problem hiding this comment.
Does this check for versions other than 24.04 mean that p4lang-bmv2 is not installed on Ubuntu 24.04 tests, and thus Ubuntu 24.40 CI does not run any tests that pass packets through bmv2?
If so, I guess the long term way to improve that is to create a way to build bmv2 binaries for p4c testing that run on Ubuntu 24.04?
There was a problem hiding this comment.
Yes there is no p4lang-bmv2 for Ubuntu 24.04. We could build BMv2 from scratch, but that adds CI time.
|
@jafingerhut This is ready for review now. |
This pull request adds a CI test for Ubuntu 24.04 and changes the way Python dependencies are installed. Part of the motivation is related to changes to PEP668 which mandates that, by default, Python dependencies should be externally managed, or local. This PEP takes effect with Ubuntu 24.04
To work around this, we introduce uv for dependency management. With uv, we can install and manage all Python dependency in a virtual environment local to the P4C repository. This also makes dependency management easier for us.
The downside is that we now have to run tests with a
uv runprefix to avoid Python dependency problems. Similarly, when using sudo we have to usesudo -E env PATH="$PATH" uv run.