1+ #!/usr/bin/env python3
2+ # -*- coding: utf-8 -*-
3+ # setup.py
4+
5+ # requirements:
6+ # python -m pip install wheel setuptools
7+
8+ # Usage:
9+ # python setup.py create
10+
11+ # install wheel
12+ # python -m pip install --force-reinstall ./dist/*.whl
13+
14+ # unittest
15+ # python -m unittest discover --catch --verbose
16+
17+ import io
18+ import os
19+ import sys
20+ from shutil import rmtree
21+
22+ from setuptools import find_packages , setup , Command
23+
24+ """ Project structure
25+ . # project directory
26+ ├── <your Python project> # name of your project
27+ │ ├── __init__.py # indicates to Python this is a package
28+ │ ├── __version__.py # optional
29+ │ ├── <project code>.py
30+ │ └── ...
31+ ├── doc
32+ | └── ...
33+ ├── test
34+ │ └── <test_project code>.py # create a test
35+ │ └── ...
36+ ├── LICENSE.txt
37+ ├── MANIFEST.in
38+ ├── pyproject.toml
39+ ├── README.md # good description of the project
40+ └── setup.py # this file
41+ """
42+
43+ # Package meta-data.
44+ NAME = 'playwright-apirequest-builder'
45+ DESCRIPTION = 'Playwright APIRequest builder'
46+ URL = 'https://github.com/w13b3/playwright-apirequest-builder'
47+ EMAIL = 'wiebe at email dot com' # prevent warning 'missing meta-data'
48+ AUTHOR = 'Wiebe'
49+ REQUIRES_PYTHON = '>=3.8.0, <4'
50+ VERSION = 'GIT' # change this
51+ # If you do change the License, remember to change the Trove Classifier for that!
52+ LICENSE = "Mozilla Public License Version 2.0"
53+
54+ # If your package is a single module, use this instead of 'packages':
55+ PY_MODULES = [
56+ 'playwright_request'
57+ ]
58+
59+ # What packages are required for this module to be executed?
60+ REQUIRED = [
61+ "playwright>=1.26.0"
62+ ]
63+
64+ # What packages are optional?
65+ EXTRAS = {
66+ # None
67+ }
68+
69+ # Trove Classifiers
70+ CLASSIFIERS = [ # https://pypi.org/classifiers/
71+ "Development Status :: 5 - Production/Stable" ,
72+ "License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)" ,
73+ "Operating System :: OS Independent" ,
74+ "Programming Language :: Python" ,
75+ "Programming Language :: Python :: 3" ,
76+ "Programming Language :: Python :: 3.8" ,
77+ "Programming Language :: Python :: 3.9" ,
78+ "Programming Language :: Python :: 3.10" ,
79+ "Programming Language :: Python :: 3.11" ,
80+ "Programming Language :: Python :: 3.12" ,
81+ "Programming Language :: Python :: 3 :: Only" ,
82+ "Typing :: Typed" ,
83+ "Intended Audience :: Developers" ,
84+ "Topic :: Software Development" ,
85+ "Topic :: Software Development :: Build Tools" ,
86+ "Topic :: Software Development :: Libraries :: Python Modules" ,
87+ ]
88+ keywords = [
89+ "builder" ,
90+ "builder-pattern" ,
91+ "web-request" ,
92+ "playwright" ,
93+ "playwright-api" ,
94+ "playwright-python"
95+ ]
96+
97+ if not bool (VERSION ) and len (VERSION ) <= 0 :
98+ raise Exception ("Forgot to change the version" )
99+
100+ here = os .path .abspath (os .path .dirname (__file__ ))
101+
102+ # Import the README and use it as the long-description.
103+ # Note: this will only work if 'README.md' is present in your MANIFEST.in file!
104+ try :
105+ with io .open (os .path .join (here , 'README.md' ), encoding = 'utf-8' ) as f :
106+ long_description = '\n ' + f .read ()
107+ except FileNotFoundError :
108+ long_description = DESCRIPTION
109+
110+
111+ class CreateCommand (Command ):
112+ """Support setup.py create."""
113+
114+ description = 'Build and publish the package.'
115+ user_options = []
116+
117+ @staticmethod
118+ def status (s ):
119+ """Prints things in bold."""
120+ print ('\033 [1m{0}\033 [0m' .format (s ))
121+
122+ def initialize_options (self ):
123+ pass
124+
125+ def finalize_options (self ):
126+ pass
127+
128+ def run (self ):
129+ try :
130+ self .status ('Removing previous builds…' )
131+ rmtree (os .path .join (here , 'dist' ))
132+ except OSError :
133+ pass
134+
135+ self .status ('Building Source and Wheel (universal) distribution…\n ' )
136+ os .system ('{0} setup.py sdist bdist_wheel --universal' .format (sys .executable ))
137+ self .status ("\n Ready to upload to PyPI." )
138+ sys .exit ()
139+
140+
141+ setup (
142+ name = NAME ,
143+ version = VERSION ,
144+ description = DESCRIPTION ,
145+ long_description = long_description ,
146+ long_description_content_type = 'text/markdown' ,
147+ author = AUTHOR ,
148+ author_email = EMAIL ,
149+ python_requires = REQUIRES_PYTHON ,
150+ url = URL ,
151+ packages = find_packages (exclude = [
152+ "test" , "*.test" , "*.test.*" , "test.*" ,
153+ "tests" , "*.tests" , "*.tests.*" , "tests.*" ,
154+ "doc" , "*.doc" , "*.doc.*" , "doc.*" ,
155+ ]),
156+ py_modules = PY_MODULES ,
157+ # entry_points={
158+ # 'console_scripts': ['mycli=mymodule:cli'],
159+ # },
160+ install_requires = REQUIRED ,
161+ extras_require = EXTRAS ,
162+ include_package_data = True ,
163+ license = LICENSE ,
164+ classifiers = CLASSIFIERS ,
165+ # $ setup.py create support.
166+ cmdclass = {
167+ 'create' : CreateCommand ,
168+ },
169+ )
0 commit comments