Code Monkey home page Code Monkey logo

spec4pypi's Introduction

pyp2rpm

Tool to convert a package from PyPI to RPM SPECFILE. Under heavy development, see TODO file for list of planned features. pyp2rpm currently ships with Fedora and Mageia specific templates.

Usage:

The most simple use case is running:

pyp2rpm -n package_name

This downloads the package from PyPI and outputs the RPM SPECFILE.

All of the options are (print this by running pyp2rpm -h:

usage: pyp2rpm [-h] -n PYPI_NAME [-v VERSION] [-m METADATA_SOURCE]
               [-s PACKAGE_SOURCE] [-d SAVE_DIR] [-t TEMPLATE]

Convert PyPI package to RPM specfile.

optional arguments:
-h, --help          show this help message and exit
-n PYPI_NAME        Name of the package on PyPI (ignored for local files).
-v VERSION          Version of the package to download (ignored for local files).
-m METADATA_SOURCE  Where to get metadata from ("pypi" or "local", default: "pypi").
-s PACKAGE_SOURCE   Where to get package from ("pypi" or "/full/path/to/local/file", default: "pypi").
-d SAVE_DIR         Where to save the package file (default: "/home/bkabrda/rpmbuild/SOURCES/")
-t TEMPLATE         Template file (jinja2 format) to render (default: "fedora"). Search order is 1) filesystem, 2) default templates.
-b BASE_PYTHON      Base Python version to package for (default: "2").
-p PYTHON_VERSION   Additional Python versions to include in the specfile (e.g -p3 for %{?with_python3}). Can be specified multiple times.

To run the unit tests, cd into the checked out directory and run:

PYTHONPATH=$(pwd) py.test

I will gladly accept any pull request or recommendation. With complex pull requests, please include unit tests in pytest, use flexmock if you need mocking.

pyp2rpm is licensed under MIT license.

spec4pypi's People

Contributors

bkabrda avatar joequant avatar henrysher avatar pixelb avatar

Stargazers

Jim Ma avatar  avatar  avatar Anay Nayak avatar

Watchers

 avatar  avatar  avatar

spec4pypi's Issues

"classifiers" can be a tuple but spec4pypi only detected for a list

For example, https://github.com/aws/aws-cli/blob/develop/setup.py

    classifiers=(
        'Development Status :: 5 - Production/Stable',
        'Intended Audience :: Developers',
        'Intended Audience :: System Administrators',
        'Natural Language :: English',
        'License :: OSI Approved :: Apache Software License',
        'Programming Language :: Python',
        'Programming Language :: Python :: 2.6',
        'Programming Language :: Python :: 2.7',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.3',
    ),

But spec4pypi could support to detect a list.

[DBUtils] no "open software license" in spec4pypi

No "open software license" in spec4pypi on DBUtils package: https://pypi.python.org/pypi/DBUtils/

classifiers=['Development Status :: 4 - Beta',
        'Environment :: Web Environment',
        'Intended Audience :: Developers',
        'License :: OSI Approved :: Open Software License',
        'Programming Language :: Python',
        'Topic :: Database',
        'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
        'Topic :: Software Development :: Libraries :: Python Modules'
    ],
Traceback (most recent call last):
  File "/opt/rh/python27/root/usr/bin/pyp2rpm", line 9, in <module>
    load_entry_point('pyp2rpm==1.0.1', 'console_scripts', 'pyp2rpm')()
  File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/pyp2rpm/bin.py", line 81, in main
    converted = convertor.convert()
  File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/pyp2rpm/convertor.py", line 56, in convert
    data = self.get_metadata_extractor(local_file).extract_data()
  File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/pyp2rpm/metadata_extractors.py", line 261, in extract_data
    data.set_from(self.data_from_archive)
  File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/pyp2rpm/metadata_extractors.py", line 186, in data_from_archive
    archive_data['license'] = self.license_from_archive
  File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/pyp2rpm/metadata_extractors.py", line 121, in license_from_archive
    return self.license_from_setup_py
  File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/pyp2rpm/metadata_extractors.py", line 125, in license_from_setup_py
    license = utils.license_from_trove(self.archive.find_list_argument('classifiers'))
  File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/pyp2rpm/archive.py", line 241, in find_list_argument
    if "," in sub_argument[-1]:
IndexError: string index out of range

Need to re-write the way of extracting information from "setup.py"

Right now, we just take "setup.py" as a string to extract the useful information. It is really difficult for the compatibility issues around the format of "setup.py". So it is time to re-write the logic of extracting the information from "setup.py" via "import_module".

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.