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

Test installation and import also on local system #4

Merged
merged 4 commits into from
Feb 15, 2023
Merged

Test installation and import also on local system #4

merged 4 commits into from
Feb 15, 2023

Conversation

nforro
Copy link
Member

@nforro nforro commented Feb 13, 2023

Note that python3 -m build doesn't work with rootless podman, I can't figure out why ☹️

@nforro
Copy link
Member Author

nforro commented Feb 14, 2023

On openSUSE and Ubuntu pip tries to install to default system sitepackages dir, overwriting installed RPM bindings, and the installation fails. That's good, because it prevents breaking anything, I'm just wondering if there is a way to do it more cleanly.

@TomasTomecek
Copy link
Member

Note that python3 -m build doesn't work with rootless podman, I can't figure out why ☹️

Worked for me fine:

diff --git a/Makefile b/Makefile
index 1f38712..3e707ac 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 TEST_IMAGE = rpm-shim-tests
-BASE_IMAGE ?=
-INSTALL_DEPS_CMD ?=
+BASE_IMAGE ?= fedora:38
+INSTALL_DEPS_CMD ?= dnf install -y python3-pip git-core
 
 CONTAINER_ENGINE ?= $(shell command -v podman 2> /dev/null || echo docker)

test run:

* Creating virtualenv isolated environment...
* Installing packages in isolated environment... (setuptools>=45, setuptools_scm[toml], setuptools_scm_git_archive)           
* Getting build dependencies for wheel...              
running egg_info             
writing rpm.egg-info/PKG-INFO                             
writing dependency_links to rpm.egg-info/dependency_links.txt
writing requirements to rpm.egg-info/requires.txt         
writing top-level names to rpm.egg-info/top_level.txt                                                                         
adding license file 'LICENSE'
writing manifest file 'rpm.egg-info/SOURCES.txt'             
* Installing packages in isolated environment... (wheel)
* Building wheel...                                                                                                           
running bdist_wheel                                                                                                           
running build                                                                                                                                                                                                                                                
running build_py
copying rpm/__init__.py -> build/lib/rpm
running egg_info
writing rpm.egg-info/PKG-INFO
writing dependency_links to rpm.egg-info/dependency_links.txt
writing requirements to rpm.egg-info/requires.txt
writing top-level names to rpm.egg-info/top_level.txt
adding license file 'LICENSE'
writing manifest file 'rpm.egg-info/SOURCES.txt'
installing to build/bdist.linux-x86_64/wheel
running install
running install_lib
creating build/bdist.linux-x86_64/wheel
creating build/bdist.linux-x86_64/wheel/rpm
copying build/lib/rpm/__init__.py -> build/bdist.linux-x86_64/wheel/rpm
running install_egg_info
Copying rpm.egg-info to build/bdist.linux-x86_64/wheel/rpm-0.0.post13+g3e79092.d20230214-py3.11.egg-info
running install_scripts
creating build/bdist.linux-x86_64/wheel/rpm-0.0.post13+g3e79092.d20230214.dist-info/WHEEL
creating '/rpm-shim/dist/.tmp-y21xfmzy/rpm-0.0.post13+g3e79092.d20230214-py3-none-any.whl' and adding 'build/bdist.linux-x86_64/wheel' to it
adding 'rpm/__init__.py'
adding 'rpm-0.0.post13+g3e79092.d20230214.dist-info/LICENSE'
adding 'rpm-0.0.post13+g3e79092.d20230214.dist-info/METADATA'
adding 'rpm-0.0.post13+g3e79092.d20230214.dist-info/WHEEL'
adding 'rpm-0.0.post13+g3e79092.d20230214.dist-info/top_level.txt'
adding 'rpm-0.0.post13+g3e79092.d20230214.dist-info/RECORD'
removing build/bdist.linux-x86_64/wheel
Successfully built rpm-0.0.post13+g3e79092.d20230214-py3-none-any.whl
Processing /rpm-shim/dist/rpm-0.0.post13+g3e79092.d20230214-py3-none-any.whl
Installing collected packages: rpm
Successfully installed rpm-0.0.post13+g3e79092.d20230214
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
DEBUG:rpm-shim:Collected sitepackages for /usr/bin/python3:
/usr/local/lib64/python3.11/site-packages
/usr/local/lib/python3.11/site-packages
/usr/lib64/python3.11/site-packages
/usr/lib/python3.11/site-packages
DEBUG:rpm-shim:Trying /usr/local/lib64/python3.11/site-packages 
DEBUG:rpm-shim:Trying /usr/local/lib/python3.11/site-packages
DEBUG:rpm-shim:Trying /usr/lib64/python3.11/site-packages
DEBUG:rpm-shim:Import successfull
No broken requirements found.

Copy link
Member

@TomasTomecek TomasTomecek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On openSUSE and Ubuntu pip tries to install to default system sitepackages dir, overwriting installed RPM bindings, and the installation fails. That's good, because it prevents breaking anything, I'm just wondering if there is a way to do it more cleanly.

Doesn't seem like worth bothering right now :)

@nforro
Copy link
Member Author

nforro commented Feb 14, 2023

Worked for me fine:

It still fails here with fedora:38 🤔

running install_egg_info
Copying rpm.egg-info to build/bdist.linux-x86_64/wheel/rpm-0.0.post13+g9bb3282-py3.11.egg-info
error: [Errno 13] Permission denied: 'build/bdist.linux-x86_64/wheel/rpm-0.0.post13+g9bb3282-py3.11.egg-info/PKG-INFO'

ERROR Backend subprocess exited when trying to invoke build_wheel
make: *** [Makefile:16: test] Error 1

@TomasTomecek
Copy link
Member

could the permision denied be selinux? are you mounting something inside? does simple touch build/foo-bar work?

skipsdist prevents installing the shim in tox >= 4, and usedevelop is
unnecessary and tox >= 4 emits warnings when it is enabled.

Signed-off-by: Nikola Forró <[email protected]>
@nforro
Copy link
Member Author

nforro commented Feb 14, 2023

could the permision denied be selinux? are you mounting something inside? does simple touch build/foo-bar work?

I'm not mounting anything (so I don't think selinux is involved in any way), touch works just fine.

@nforro
Copy link
Member Author

nforro commented Feb 14, 2023

I've moved test-related files to a subdirectory and added a sanity check so even if the shim fails to install on a local system we verify that rpm can be imported and used.

@nforro nforro requested a review from TomasTomecek February 14, 2023 19:41
Copy link
Member

@TomasTomecek TomasTomecek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works like a charm.

@nforro
Copy link
Member Author

nforro commented Feb 15, 2023

Thanks. Merging manually.

@nforro nforro merged commit e1fd0a9 into main Feb 15, 2023
@delete-merged-branch delete-merged-branch bot deleted the tests branch February 15, 2023 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants