Giter VIP home page Giter VIP logo

pypack's Introduction

No boilerplate way to create (executable) source packages for Python modules.

Build Status PyPI

$ python -m pypack appvey.py
[*] Packing appvey.py into appvey-1234.zip
[*] Making appvey-1234.zip executable
[*] Making appvey-1234.zip installable
[*] Making appvey-1234.zip uploadable to PyPI

See also:

Features

  • No packaging boilerplate
  • Executable .zip file if module provides main() function
  • Command line script entry for the main() function
  • requirements.txt detected and included

Changes

  • 1.0 - Python 3 compatibility fix

Details

Necessary package fields are read from the .py module, without imporing it:

  • name - extracted from the module filename
  • __author__
  • __version__
  • __url__

Also detects and restores these optional fields:

  • __license__
  • description - first line of module docstring

Python packaging still relies on setup.py, so it is created automatically (but this may change with PEP-517 and PEP-518).

requirements.txt should use safe setuptools subset pypa/setuptools#1080 (comment)

main() function is required to enable executable features.

Checklist for packaging your module for PyPI
  • Pack your module into .zip archive

      pypack.py <module.py>
    
  • Write changelog

  • Tag release

    git tag -a
    git push --follow-tags
    
  • Upload archive to PyPI

    twine upload <package.zip>
    

pypack's People

Contributors

techtonik avatar

Stargazers

 avatar Nathan Larsen avatar Cosimo Lupo avatar Dale Athanasias avatar

Watchers

 avatar

pypack's Issues

Do not generate executable if main() is not found

Do not make anything executable if module doesn't expose main() function.

Traceback (most recent call last):
  File "__main__.py", line 4, in <module>
    sys.exit(appvey.main())
AttributeError: 'module' object has no attribute 'main'

Instead show a message;

* [x] main() is not found, skip executables

Deploy on tag

  • generate PyPI token for deployment
  • encrypt token for .travis.yml and add it there
$ travis encrypt -r techtonik/pypack --org
  • modify .travis.yml to execute commands on tag
  • add commands for uploading pypack on tag

0.2 and 0.3 are broken on Python 3

0.1 was ok - https://travis-ci.org/techtonik/python-patch/jobs/160276595
0.3 is not - https://travis-ci.org/techtonik/python-patch/jobs/577891157#L186

Traceback (most recent call last):
  File "/opt/python/3.4.8/lib/python3.4/runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/opt/python/3.4.8/lib/python3.4/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/travis/virtualenv/python3.4.8/lib/python3.4/site-packages/pypack.py", line 202, in <module>
    main()
  File "/home/travis/virtualenv/python3.4.8/lib/python3.4/site-packages/pypack.py", line 185, in main
    if not get_main(modpath):
  File "/home/travis/virtualenv/python3.4.8/lib/python3.4/site-packages/pypack.py", line 59, in get_main
    if line.startswith('def main('):
TypeError: startswith first arg must be bytes or a tuple of bytes, not str
The command "python -m pypack patch.py" exited with 1.

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.