RedHatQE / pylero

Python wrapper for the Polarion WSDL API
https://redhatqe.github.io/pylero/
MIT License
37 stars 25 forks source link

Using modern pypi package build system interface #94

Closed waynesun09 closed 2 years ago

waynesun09 commented 2 years ago

The modern python packages use pyproject.toml as build interface. The file contains build system requirements and information, which are used by pip to build the package.

To build a pip package:

$ python -m build

Signed-off-by: Wayne Sun gsun@redhat.com

leelavg commented 2 years ago

Before merge, is scm also part of stdlib?

waynesun09 commented 2 years ago

Before merge, is scm also part of stdlib?

no, both setuptools and setuptools_scm are not part of the stdlib, both are pypi packages

leelavg commented 2 years ago

no, both setuptools and setuptools_scm are not part of the stdlib, both are pypi packages

  • ack, then we better add dev-requirements.txt for installing these?
  • only a thought, if that's not on priority we can merge the PR.
waynesun09 commented 2 years ago

So if user directly install the package from the repo with:

$ pip install . 
Processing /home/waynesun/workspace/pylero
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: suds in /home/waynesun/.local/share/virtualenvs/pylero-xZ4TB2uX/lib/python3.10/site-packages (from pylero==0.0.3) (1.1.2)
Requirement already satisfied: click in /home/waynesun/.local/share/virtualenvs/pylero-xZ4TB2uX/lib/python3.10/site-packages (from pylero==0.0.3) (8.1.3)
Building wheels for collected packages: pylero
  Building wheel for pylero (pyproject.toml) ... done
  Created wheel for pylero: filename=pylero-0.0.3-py3-none-any.whl size=97934 sha256=e754fece93f10cdd85635ddcd1973a7505036da2daac22d580e007c97a5f9db1
  Stored in directory: /tmp/pip-ephem-wheel-cache-u_33beds/wheels/2e/f6/50/111cf77eb1ef990291b666159cf8fa502c24e64361dce12587
Successfully built pylero
Installing collected packages: pylero
Successfully installed pylero-0.0.3

As the pyproject.toml exist, it will use the mordern build interface create venv to build the package. Inside the file under build setuptool and setuptool_scm are specified as dependency, so they will be installed in the venv to build the package.

Also works when build a pypi package:

$ python -m build
* Creating virtualenv isolated environment...
* Installing packages in isolated environment... (setuptools>=45, setuptools_scm, wheel)
......
Successfully built pylero-0.0.3.tar.gz and pylero-0.0.3-py3-none-any.whl

So no need for a dev-requirements.txt file, the modern rpm packaging spec now package the python package from the pypi package (basically build pypi first then copy files) rather then the old bdist rpm format (distutils is deprecated and will be removed in python 12, tracked in https://github.com/RedHatQE/pylero/issues/72). In the current repo if we run:

$ python setup.py bdist_rpm

it will fail..., currently I'm using:

$ spectool -gR pylero.spec
$ rpmbuild -ba pylero.spec

for local rpmbuild which require python-setuptool rpm to be installed on the host.

I have removed the rpm build part in the doc, as after get into Fedora we might not need build from local here. Just created https://github.com/RedHatQE/pylero/issues/96 for the python cmd rpmbuild.

So I will merge this now, if other scenario which I don't cover require the dev-requirements file please raise a new PR.

Thanks