Giter Club home page Giter Club logo

py2pack's Introduction

Py2pack: Generate distribution packages from PyPI

Unit tests

This script allows to generate RPM spec or DEB dsc files from Python modules. It allows to list Python modules or search for them on the Python Package Index (PyPI). Conveniently, it can fetch tarballs and changelogs making it an universal tool to package Python modules.

Installation

To install py2pack from the Python Package Index, simply:

$ python3 -mpip install py2pack

You can also check your distro of choice if they provide packages. For openSUSE Tumbleweed and Leap 15.X, you can

$ sudo zypper install python3-py2pack

Usage

Lets suppose you want to package zope.interface and you don't know how it is named exactly. First of all, you can search for it and download the source tarball if you found the correct module:

$ py2pack search zope.interface
searching for module zope.interface...
found zope.interface-3.6.1
$ py2pack fetch zope.interface
downloading package zope.interface-3.6.1...
from http://pypi.python.org/packages/source/z/zope.interface/zope.interface-3.6.1.tar.gz

As a next step you may want to generate a package recipe for your distribution. For RPM-based distributions (let's use openSUSE as an example), you want to generate a spec file (named 'python-zope.interface.spec'):

$ py2pack generate zope.interface -t opensuse.spec -f python-zope.interface.spec

The source tarball and the package recipe is all you need to generate the RPM (or DEB) file. This final step may depend on which distribution you use. Again, for openSUSE (and by using the Open Build Service), the complete recipe is:

$ osc mkpac python-zope.interface
$ cd python-zope.interface
$ py2pack fetch zope.interface
$ py2pack generate zope.interface -f python-zope.interface.spec
$ osc build
...

Depending on the module, you may have to adapt the resulting spec file slightly. To get further help about py2pack usage, issue the following command:

$ py2pack help

Hacking and contributing

You can test py2pack from your git checkout by executing the py2pack module.

Edit py2pack/version.py file changing the version number. Adding +1 to the revision number and optionally appending .dev1 is enough and makes sure that you can distinguish your hackish version from an installed one.

From the py2pack directory, install the py2pack module locally.

$ pip install -e .

Now you can run your hackish py2pack version. It is usually located in $HOME/.local/bin/py2pack

$ py2pack

Fork the repository on Github to start making your changes to the master branch (or branch off of it). Don't forget to write a test for fixed issues or implemented features whenever appropriate. You can invoke the testsuite from the repository root directory via tox:

$ tox

To run a single test class via tox, use i.e.:

$ tox -epy38 test.test_py2pack:Py2packTestCase

You can also run pytest directly:

$ pytest

It assumes you have the test dependencies installed (available on PYTHONPATH) on your system.

copyright
  1. 2013 Sascha Peilicke.
license

Apache-2.0, see LICENSE for more details.

py2pack's People

Contributors

antlarr avatar bboozzoo avatar bitdeli-chef avatar bnavigator avatar danigm avatar dcermak avatar dirkmueller avatar esc avatar frispete avatar hramrach avatar huakim avatar iyuroch avatar kbabioch avatar l1k avatar m0ses avatar marfrh avatar mcepl avatar meggycal avatar okurz avatar saschpe avatar scarabeusiv avatar sebix avatar termim avatar thesp0nge avatar toabctl avatar yecril71pl 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

py2pack's Issues

Syntax error when parsing file

docb@T520:~/buildservice/Application:ERP:Tryton:3.8/python-pycha> py2pack generate -t opensuse.spec -f python-pycha.spec pycha
generating spec file for pycha...
Traceback (most recent call last):
File "/usr/bin/py2pack", line 22, in
main()
File "/usr/lib/python2.7/site-packages/py2pack/init.py", line 354, in main
args.func(args)
File "/usr/lib/python2.7/site-packages/py2pack/init.py", line 268, in generate
_augment_data_from_tarball(args, tarball_file[0], data)
File "/usr/lib/python2.7/site-packages/py2pack/init.py", line 213, in _augment_data_from_tarball
_parse_setup_py(f.extractfile(setup_filename), data)
File "/usr/lib/python2.7/site-packages/py2pack/init.py", line 110, in _parse_setup_py
data["install_requires"] = eval(match.group(1))
File "", line 3
# ]
^
SyntaxError: invalid syntax

Is this problem already known?

Traceback: NameError: name 'conditional_dependencies' is not defined

Happens on openSUSE Tumbleweed:

Information for package python-py2pack:
---------------------------------------
Repository: openSUSE-20150516-0
Name: python-py2pack
Version: 0.4.10-3.1
[..]
py2pack generate jrnl -t opensuse.spec -f python-jrnl.spec
generating spec file for jrnl...
Traceback (most recent call last):
  File "/usr/bin/py2pack", line 22, in <module>
    main()
  File "/usr/lib/python2.7/site-packages/py2pack/__init__.py", line 255, in main
    args.func(args)
  File "/usr/lib/python2.7/site-packages/py2pack/__init__.py", line 155, in generate
    _augment_data_from_tarball(args, tarball_file[0], data)
  File "/usr/lib/python2.7/site-packages/py2pack/__init__.py", line 117, in _augment_data_from_tarball
    _parse_setup_py(f.extractfile(setup_filename), data)
  File "/usr/lib/python2.7/site-packages/py2pack/__init__.py", line 104, in _parse_setup_py
    data["install_requires"] = eval(match.group(1))
  File "<string>", line 7, in <module>
NameError: name 'conditional_dependencies' is not defined

Run-requirements are not evaluated

I noticed that after generating a spec file, the build requirements are properly in, but not the required packages for runtime (found under .egg-info/requires.txt)
Is this a feature not implemented yet?

py2pack fails with deprecated API fault

This software no longer works:

kbabioch@aquarius /home/kbabioch/home:kbabioch/python-fido2                                                                                                                                                        
⚡ py2pack generate fido2 -f python-fido2.spec                                                                                                           
generating spec file for fido2...
Traceback (most recent call last):
  File "/usr/bin/py2pack", line 10, in <module>
    sys.exit(main())
  File "/usr/lib/python2.7/site-packages/py2pack/__init__.py", line 341, in main
    args.func(args)
  File "/usr/lib/python2.7/site-packages/py2pack/__init__.py", line 223, in generate
    url = newest_download_url(args)
  File "/usr/lib/python2.7/site-packages/py2pack/__init__.py", line 271, in newest_download_url
    for url in pypi.package_urls(args.name, args.version):                  # Fetch all download URLs
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1243, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1602, in __request
    verbose=self.__verbose
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1283, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1316, in single_request
    return self.parse_response(response)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1493, in parse_response
    return u.close()
  File "/usr/lib64/python2.7/xmlrpclib.py", line 800, in close
    raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault -32500: 'RuntimeError: This API has been deprecated. Use https://pypi.org/fido2/0.3.0/json instead. The XMLRPC method release_urls can be used in the interim, but will be deprecated in the future.'>

kbabioch@aquarius /home/kbabioch/home:kbabioch/python-fido2                                                                                                                                                        
⚡ py2pack --version
py2pack 0.8.2

References:
https://bugzilla.suse.com/show_bug.cgi?id=1089613

Python 3 templates

For python3 packages on opensuse, all occurences of python- have to be replaced with python3. See

We could do a simple replace if the major version is 3, and on the other hand we can create py3 and p2 templates, e.g. templates/3/opensuse.spec and templates/2/opensuse.spec and we chose the version based on the python-version which is running py2pack in that moment.

What would be the preferred method?

I don't know how this is handled in Fedora.

extraction of metadata from setup.py is fundamentally flawed

Currently py2pack uses two different ways to extract metadata from setup.py:

  1. The default way is to use regexps to extract code fragments, eval them, and pray that we get the value we want. This can easily fail, e.g. if the code fragments reference any variables defined elsewhere in setup.py.

  2. The alternative way, when the --run option is used, is to run setup.py inside a setuptools.sandbox.DirectorySandbox, and then rely on some private internal voodoo within distutils.core:

    distutils.core._setup_stop_after = "config"
    setuptools.sandbox.run_setup(setup_filename, "")
    dist = distutils.core._setup_distribution
    

As can be seen by many other bug reports, the default way is fraught with failure, and I can no longer get --run to work at all, which suggests that maybe something changed in the internals of setuptools.

A far better approach to this problem of dynamic evaluation of metadata from setup.py is shown by fpm:

That approach does not rely on any private internal implementation details within distutils.

Having said all that, is py2pack even maintained any more? If not, maybe we should scrap it in favour of fpm.

Namespace object has no attribute func

On py36 when calling py2pack with no options or args the following error is triggered:

Traceback (most recent call last):
  File "/usr/bin/py2pack", line 10, in <module>
    sys.exit(main())
  File "/usr/lib/python3.6/site-packages/py2pack/__init__.py", line 334, in main
    args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Can not fetch Django

$ py2pack fetch Django
downloading package Django-1.11b1...
from 
Traceback (most recent call last):
  File "/usr/bin/py2pack", line 10, in <module>
    sys.exit(main())
  File "/usr/lib/python2.7/site-packages/py2pack/__init__.py", line 334, in main
    args.func(args)
  File "/usr/lib/python2.7/site-packages/py2pack/__init__.py", line 93, in fetch
    urlretrieve(url['url'], url['filename'])
  File "/usr/lib64/python2.7/urllib.py", line 98, in urlretrieve
    return opener.retrieve(url, filename, reporthook, data)
  File "/usr/lib64/python2.7/urllib.py", line 245, in retrieve
    fp = self.open(url, data)
  File "/usr/lib64/python2.7/urllib.py", line 213, in open
    return getattr(self, name)(url)
  File "/usr/lib64/python2.7/urllib.py", line 469, in open_file
    return self.open_local_file(url)
  File "/usr/lib64/python2.7/urllib.py", line 483, in open_local_file
    raise IOError(e.errno, e.strerror, e.filename)
IOError: [Errno 2] No such file or directory: ''

py2pack generate -t fedora.spec broken?

Hello folks,

I currently have a CentOS 7 box where I've installed py2pack with the following command:
sudo pip3.4 install py2pack
It has successfully installed py2pack 0.8.2 and its basic functionality seems to be there.

However, I'm having trouble with a command that used to work which no longer seems to be functioning:
py2pack generate -t fedora.spec click

I get the following output:

generating spec file for click...
Traceback (most recent call last):
  File "/usr/bin/py2pack", line 11, in <module>
    sys.exit(main())
  File "/usr/lib/python3.4/site-packages/py2pack/__init__.py", line 341, in main
    args.func(args)
  File "/usr/lib/python3.4/site-packages/py2pack/__init__.py", line 223, in generate
    url = newest_download_url(args)
  File "/usr/lib/python3.4/site-packages/py2pack/__init__.py", line 271, in newest_download_url
    for url in pypi.package_urls(args.name, args.version):                  # Fetch all download URLs
  File "/usr/lib64/python3.4/xmlrpc/client.py", line 1105, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib64/python3.4/xmlrpc/client.py", line 1445, in __request
    verbose=self.__verbose
  File "/usr/lib64/python3.4/xmlrpc/client.py", line 1147, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib64/python3.4/xmlrpc/client.py", line 1163, in single_request
    return self.parse_response(resp)
  File "/usr/lib64/python3.4/xmlrpc/client.py", line 1335, in parse_response
    return u.close()
  File "/usr/lib64/python3.4/xmlrpc/client.py", line 662, in close
    raise Fault(**self._stack[0])
xmlrpc.client.Fault: <Fault -32500: 'RuntimeError: This API has been deprecated. Use https://pypi.org/click/6.7/json instead. The XMLRPC method release_urls can be used in the interim, but will be deprecated in the future.'>

On the plus side, it is able to find that the latest version of python-click is 6.7, which means that it's at least able to derive that info successfully. So, it's partially working, but it's still not completing what it needs to. Was there perhaps some site reorganization on pypi.org that requires py2pack to be updated?

I've also tried using an explicit version:
py2pack generate -t fedora.spec click 6.6
and got similar results (minus the version change in the link).

I haven't tried using this command for about a year, so I can't tell when the last time it worked was.

Does anybody have any ideas?

Thanks!

ignores requirements.txt

Currently setup.py is parsed to discover dependencies, but if they are only stated in requirements.txt or similar then the spec file ends up with all the dependencies missing.

The weird thing is that there is a parse_requirements() method in py2pack.setup, but it's only used for packaging py2pack itself.

BuildRequires nose if using nosetests.

Currently, py2pack will insert nosetests in the .spec file %check section. However, when it does this, it does not add python-nose to the BuildRequires. It would be nice if it did this since the test cannot work without the package.

Generate sometimes produces blank spec tags

Generating a spec sometimes results in blank spec tags, such as Url: and License. Perhaps these should be commented out if appropriate values are not found in the input package.

Fedora now uses python2, python3 module names and distinct builds

Fedora has been splitting module builds into distinct python2-[module] and python3-[module] names for some years now. It should be possible to update the fedora.spec file to generate code compatible with this, and much closer to the current Fedora structure for compatibility.

Insert spaces in dependency versions

Currently, dependency versions are just copied to the spec file BuildRequires verbatim. However, in cases where there are no spaces between the version number and the package name, the spec file will interpret it as one big name rather than a package with a version (so python>=2.6 will look for a package named python>=2.6, rather than a package named python with version >=2.6).

It would be great if py2pack detected this and inserted appropriate spaces.

Add update command which does fetch and re-generate

py2pack update foo would fetch a newer foo if it is exists, and update the Version in .spec if appropriate,

Ideally it also exited with non-zero exit code if no newer version was available, to make scripting easy.

ValueError: substring not found

With latest version from git:

$ python ~/devel/py2pack/py2pack/__init__.py generate blockdiag -f python-blockdiag.spec
generating spec file for blockdiag...
Traceback (most recent call last):
  File "/home/tom/devel/py2pack/py2pack/__init__.py", line 360, in <module>
    main()
  File "/home/tom/devel/py2pack/py2pack/__init__.py", line 355, in main
    args.func(args)
  File "/home/tom/devel/py2pack/py2pack/__init__.py", line 269, in generate
    _augment_data_from_tarball(args, tarball_file[0], data)
  File "/home/tom/devel/py2pack/py2pack/__init__.py", line 215, in _augment_data_from_tarball
    _canonicalize_setup_data(data)
  File "/home/tom/devel/py2pack/py2pack/__init__.py", line 200, in _canonicalize_setup_data
    i[:i.index(" = ")] for i in data["entry_points"]["console_scripts"]]
ValueError: substring not found

`py2pack generate khal -f python-khal' leads to AttributeError

generating spec for python-khal produce AttributeError

$ py2pack generate khal -f python-khal
generating spec file for khal...
Traceback (most recent call last):
  File "/usr/bin/py2pack", line 22, in <module>
    main()
  File "/usr/lib/python2.7/site-packages/py2pack/__init__.py", line 354, in main
    args.func(args)
  File "/usr/lib/python2.7/site-packages/py2pack/__init__.py", line 268, in generate
    _augment_data_from_tarball(args, tarball_file[0], data)
  File "/usr/lib/python2.7/site-packages/py2pack/__init__.py", line 214, in _augment_data_from_tarball
    _canonicalize_setup_data(data)
  File "/usr/lib/python2.7/site-packages/py2pack/__init__.py", line 199, in _canonicalize_setup_data
    data["console_scripts"] = data["entry_points"]["console_scripts"].keys()
AttributeError: 'list' object has no attribute 'keys'

pip install fails on RHEL 5

Will py2pack work for python 2.4? I ask because this is what people get with RHEL 5.

When trying to install py2pack using pip on RHEL 5.5 I get the following:

[igable@elephant ~]$ pip --version
pip 0.8.2 from /usr/lib/python2.4/site-packages/pip-0.8.2-py2.4.egg (python 2.4)

[igable@elephant ~]$ sudo pip install py2pack
[sudo] password for igable: 
Downloading/unpacking py2pack
  Downloading py2pack-0.3.10.tar.gz
  Running setup.py egg_info for package py2pack
    Traceback (most recent call last):
      File "<string>", line 14, in ?
      File "/home/igable/build/py2pack/setup.py", line 2, in ?
        import py2pack
      File "py2pack/__init__.py", line 5, in ?
        from py2pack import list, search, fetch, generate, main
      File "py2pack/py2pack.py", line 74
        with open(args.filename, 'w') as outfile:                               # write result to spec file
                ^
    SyntaxError: invalid syntax
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 14, in ?

  File "/home/igable/build/py2pack/setup.py", line 2, in ?

    import py2pack

  File "py2pack/__init__.py", line 5, in ?

    from py2pack import list, search, fetch, generate, main

  File "py2pack/py2pack.py", line 74

    with open(args.filename, 'w') as outfile:                               # write result to spec file

            ^

SyntaxError: invalid syntax

----------------------------------------
Command python setup.py egg_info failed with error code 1

`py2pack generate praw -f python-praw.spec' leads to syntax error

I just met this error:

$ py2pack generate praw -f python-praw.spec
generating spec file for praw...
Traceback (most recent call last):
  File "/usr/bin/py2pack", line 22, in <module>
    main()
  File "/usr/lib/python2.7/site-packages/py2pack/__init__.py", line 354, in main
    args.func(args)
  File "/usr/lib/python2.7/site-packages/py2pack/__init__.py", line 268, in generate
    _augment_data_from_tarball(args, tarball_file[0], data)
  File "/usr/lib/python2.7/site-packages/py2pack/__init__.py", line 222, in _augment_data_from_tarball
    _parse_setup_py(s, data)
  File "/usr/lib/python2.7/site-packages/py2pack/__init__.py", line 107, in _parse_setup_py
    data["test_suite"] = eval(match.group(1))
  File "<string>", line 1
    'tests')
           ^
SyntaxError: invalid syntax

Can not fetch pyv8

> py2pack fetch PyV8
downloading package PyV8-1.0-dev...
from http://code.google.com/p/pyv8/downloads/list

Results in a html-file list.

But pip has no problem:

> pip download pyv8
Collecting pyv8
  Using cached PyV8-0.5.zip
  Saved ./PyV8-0.5.zip
Successfully downloaded pyv8

Probably using pip internally is less error-prone?

py2pack generate -t fedora.spec has a few breakages

Hello again,

I'm happy to confirm that py2pack 0.8.3 is now (mostly) working again for "generate -t fedora.spec".
I've found a few cases that I'd like to report as broken on EL-7, which maybe somebody would have some insight about. I can't tell if they're because the packages are doing non-standard things with their code / sites, or if there are py2pack issues.

For all of these cases, I'm starting out with the following procedure:

sudo yum -y install python34 python34-libs
curl -O https://bootstrap.pypa.io/get-pip.py
sudo /usr/bin/python3.4 ./get-pip.py
sudo pip3.4 install py2pack

Here are some breakages and reasons.

  1. consul
py2pack generate -t fedora.spec -f consul.spec consul 0.7.2

This generates a specfile with a weird Source line:

Source:         %{version}c%{version}o%{version}n%{version}s%{version}u%{version}l%{version}-%{version}0%{version}.%{version}7%{version}.%{version}2%{version}.%{version}z%{version}i%{version}p%{version}
  1. pip
py2pack  generate -t fedora.spec -f pip.spec pip 9.0.1

This generates a specfile with a weird BuildRequires line:

BuildRequires:  python-devel = >=2.6,!=3.0.*,!=3.1.*,!=3.2.*
  1. psutil
py2pack generate -t fedora.spec -f psutil.spec psutil 5.4.5

This generates a specfile with a weird BuildRequires line:

BuildRequires:  python-devel = >=2.6, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*

Additionally, psutil's %description field is weird, but I think the specfile will process it anyway. My guess is that's because the source info for psutil is strange.

I just wanted to share, just in case this is useful to help improve the tool.

os-faults requires blocks are missing.

$ ls
os_faults-0.1.9.tar.gz
$ py2pack generate os-faults 0.1.9

os-faults.spec is generated but is missing the {Build}Requires sections.
the tarball has the {test}-requirements.txt file present.

$ py2pack metadata os_faults-0.1.9.tar.gz
shows the correct output with the two requires sections

needs new maintainer?

@saschpe Please can you clarify whether you are still maintaining this? I suspect not, in which case it would be good to hand it over to someone else before too many more unreviewed pull requests accumulate. Cheers!

Looking for python27 template

The RHEL software collections need some additional syntax and an enabled local yum environment, or reconfigured "mock" setup, to compile python27 enabled packages on RHEL 6 based operating systems. I'll be happy to submit one if I can pry some time free.

Support for wheels

A lot of packages are now either only supporting wheels or provide a more reliable installation when using wheels. It would be nice if py2pack could generate spec files for wheels.

Stacktrace under Python 2.6

"py2pack generate" says the following under Python 2.6 (it's using syntax introduced in Python 2.7). Either this should be fixed or the supported versions should be changed.

Traceback (most recent call last):
  File "/users/geoff/.local/selenium_test/bin/py2pack", line 22, in <module>
    main()
  File "/users/geoff/.local/selenium_test/lib/python2.6/site-packages/py2pack/__init__.py", line 255, in main
    args.func(args)
  File "/users/geoff/.local/selenium_test/lib/python2.6/site-packages/py2pack/__init__.py", line 155, in generate
    _augment_data_from_tarball(args, tarball_file[0], data)
  File "/users/geoff/.local/selenium_test/lib/python2.6/site-packages/py2pack/__init__.py", line 115, in _augment_data_from_tarball
    with tarfile.open(filename) as f:
AttributeError: 'TarFile' object has no attribute '__exit__'

ImportError: No module named 'jinja2'

$ source xxx/bin/activate
(xxx) tom@basilikum:~/tmp$ pip install py2pack
Collecting py2pack
  Downloading py2pack-0.6.7.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-_dyaoiza/py2pack/setup.py", line 24, in <module>
        import py2pack
      File "/tmp/pip-build-_dyaoiza/py2pack/py2pack/__init__.py", line 40, in <module>
        import jinja2
    ImportError: No module named 'jinja2'
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-_dyaoiza/py2pack/

ChangeLog?

It is rather hard to figure out if its worth the hassle to update the lib.

Wrong paths for man

I used @asdf-vm to build py2pack, and while generating for anyconfig the .spec contained:

%dir /home/jayvdb/.asdf/installs/python/3.7.2/share/man/man1
/home/jayvdb/.asdf/installs/python/3.7.2/share/man/man1/anyconfig_cli.1

I suspect something is using sys.executable, and this might be fixed by using /usr/bin/python* instead, but that could create new problems.

Support GitHub tarballs

Sometimes it is useful/necessary to fetch the source tarballs from the git/hg/etc repo, especially to get tests which are excluded from the PyPi package.

Also, it would be nice if py2pack could ensure this approach is done in a safe manner, using PyPi for the main content, and then splicing in extra content in the source repo's tarball.

SyntaxError: invalid syntax

$ py2pack generate -f python-elasticsearch.spec elasticsearch
generating spec file for elasticsearch...
Traceback (most recent call last):
File "/usr/bin/py2pack", line 22, in
main()
File "/usr/lib/python2.7/site-packages/py2pack/init.py", line 255, in main
args.func(args)
File "/usr/lib/python2.7/site-packages/py2pack/init.py", line 155, in generate
_augment_data_from_tarball(args, tarball_file[0], data)
File "/usr/lib/python2.7/site-packages/py2pack/init.py", line 117, in _augment_data_from_tarball
_parse_setup_py(f.extractfile(setup_filename), data)
File "/usr/lib/python2.7/site-packages/py2pack/init.py", line 104, in _parse_setup_py
data["install_requires"] = eval(match.group(1))
File "", line 4
tests_require = [
^
SyntaxError: invalid syntax

py2pack/setup.py license

The main py2pack license is under GPL-2.0. py2pack/setup.py, on the other hand, is under the Apache 2.0 license (according to the file header). These two licenses are incompatible. As it stands, the current version of the package cannot be accepted into openSUSE:Factory because of this incompatibility.

py2pack fails with Radicale

py2pack generate -t opensuse.spec Radicale
generating spec file for Radicale...
Traceback (most recent call last):
File "/usr/bin/py2pack", line 2, in
from py2pack import main; main()
File "/usr/lib/python2.7/site-packages/py2pack/py2pack.py", line 132, in main
args.func(args)
File "/usr/lib/python2.7/site-packages/py2pack/py2pack.py", line 76, in generate
outfile.write(result)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 1856: ordinal not in range(128)

python 2.7 on openSUSE 11.4

version of generate

When using the generate command with a package that's not the latest on PyPI, py2pack uses the latest version from PyPI instead of the version of the input package. I believe py2pack should use the version of the input file instead.

ValueError: too many values to unpack (expected 1)

py2pack generate gitsome -f python-gitsome.spec results in:

generating spec file for gitsome...
Traceback (most recent call last):
  File "/usr/bin/py2pack", line 21, in <module>
    main()
  File "/usr/lib/python3.5/site-packages/py2pack/__init__.py", line 314, in main
    args.func(args)
  File "/usr/lib/python3.5/site-packages/py2pack/__init__.py", line 219, in generate
    _augment_data_from_tarball(args, tarball_file[0], data)
  File "/usr/lib/python3.5/site-packages/py2pack/__init__.py", line 147, in _augment_data_from_tarball
    _canonicalize_setup_data(data)
  File "/usr/lib/python3.5/site-packages/py2pack/__init__.py", line 106, in _canonicalize_setup_data
    py2pack.requires._requirements_sanitize(data["install_requires"])
  File "/usr/lib/python3.5/site-packages/py2pack/requires.py", line 108, in _requirements_sanitize
    return [" ".join(req) for req in filtered_req_list]
  File "/usr/lib/python3.5/site-packages/py2pack/requires.py", line 108, in <listcomp>
    return [" ".join(req) for req in filtered_req_list]
  File "/usr/lib/python3.5/site-packages/py2pack/requires.py", line 105, in <lambda>
    map(lambda x: pkg_resources.Requirement.parse(x), req_list)
  File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2918, in parse
    req, = parse_requirements(s)
ValueError: too many values to unpack (expected 1)

openSUSE multipython template

openSUSE is currently switching to using the new multipython macros, which allow for building for multiply python versions in a single spec file. It would be nice if py2pack supported this.

Evaluate pypi summary not being evaluated

docb@T520:~/buildservice/Application:ERP:Tryton:3.2/trytond_nereid> py2pack
generate trytond_nereid-3.0.7.2.tar.gz trytond_nereid.spec
generating spec file for trytond_nereid-3.0.7.2.tar.gz...
Traceback (most recent call last):
File "/usr/bin/py2pack", line 22, in
main()
File "/usr/lib/python2.7/site-packages/py2pack/init.py", line 255, in
main
args.func(args)
File "/usr/lib/python2.7/site-packages/py2pack/init.py", line 151, in
generate
data['summary_no_ending_dot'] = re.sub('(.*).', '\g<1>', data['summary'])
KeyError: 'summary'

Use %bcond_with test

I see a lot of packages in openSUSE d:l:python using

%bcond_with     test
...
%if %{with test}
BuildRequires:  %{python_module nose}
BuildRequires:  %{python_module ..}
%endif
...
%if %{with test}
%check
%python_exec ...
%endif

This would be a better approach in the templates, instead of adding comments above and below test dependencies.

multipython template bug and additional suggestions

In the multipython template, Requires: (and Recommends: and Suggests:) are wrapped in the %{python_module foo} macro. This is incorrect, since it makes all versions of the package depend on all versions of the dependency. So rather than having the python2 package depend on the python2 dependency and the python3 package depend on the python3 version, the approach py2pack uses makes the python2 package depend on both the python2 and python3 dependency and the python3 package depend on both the python2 and python3 depenceny.

Instead Requires, Recommends, and Suggests should be of the form python-foo. They are automatically converted to the correct python version by the macros. Only the BuildRequires should use the %{python_module foo} macro.

So, for example, something like:

BuildRequires:  python-rpm-macros
BuildRequires:  %{python_module devel}
BuildRequires:  %{python_module setuptools}
Requires:       %{python_module PyYAML}
Recommends:     %{python_module Django}
Suggests:       %{python_module pandas}

Should instead be

BuildRequires:  python-rpm-macros
BuildRequires:  %{python_module devel}
BuildRequires:  %{python_module setuptools}
Requires:       python-PyYAML
Recommends:     python-Django
Suggests:       python-pandas

There are also some minor issues with spacing:

%build

%python_build

%install
%python_install
%if %{with test}
%check
%python_exec setup.py test
%endif

Notice the extra space between %build and %python_build and the lack of a space between the %install section and the %check section.

Finally, due to how the multipython macros build the packages, it leads to a lot of duplicates. So we need to add a %fdupes call after %python_install. It would be great if this could be added automatically (along with Requires: fdupes). It should look like this:

%install
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}

Or

%install
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitearch}

Depending on where the python files end up.

Thanks a lot for implementing this!

Does not install correctly into clean virtualenv

Contrary to the README, it's not simply $ pip install py2pack. For version 0.4.4 I get this:

$ pip install py2pack
Downloading/unpacking py2pack
  Downloading py2pack-0.4.4.linux-x86_64.tar.gz
  Running setup.py egg_info for package py2pack
    Traceback (most recent call last):
      File "<string>", line 14, in <module>
    IOError: [Errno 2] No such file or directory: '/home/matthias/.virtualenvs/osb/build/py2pack/setup.py'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 14, in <module>

IOError: [Errno 2] No such file or directory: '/home/matthias/.virtualenvs/osb/build/py2pack/setup.py'

I tried installing 0.4.3, but that was complaining that Jinja2 is missing (why aren't the dependencies listed in setup.py by the way?). After installing Jinja2 manually I get this installation behaviour (no matter if 0.4.4 or 0.4.3):

$ pip install py2pack
Downloading/unpacking py2pack
  Running setup.py egg_info for package py2pack
    Traceback (most recent call last):
      File "<string>", line 14, in <module>
      File "/home/matthias/.virtualenvs/osb/build/py2pack/setup.py", line 29, in <module>
        import py2pack
      File "py2pack/__init__.py", line 24, in <module>
        from py2pack import __version__, list, search, fetch, generate, main
      File "py2pack/py2pack.py", line 61, in <module>
        SDPX_LICENSES = pickle.load(open(SPDX_LICENSES_FILE, 'rb'))
    IOError: [Errno 2] No such file or directory: 'py2pack/suse_spdx_license_map.p'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 14, in <module>

  File "/home/matthias/.virtualenvs/osb/build/py2pack/setup.py", line 29, in <module>

    import py2pack

  File "py2pack/__init__.py", line 24, in <module>

    from py2pack import __version__, list, search, fetch, generate, main

  File "py2pack/py2pack.py", line 61, in <module>

    SDPX_LICENSES = pickle.load(open(SPDX_LICENSES_FILE, 'rb'))

IOError: [Errno 2] No such file or directory: 'py2pack/suse_spdx_license_map.p'

For a tool that handles packaging, it's a bit disappointing to see the packaging done in this way.

openSUSE spec files don't follow package naming guidelines

For openSUSE spec files, the general naming pattern is python-{packagename}.spec. py2pack, however, creates spec files named {packagename}.spec by default, even though the package name inside the spec file is python-{packagename}.

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.