mirror of
https://github.com/bndr/pipreqs.git
synced 2025-06-07 12:05:33 +00:00
Merge pull request #255 from bndr/drop_python2
Drop support for python 2 and bump python versions in general
This commit is contained in:
commit
4219833019
14
.travis.yml
14
.travis.yml
@ -4,17 +4,17 @@ language: python
|
|||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
|
- python: 3.9
|
||||||
|
env: TOX_ENV=py39
|
||||||
|
- python: 3.8
|
||||||
|
env: TOX_ENV=py38
|
||||||
|
- python: 3.7
|
||||||
|
env: TOX_ENV=py37
|
||||||
- python: 3.6
|
- python: 3.6
|
||||||
env: TOX_ENV=py36
|
env: TOX_ENV=py36
|
||||||
- python: 3.5
|
|
||||||
env: TOX_ENV=py35
|
|
||||||
- python: 3.4
|
|
||||||
env: TOX_ENV=py34
|
|
||||||
- python: 2.7
|
|
||||||
env: TOX_ENV=py27
|
|
||||||
- python: pypy3
|
- python: pypy3
|
||||||
env: TOX_ENV=pypy3
|
env: TOX_ENV=pypy3
|
||||||
- python: 3.6
|
- python: 3.9
|
||||||
env: TOX_ENV=flake8
|
env: TOX_ENV=flake8
|
||||||
|
|
||||||
# Use tox to run tests on Travis-CI to keep one unified method of running tests in any environment
|
# Use tox to run tests on Travis-CI to keep one unified method of running tests in any environment
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""pipreqs - Generate pip requirements.txt file based on imports
|
"""pipreqs - Generate pip requirements.txt file based on imports
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
@ -37,13 +36,11 @@ Options:
|
|||||||
<gt> | e.g. Flask>=1.1.2
|
<gt> | e.g. Flask>=1.1.2
|
||||||
<no-pin> | e.g. Flask
|
<no-pin> | e.g. Flask
|
||||||
"""
|
"""
|
||||||
from __future__ import print_function, absolute_import
|
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
import logging
|
import logging
|
||||||
import codecs
|
|
||||||
import ast
|
import ast
|
||||||
import traceback
|
import traceback
|
||||||
from docopt import docopt
|
from docopt import docopt
|
||||||
@ -58,14 +55,6 @@ REGEXP = [
|
|||||||
re.compile(r'^from ((?!\.+).*?) import (?:.*)$')
|
re.compile(r'^from ((?!\.+).*?) import (?:.*)$')
|
||||||
]
|
]
|
||||||
|
|
||||||
if sys.version_info[0] > 2:
|
|
||||||
open_func = open
|
|
||||||
py2 = False
|
|
||||||
else:
|
|
||||||
open_func = codecs.open
|
|
||||||
py2 = True
|
|
||||||
py2_exclude = ["concurrent", "concurrent.futures"]
|
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def _open(filename=None, mode='r'):
|
def _open(filename=None, mode='r'):
|
||||||
@ -122,7 +111,7 @@ def get_all_imports(
|
|||||||
candidates += [os.path.splitext(fn)[0] for fn in files]
|
candidates += [os.path.splitext(fn)[0] for fn in files]
|
||||||
for file_name in files:
|
for file_name in files:
|
||||||
file_name = os.path.join(root, file_name)
|
file_name = os.path.join(root, file_name)
|
||||||
with open_func(file_name, "r", encoding=encoding) as f:
|
with open(file_name, "r", encoding=encoding) as f:
|
||||||
contents = f.read()
|
contents = f.read()
|
||||||
try:
|
try:
|
||||||
tree = ast.parse(contents)
|
tree = ast.parse(contents)
|
||||||
@ -157,7 +146,6 @@ def get_all_imports(
|
|||||||
with open(join("stdlib"), "r") as f:
|
with open(join("stdlib"), "r") as f:
|
||||||
data = {x.strip() for x in f}
|
data = {x.strip() for x in f}
|
||||||
|
|
||||||
data = {x for x in data if x not in py2_exclude} if py2 else data
|
|
||||||
return list(packages - data)
|
return list(packages - data)
|
||||||
|
|
||||||
|
|
||||||
@ -214,7 +202,7 @@ def get_locally_installed_packages(encoding=None):
|
|||||||
for item in files:
|
for item in files:
|
||||||
if "top_level" in item:
|
if "top_level" in item:
|
||||||
item = os.path.join(root, item)
|
item = os.path.join(root, item)
|
||||||
with open_func(item, "r", encoding=encoding) as f:
|
with open(item, "r", encoding=encoding) as f:
|
||||||
package = root.split(os.sep)[-1].split("-")
|
package = root.split(os.sep)[-1].split("-")
|
||||||
try:
|
try:
|
||||||
package_import = f.read().strip().split("\n")
|
package_import = f.read().strip().split("\n")
|
||||||
@ -309,7 +297,7 @@ def parse_requirements(file_):
|
|||||||
delim = ["<", ">", "=", "!", "~"]
|
delim = ["<", ">", "=", "!", "~"]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
f = open_func(file_, "r")
|
f = open(file_, "r")
|
||||||
except OSError:
|
except OSError:
|
||||||
logging.error("Failed on file: {}".format(file_))
|
logging.error("Failed on file: {}".format(file_))
|
||||||
raise
|
raise
|
||||||
@ -381,7 +369,7 @@ def clean(file_, imports):
|
|||||||
to_write = []
|
to_write = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
f = open_func(file_, "r+")
|
f = open(file_, "r+")
|
||||||
except OSError:
|
except OSError:
|
||||||
logging.error("Failed on file: {}".format(file_))
|
logging.error("Failed on file: {}".format(file_))
|
||||||
raise
|
raise
|
||||||
|
1652
pipreqs/stdlib
1652
pipreqs/stdlib
File diff suppressed because it is too large
Load Diff
11
setup.py
11
setup.py
@ -1,6 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
@ -34,7 +32,7 @@ setup(
|
|||||||
package_dir={'pipreqs':
|
package_dir={'pipreqs':
|
||||||
'pipreqs'},
|
'pipreqs'},
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
package_data={'': ['stdlib','mapping']},
|
package_data={'': ['stdlib', 'mapping']},
|
||||||
install_requires=requirements,
|
install_requires=requirements,
|
||||||
license='Apache License',
|
license='Apache License',
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
@ -44,12 +42,11 @@ setup(
|
|||||||
'Intended Audience :: Developers',
|
'Intended Audience :: Developers',
|
||||||
'License :: OSI Approved :: Apache Software License',
|
'License :: OSI Approved :: Apache Software License',
|
||||||
'Natural Language :: English',
|
'Natural Language :: English',
|
||||||
'Programming Language :: Python :: 2',
|
|
||||||
'Programming Language :: Python :: 2.7',
|
|
||||||
'Programming Language :: Python :: 3',
|
'Programming Language :: Python :: 3',
|
||||||
'Programming Language :: Python :: 3.4',
|
|
||||||
'Programming Language :: Python :: 3.5',
|
|
||||||
'Programming Language :: Python :: 3.6',
|
'Programming Language :: Python :: 3.6',
|
||||||
|
'Programming Language :: Python :: 3.7',
|
||||||
|
'Programming Language :: Python :: 3.8',
|
||||||
|
'Programming Language :: Python :: 3.9',
|
||||||
],
|
],
|
||||||
test_suite='tests',
|
test_suite='tests',
|
||||||
entry_points={
|
entry_points={
|
||||||
|
4
tox.ini
4
tox.ini
@ -1,5 +1,5 @@
|
|||||||
[tox]
|
[tox]
|
||||||
envlist = py27, py34, py35, py36, pypy3, flake8
|
envlist = py36, py37, py38, py39, pypy3, flake8
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
setenv =
|
setenv =
|
||||||
@ -9,7 +9,7 @@ deps =
|
|||||||
-r{toxinidir}/requirements.txt
|
-r{toxinidir}/requirements.txt
|
||||||
|
|
||||||
[testenv:flake8]
|
[testenv:flake8]
|
||||||
basepython = python3.6
|
basepython = python3.9
|
||||||
commands = flake8 pipreqs
|
commands = flake8 pipreqs
|
||||||
deps =
|
deps =
|
||||||
-r{toxinidir}/requirements.txt
|
-r{toxinidir}/requirements.txt
|
||||||
|
Loading…
x
Reference in New Issue
Block a user