GithubHelp home page GithubHelp logo

wenliangcan / pip2pkgbuild Goto Github PK

View Code? Open in Web Editor NEW
50.0 7.0 11.0 92 KB

Generate PKGBUILD file for a Python module from PyPi

Home Page: https://pypi.org/project/pip2pkgbuild/

Python 100.00%
python arch-linux packaging pkgbuild

pip2pkgbuild's Introduction

PyPi Downloads

About

Re-implementing bluepeppers/pip2arch with some improvements:

  • Supports generating PKGBUILD contained multiple packages.
  • Smarter package license detection.
  • License file installation (by @brycepg).
  • Maintainer information generation (by @brycepg).
  • Supports generating PEP517 based installation instructments.

Installation

Install from AUR:

$ git clone https://aur.archlinux.org/pip2pkgbuild.git
$ # for Python 2:
$ # git clone https://aur.archlinux.org/python2-pip2pkgbuild.git pip2pkgbuild
$ cd pip2pkgbuild
$ makepkg -si

Install from PyPi:

$ pip install pip2pkgbuild

Install manually:

$ cp pip2pkgbuild/pip2pkgbuild.py ~/bin/pip2pkgbuild
$ chmod u+x ~/bin/pip2pkgbuild

Usage

 usage: pip2pkgbuild [-h] [-v MODULE_VERSION] [-p {python,python2,multi}]
                     [-b PKGBASE] [-n PKGNAME]
                     [--python2-package-name PY2_PKGNAME]
                     [-d [DEPENDS [DEPENDS ...]]]
                     [--python2-depends [DEPENDS [DEPENDS ...]]]
                     [--python3-depends [DEPENDS [DEPENDS ...]]]
                     [-m [MKDEPENDS [MKDEPENDS ...]]] [-o] [-V] [-l]
                     [--name NAME] [--email EMAIL]
                     module

 Generate PKGBUILD file for a Python module from PyPi

 positional arguments:
   module                The Python module name

 optional arguments:
   -h, --help            show this help message and exit
   -v MODULE_VERSION, --module-version MODULE_VERSION
                         Use the specified version of the Python module
   -p {python,python2,multi}, --python-version {python,python2,multi}
                         The Python version on which the PKGBUILD bases
   -b PKGBASE, --package-basename PKGBASE
                         Specifiy the pkgbase value, the first value in the
                         pkgname array is used by default
   -n PKGNAME, --package-name PKGNAME
                         Specify the pkgname value or the name for the Python 3
                         based package in a package group
   --python2-package-name PY2_PKGNAME
                         Specify the name for the Python 2 based package in a
                         package group
   -d [DEPENDS [DEPENDS ...]], --depends [DEPENDS [DEPENDS ...]]
                         Dependencies for the whole PKGBUILD
   --python2-depends [DEPENDS [DEPENDS ...]]
                         Dependencies for the Python 2 based package in a
                         package group
   --python3-depends [DEPENDS [DEPENDS ...]]
                         Dependencies for the Python 3 based package in a
                         package group
   -m [MKDEPENDS [MKDEPENDS ...]], --make-depends [MKDEPENDS [MKDEPENDS ...]]
                         Dependencies required while running the makepkg
                         command
   -o, --print-out       Print on screen rather than saving to PKGBUILD file
   -V, --version         show program's version number and exit
   -l, --find-license    Attempt to find package license to install
   --name NAME           Your full name for the package maintainer line e.g.
                         'yourFirstName yourLastName'
   --email EMAIL         Your email for the package maintainer line
   --pep517              Prefer PEP517 based installation method if supporting by the module

Examples

Generate a Python 2 based PKGBUILD for Django with pkgname "django":

$ pip2pkgbuild django -p python2 -n django

Generate PKGBUILD for Flask, containing both Python 2 and 3 packages with pkgbase "flask":

$ pip2pkgbuild flask -p multi -b flask

pip2pkgbuild's People

Contributors

brycepg avatar daavve avatar hseg avatar mvdnes avatar rffontenelle avatar wenliangcan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pip2pkgbuild's Issues

AttributeError: 'NoneType' object has no attribute 'lower'

Hi, thanks for the great tool, it saves a lot of time.

For two packages -- django-model-utils and django-secure -- however I'm encountering the following:

Traceback (most recent call last): File "/usr/bin/pip2pkgbuild", line 9, in <module> load_entry_point('pip2pkgbuild==0.1.4', 'console_scripts', 'pip2pkgbuild')() File "/usr/lib/python3.5/site-packages/pip2pkgbuild/pip2pkgbuild.py", line 343, in main module = fetch_pymodule(args.module, args.module_version) File "/usr/lib/python3.5/site-packages/pip2pkgbuild/pip2pkgbuild.py", line 291, in fetch_pymodule return PyModule(info) File "/usr/lib/python3.5/site-packages/pip2pkgbuild/pip2pkgbuild.py", line 106, in __init__ self.license = self._get_license(info) File "/usr/lib/python3.5/site-packages/pip2pkgbuild/pip2pkgbuild.py", line 124, in _get_license lambda recg: recg.lower() == info.get('license', '').lower()) File "/usr/lib/python3.5/site-packages/pip2pkgbuild/pip2pkgbuild.py", line 121, in find_recognized return search_in_iter(recognized_licenses(), p) File "/usr/lib/python3.5/site-packages/pip2pkgbuild/pip2pkgbuild.py", line 74, in search_in_iter if p(i): File "/usr/lib/python3.5/site-packages/pip2pkgbuild/pip2pkgbuild.py", line 124, in <lambda> lambda recg: recg.lower() == info.get('license', '').lower()) AttributeError: 'NoneType' object has no attribute 'lower'

README : AUR URL changed

git clone https://aur.archlinux.org/packages/pip2pkgbuild should be git clone https://aur.archlinux.org/pip2pkgbuild

Add support for poetry packages.

I attempted to use the tool to generate a PKGBUILD file for a Python package that uses poetry for managing its dependencies, but the installation process failed with the following error message:

python: can't open file '/tmp/makepkg/name/src/name-0.1.0/setup.py': [Errno 2] No such file or directory

I believe this error is occurring because poetry uses pyproject.toml instead of setup.py to manage package metadata and dependencies.

I would like to request the support for poetry packages. This would make the tool more versatile and useful for users who rely on poetry to manage dependencies for their Python packages.

Thank you for your attention to this matter, and please let me know if you require any further information from me.

Possible to use other source?

If possible, how does a person use a different source for the python package as demonstrated below?

pip2pkgbuild git+https://github.com/fabpot/sphinx-php.git
[ERROR] : Python module not found: git+https://github.com/fabpot/sphinx-php.git

Use SPDX licenses

After RFC16, /usr/share/licenses/common/ has been replaced with /usr/share/licenses/spdx/{,exceptions}.
Naturally, this gives rise to

FileNotFoundError: [Errno 2] No such file or directory: '/usr/share/licenses/common'

[bug] - should be _

pip2pkgbuild pre-commit-mirror-maker
makepkg -fsi

will get

==> Making package: python-pre-commit-mirror-maker 1.9.0-1 (Sat 11 Mar 2023 12:37:43 AM CST)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Downloading pre-commit-mirror-maker-1.9.0.tar.gz...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
curl: (22) The requested URL returned error: 404
==> ERROR: Failure while downloading https://files.pythonhosted.org/packages/source/p/pre-commit-mirror-maker/pre-commit-mirror-maker-1.9.0.tar.gz
    Aborting...

That is correct filename is https://files.pythonhosted.org/packages/source/p/pre-commit-mirror-maker/pre_commit_mirror_maker-1.9.0.tar.gz.

See https://aur.archlinux.org/packages/python-pre-commit-mirror-maker.

Install License when available

The archlinux wiki recommends installing the license if available via adding install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" to the package() functions.

This would require downloading an inspecting the compressed package itself to see whether a LICENSE file exists, if so add the command above.

Setuptools deprecating, using new python method for installing

New makedepends (replace python-setuptools):

makedepends=('python-pip' 'python-wheel' 'python-flit' 'python-installer')

The new method is:

build() {
    cd "${srcdir}/${_module}-${pkgver}"
    python -m build --wheel --no-isolation
}

package() {
    depends+=()
    cd "${srcdir}/${_module}-${pkgver}"
    python -m installer --destdir="$pkgdir" dist/*.whl
}

See this guideline:
https://wiki.archlinux.org/title/Python_package_guidelines#Installation_methods

Failed to install packages whose name includes underscore

Hi, I tried pip2pkgbuild open-interpreter && makepkg -si but failed with the following error:

==> Making package: python-open-interpreter 0.1.15-1 (Tue 21 Nov 2023 08:41:32 AM JST)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Downloading open_interpreter-0.1.15.tar.gz...
==> Validating source files with sha256sums...
    open_interpreter-0.1.15.tar.gz ... Passed
==> Extracting sources...
  -> Extracting open_interpreter-0.1.15.tar.gz with bsdtar
==> Starting build()...
/home/yuki/.local/src/github.com/acomagu/pkgbuilds/open-interpreter/PKGBUILD: line 16: cd: /home/yuki/.local/src/github.com/acomagu/pkgbuilds/open-interpreter/src/open-interpreter-0.1.15: No such file or directory
==> ERROR: A failure occurred in build().
    Aborting...

The generated PKGBUILD try to cd to src/open-interpreter-0.1.15, but the correct path seems to be src/open_interpreter-0.1.15.

I can fix it by rewriting PKGBUILD by hand, but I report. Thank you for awesome tool!

Use importlib instead of imp?

When setting up the package, the following warning is shown:

setup.py:1: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses

Use SHA256 instead of MD5

You should probably be using SHA256SUMS in the PKGBUILD instead of MD5SUMS. MD5 is not suitable for package signatures anymore.

Setup.py is supposedly deprecated

I used this to generate PKGBUILDs for two python modules, cs50 and submit50. However upon installing the packages, I get the below terminal output:

image

The package installations still seemed to complete anyway, but I thought maybe I should post this here just in case.

Make PEP517+python 3 the default

While it's all well and good to provide tooling for the usecases wanting python2 packages, most users are going to go for the default and not bother passing --pep517. Swapping these defaults would help here.

Can't create a PKGBUILD: module not found

I'm trying to create a PKGBUILD for my module from its directory; when I run

pip2pkgbuild yarsync
[ERROR] : Python module not found: yarsync

it gives that error. However, I installed the module on my system:

pip show yarsync

outputs its details.

https instead of http

I'm getting this when I try to run pip2pkgbuild today:

Traceback (most recent call last):
  File "/bin/pip2pkgbuild", line 11, in <module>
    load_entry_point('pip2pkgbuild==0.2.3', 'console_scripts', 'pip2pkgbuild')()
  File "/usr/lib/python3.6/site-packages/pip2pkgbuild/pip2pkgbuild.py", line 591, in main
    args.module, args.module_version, args.find_license)
  File "/usr/lib/python3.6/site-packages/pip2pkgbuild/pip2pkgbuild.py", line 525, in fetch_pymodule
    raise e
  File "/usr/lib/python3.6/site-packages/pip2pkgbuild/pip2pkgbuild.py", line 513, in fetch_pymodule
    info = fetch_json(url)
  File "/usr/lib/python3.6/site-packages/pip2pkgbuild/pip2pkgbuild.py", line 509, in fetch_json
    return json.loads(urlopen(url).read().decode('utf-8'))
  File "/usr/lib/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.6/urllib/request.py", line 532, in open
    response = meth(req, response)
  File "/usr/lib/python3.6/urllib/request.py", line 642, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python3.6/urllib/request.py", line 570, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 650, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: SSL is required

Add support for wheels!

I love using pip2pkgbuild because I don't know much about PKGBUILD scripts myself. The one problem is that it always uses setup.py to build the package. making wheels with pip and installing as wheels from pip offers several advantages, including that the setup.py file never has root, compiled components can be distributed as binaries, modules ship with bytecode compiled and entry_points generates much faster startup scripts.

It would be awesome if pip2pkgbuild supported this installation method!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.