Skip to content

Commit

Permalink
Merge d5e337c into 78b305a
Browse files Browse the repository at this point in the history
  • Loading branch information
pgaref committed Oct 16, 2020
2 parents 78b305a + d5e337c commit dd758a3
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 54 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
tests:
name: "Python ${{ matrix.python-version }}"
runs-on: "ubuntu-latest"
env:
USING_COVERAGE: '3.9'

strategy:
matrix:
python-version: ["3.6","3.7","3.8","3.9","pypy3"]

steps:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v2"
with:
python-version: "${{ matrix.python-version }}"
- name: "Install dependencies"
run: |
set -xe
python -VV
python -m site
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade coverage[toml] virtualenv tox tox-gh-actions
pip install -r requirements.txt
- name: "Run unit tests for tox ${{ matrix.python-version }}"
run: |
python -m tox
pip install pytest
py.test tests
# ensure Dev env works everywhere
install-dev:
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest", "macos-latest"]

name: "Verify dev env"
runs-on: "${{ matrix.os }}"
steps:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v2"
with:
python-version: "3.9"
- name: "Install in dev mode"
run: "python -m pip install -e .[dev]"
- name: "Import package"
run: "python -c 'import http_request_randomizer; print(http_request_randomizer.__version__)'"
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License

Copyright (c) 2018 Panagiotis Garefalakis http://pgaref.github.io
Copyright (c) 2020 Panagiotis Garefalakis http://pgaref.github.io

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
12 changes: 12 additions & 0 deletions http_request_randomizer/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
__author__ = 'pgaref'

__version__ = '1.2.3'

__title__ = 'http_request_randomizer'
__description__ = 'A package using public proxies to randomise http requests'
__uri__ = 'http://pgaref.com/blog/python-proxy'

__author__ = 'Panagiotis Garefalakis'
__email__ = 'pangaref@gmail.com'

__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 ' + __author__
20 changes: 10 additions & 10 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
beautifulsoup4 >= 4.6.0
coverage >= 4.5.1
httmock >= 1.2.6
psutil >= 5.4.3
pytest >= 3.4.0
pytest-cov >= 2.5.1
python-dateutil >= 2.6.1
requests >= 2.18.4
pyOpenSSL >= 17.5.0
fake-useragent >= 0.1.10
beautifulsoup4 >= 4.9.3
coverage >= 5.3
httmock >= 1.3.0
psutil >= 5.7.2
pytest >= 6.1.1
pytest-cov >= 2.10.1
python-dateutil >= 2.8.1
requests >= 2.24.0
pyOpenSSL >= 19.1.0
fake-useragent >= 0.1.11
75 changes: 52 additions & 23 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,43 @@
import codecs
import sys
import os
import re

NAME = 'http_request_randomizer'
HERE = os.path.abspath(os.path.dirname(__file__))

PROJECT_URLS = {
'Blog': 'http://pgaref.com/blog/python-proxy',
'Documentation': 'https://pythonhosted.org/http-request-randomizer',
'Source Code': 'https://github.com/pgaref/http_request_randomizer',
}

def read(*parts):
"""Return multiple read calls to different readable objects as a single
string."""
# intentionally *not* adding an encoding option to open
return codecs.open(os.path.join(HERE, *parts), 'r').read()

LONG_DESCRIPTION = read('README.rst')
try:
META_PATH = os.path.join(HERE, "http_request_randomizer", "__init__.py")
finally:
print(META_PATH)
META_FILE = read(META_PATH)

def find_meta(meta):
"""
Extract __*meta*__ from META_FILE.
"""
print(META_PATH)
meta_match = re.search(
fr"^__{meta}__ = ['\"]([^'\"]*)['\"]", META_FILE, re.M
)
if meta_match:
return meta_match.group(1)
raise RuntimeError(f"Unable to find __{ meta }__ string.")

LONG_DESCRIPTION = read('README.rst')
#########################################################################
class Tox(TestCommand):
def finalize_options(self):
TestCommand.finalize_options(self)
Expand Down Expand Up @@ -43,16 +68,18 @@ def run_tests(self):
import pytest
errno = pytest.main(self.test_args)
sys.exit(errno)


#########################################################################
setup(
name='http_request_randomizer',
version='1.2.3',
url='http://pgaref.com/blog/python-proxy',
license='MIT',
author='Panagiotis Garefalakis',
author_email='pangaref@gmail.com',
description='A package using public proxies to randomise http requests.',
name=NAME,
version=find_meta("version"),
url=find_meta("uri"),
project_urls=PROJECT_URLS,
license=find_meta("license"),
author=find_meta("author"),
author_email=find_meta("email"),
maintainer=find_meta("author"),
maintainer_email=find_meta("email"),
description=find_meta("description"),
long_description=LONG_DESCRIPTION,
packages=find_packages(exclude=['tests']),
platforms='any',
Expand All @@ -61,13 +88,13 @@ def run_tests(self):
# cmdclass={'test': Tox},
tests_require=['pytest', 'pytest-cov'],
cmdclass={'test': PyTest},
install_requires=['beautifulsoup4 >= 4.6.0',
'httmock >= 1.2.6',
'psutil >= 5.4.3',
'python-dateutil >= 2.6.1',
'requests >= 2.18.4',
'pyOpenSSL >= 17.5.0',
'fake-useragent >= 0.1.10'
install_requires=['beautifulsoup4 >= 4.9.3',
'httmock >= 1.3.0',
'psutil >= 5.7.2',
'python-dateutil >= 2.8.1',
'requests >= 2.24.0',
'pyOpenSSL >= 19.1.0',
'fake-useragent >= 0.1.11'
],
use_scm_version=True,
setup_requires=['setuptools-scm', 'pytest-runner'],
Expand All @@ -86,16 +113,18 @@ def run_tests(self):
],
},
classifiers=[
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
'Operating System :: OS Independent',
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Operating System :: OS Independent',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'Topic :: Internet :: WWW/HTTP',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Topic :: Software Development :: Libraries :: Python Modules',
],
)
38 changes: 18 additions & 20 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,38 @@
# and then run "tox" from this directory.

[tox]
envlist = py27, py3
envlist = py36, py37, py38, py39, mypy

[gh-actions]
python =
3.6: py36
3.7: py37
3.8: py38, docs
3.9: py39, lint, manifest
pypy3: pypy3

[testenv]
;commands = {envpython} setup.py test
deps =
requests
pytest
coverage
pytest-cov
setenv=
PYTHONWARNINGS=all
commands = pytest

[pytest]
adopts=--doctest-modules
addopts=--doctest-modules --ignore=setup.py
python_files=*.py
python_functions=test_
norecursedirs=.tox .git

[testenv:py27]
basepython=python2.7
commands=
py.test tests --doctest-module

[testenv:py27verbose]
basepython=python2.7
commands=
py.test tests --doctest-module --cov=. --cov-report term
norecursedirs=.tox .git .eggs

[testenv:py3]
basepython=python3
[testenv:pyDev]
basepython=python3.9
commands=
py.test tests --doctest-module
py.test tests --doctest-modules

[testenv:py3verbose]
basepython=python3
[testenv:pyDevVerbose]
basepython=python3.9
commands=
py.test tests --doctest-module --cov=. --cov-report term
py.test tests --doctest-modules --cov=. --cov-report term

0 comments on commit dd758a3

Please sign in to comment.