Giter Site home page Giter Site logo

pypkgfreeze's Introduction

pypkgfreeze

Python's npm install --save

Code style: black Build Status

Automatically inserts your currently used package versions to setup.py.

Example

Old setup.py

from setuptools import setup
test_req = ['pytest', ]
setup(
    name='pypkgfreeze',
    install_requires=[
        "Click",
    ],
    tests_require=test_req,
    extras_require={
        'test': test_req
    }
)

New setup.py

from setuptools import setup
test_req = ['pytest==4.0.2', ]  # ADDED VERSION HERE
setup(
    name='pypkgfreeze',
    install_requires=[
        "Click==7.0",  # AND HERE
    ],
    tests_require=test_req,
    extras_require={
        'test': test_req
    }
)

Usage

pkgfreeze. It's that simple.

Installation

pip install pypkgfreeze

Contributing

Thanks! Please read the CONTRIBUTING.md file.

pypkgfreeze's People

Contributors

adamgold avatar

Stargazers

 avatar Jon Fincher avatar Tomer avatar Wes Turner avatar

Watchers

 avatar James Cloos avatar Tomer avatar

pypkgfreeze's Issues

implement add_new

if add_new=True, a generator will be made of all top tree dependencies - filtered by only non existing packages in setup.py. Then, add them (by regex, maybe AST in the future) to install_requires by the following logic:

  1. search for install_requires=
  2. search for the next comma that isn't followed by quotes (for example:
    install_requires=['test', 'test2'], # THIS COMMA test_requires)
  3. ask the user if he/she wants to add all non existing packages or loop through.
    if all - just make a list from the generator and add before that comma. If it's a loop, loop through the generator, asking the user whether to add a specific package each time - make a list and add before that comma.
  4. write to setup.py

re.error: missing ), unterminated subpattern at position 6

Running pkgfreeze in the pkgfreeze repo on Python 3.7 and the last PyPI release of pkgfreeze

pypkgfreeze> pkgfreeze
Traceback (most recent call last):
  File "/usr/bin/pkgfreeze", line 11, in <module>
    load_entry_point('pypkgfreeze==0.1.2', 'console_scripts', 'pkgfreeze')()
  File "/usr/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3.7/site-packages/pypkgfreeze/pypkgfreeze.py", line 43, in main
    altered_setup = freeze_pkgs(setup_path.read_text(), pip_output)
  File "/usr/lib/python3.7/site-packages/pypkgfreeze/pypkgfreeze.py", line 27, in freeze_pkgs
    r"[\'\"]({})[\'\"]".format(name), r'"\1=={}"'.format(version), text
  File "/usr/lib64/python3.7/re.py", line 192, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "/usr/lib64/python3.7/re.py", line 286, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/usr/lib64/python3.7/sre_compile.py", line 764, in compile
    p = sre_parse.parse(p, flags)
  File "/usr/lib64/python3.7/sre_parse.py", line 930, in parse
    p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
  File "/usr/lib64/python3.7/sre_parse.py", line 426, in _parse_sub
    not nested and not items))
  File "/usr/lib64/python3.7/sre_parse.py", line 819, in _parse
    source.tell() - start)
re.error: missing ), unterminated subpattern at position 6

test add_new=True

Add a test to make sure the add_new does in fact add new packages not listed in setup.py

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.