├── MANIFEST.in ├── reciprocal_tariff ├── __main__.py └── __init__.py ├── example.py ├── README.md ├── setup.py ├── LICENSE └── .gitignore /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README.md 2 | include LICENSE -------------------------------------------------------------------------------- /reciprocal_tariff/__main__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Main entry point for the tariff package. 3 | """ 4 | 5 | if __name__ == "__main__": 6 | print("Tremendous") -------------------------------------------------------------------------------- /example.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """ 3 | Example usage of the tariff package. 4 | """ 5 | 6 | import tariff 7 | 8 | print("Setting tariffs on packages...") 9 | tariff.set({ 10 | "time": 50, # 50% tariff 11 | "os": 100, # 100% tariff 12 | "sys": 200 # 200% tariff 13 | }) 14 | 15 | print("\nImporting packages with tariffs:") 16 | import time 17 | import os 18 | import sys 19 | 20 | print("\nImporting a package without tariffs:") 21 | import json 22 | 23 | print("\nDemo completed! Make importing great again! 🇺🇸") -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## About 2 | 3 | This is a clone of tariff project for reciprocal purpose. 4 | This is about making the importing of tariff equally painful 5 | 6 | 7 | ## Installation 8 | 9 | ```bash 10 | pip install reciprocal-tariff 11 | ``` 12 | 13 | ## Usage 14 | 15 | ```python 16 | import reciprocal_tariff 17 | 18 | # Now when you import tariff package, they'll be TARIFFED! 19 | import tariff # This will be 100% slower 20 | ``` 21 | 22 | ## How It Works 23 | 24 | When you import a package that has a tariff: 25 | 1. TARIFF measures how long the original import takes 26 | 2. TARIFF makes the import take longer based on your tariff percentage 27 | 3. TARIFF announces the tariff with a TREMENDOUS message 28 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | 3 | with open("README.md", "r", encoding="utf-8") as fh: 4 | long_description = fh.read() 5 | 6 | setup( 7 | name="reciprocal-tariff", 8 | version="1.0.0", 9 | author="Python Anti-Economist", 10 | author_email="james@lin.net.nz", 11 | description="Make importing shit again! A parody package that imposes tariffs on tariff imports.", 12 | long_description=long_description, 13 | long_description_content_type="text/markdown", 14 | url="https://github.com/variable/reciprocal-tariff", 15 | packages=find_packages(), 16 | classifiers=[ 17 | "Programming Language :: Python :: 3", 18 | "License :: OSI Approved :: MIT License", 19 | "Operating System :: OS Independent", 20 | "Development Status :: 3 - Alpha", 21 | "Intended Audience :: Developers", 22 | "Topic :: Software Development :: Libraries :: Python Modules", 23 | "Topic :: Utilities", 24 | ], 25 | python_requires=">=3.6", 26 | keywords="import, tariff, parody, monkey-patch", 27 | ) -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Tariff Package Contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /reciprocal_tariff/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | 🇺🇸 TARIFF 🇺🇸 - Make importing great again! 3 | """ 4 | 5 | import sys 6 | import time 7 | import builtins 8 | import importlib 9 | import random 10 | 11 | # Store the original import function 12 | original_import = builtins.__import__ 13 | 14 | # Global tariff sheet 15 | _tariff_sheet = {} 16 | 17 | # List of Trump-like phrases 18 | _trump_phrases = [ 19 | "American packages are WINNING AGAIN!", 20 | "We're bringing back JOBS to our codebase!", 21 | "This is how we get FAIR TRADE in Python!", 22 | "Big win for AMERICAN programmers!", 23 | "No more BAD DEALS with foreign packages!", 24 | "Making Programming Great Again!", 25 | "Believe me, this is the BEST tariff!", 26 | "We're going to win SO MUCH, you'll get tired of winning!", 27 | "This is how we Keep America Coding Again!", 28 | "HUGE success!" 29 | ] 30 | 31 | def _get_trump_phrase(): 32 | """Get a random Trump-like phrase.""" 33 | return random.choice(_trump_phrases) 34 | 35 | def tariff_set(tariff_sheet): 36 | """ 37 | Set tariff rates for packages. 38 | 39 | Args: 40 | tariff_sheet (dict): Dictionary mapping package names to tariff percentages. 41 | e.g., {"numpy": 50, "pandas": 200} 42 | """ 43 | global _tariff_sheet 44 | _tariff_sheet = tariff_sheet 45 | 46 | # Only patch the import once 47 | if builtins.__import__ is not original_import: 48 | return 49 | 50 | # Replace the built-in import with our custom version 51 | builtins.__import__ = _tariffed_import 52 | 53 | def _tariffed_import(name, globals=None, locals=None, fromlist=(), level=0): 54 | """Custom import function that applies tariffs.""" 55 | # Check if the package is in our tariff sheet 56 | base_package = name.split('.')[0] 57 | tariff_rate = _tariff_sheet.get(base_package) 58 | 59 | # Measure import time 60 | start_time = time.time() 61 | module = original_import(name, globals, locals, fromlist, level) 62 | original_import_time = (time.time() - start_time) * 1000000 # convert to microseconds 63 | 64 | # Apply tariff if applicable 65 | if tariff_rate is not None: 66 | # Calculate sleep time based on tariff rate 67 | sleep_time = original_import_time * (tariff_rate / 100) 68 | time.sleep(sleep_time / 1000000) # convert back to seconds 69 | 70 | # Calculate new total time 71 | new_total_time = original_import_time + sleep_time 72 | 73 | # Print tariff announcement in Trump style 74 | print(f"JUST IMPOSED a {tariff_rate}% TARIFF on {base_package}! Original import took {int(original_import_time)} us, " 75 | f"now takes {int(new_total_time)} us. {_get_trump_phrase()}") 76 | 77 | return module 78 | 79 | tariff_set({ 80 | "tariff": 100, # 50% tariff on tariff 81 | }) -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Project Specific ## 2 | mailbox_attachments/ 3 | static/bundles/ 4 | static/tinymce/ 5 | webpack-stats.json 6 | tigerpaw_webui_settings.json 7 | local_settings.json 8 | settings.json 9 | 10 | ## Django ### 11 | *.log 12 | *.pot 13 | *.pyc 14 | __pycache__/ 15 | local_settings.py 16 | local_settings.json 17 | db.sqlite3 18 | media 19 | 20 | # If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/ 21 | # in your Git repository. Update and uncomment the following line accordingly. 22 | # /staticfiles/ 23 | 24 | ### Linux ### 25 | *~ 26 | 27 | # temporary files which can be created if a process still has a handle open of a deleted file 28 | .fuse_hidden* 29 | 30 | # KDE directory preferences 31 | .directory 32 | 33 | # Linux trash folder which might appear on any partition or disk 34 | .Trash-* 35 | 36 | # .nfs files are created when an open file is removed but is still being accessed 37 | .nfs* 38 | 39 | ### macOS ### 40 | *.DS_Store 41 | .AppleDouble 42 | .LSOverride 43 | 44 | # Icon must end with two \r 45 | Icon 46 | 47 | # Thumbnails 48 | ._* 49 | 50 | # Files that might appear in the root of a volume 51 | .DocumentRevisions-V100 52 | .fseventsd 53 | .Spotlight-V100 54 | .TemporaryItems 55 | .Trashes 56 | .VolumeIcon.icns 57 | .com.apple.timemachine.donotpresent 58 | 59 | # Directories potentially created on remote AFP share 60 | .AppleDB 61 | .AppleDesktop 62 | Network Trash Folder 63 | Temporary Items 64 | .apdisk 65 | 66 | ### Node ### 67 | # Logs 68 | logs 69 | npm-debug.log* 70 | yarn-debug.log* 71 | yarn-error.log* 72 | 73 | # Runtime data 74 | pids 75 | *.pid 76 | *.seed 77 | *.pid.lock 78 | 79 | # Directory for instrumented libs generated by jscoverage/JSCover 80 | lib-cov 81 | 82 | # Coverage directory used by tools like istanbul 83 | coverage 84 | 85 | # nyc test coverage 86 | .nyc_output 87 | 88 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 89 | .grunt 90 | 91 | # Bower dependency directory (https://bower.io/) 92 | bower_components 93 | 94 | # node-waf configuration 95 | .lock-wscript 96 | 97 | # Compiled binary addons (http://nodejs.org/api/addons.html) 98 | build/Release 99 | 100 | # Dependency directories 101 | node_modules/ 102 | jspm_packages/ 103 | 104 | # Typescript v1 declaration files 105 | typings/ 106 | 107 | # Optional npm cache directory 108 | .npm 109 | 110 | # Optional eslint cache 111 | .eslintcache 112 | 113 | # Optional REPL history 114 | .node_repl_history 115 | 116 | # Output of 'npm pack' 117 | *.tgz 118 | 119 | # Yarn Integrity file 120 | .yarn-integrity 121 | 122 | # dotenv environment variables file 123 | .env 124 | .env_test 125 | 126 | 127 | ### PyCharm ### 128 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 129 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 130 | 131 | # User-specific stuff: 132 | 133 | .idea 134 | .idea/**/workspace.xml 135 | .idea/**/tasks.xml 136 | .idea/dictionaries 137 | .idea 138 | 139 | # Sensitive or high-churn files: 140 | .idea/**/dataSources/ 141 | .idea/**/dataSources.ids 142 | .idea/**/dataSources.xml 143 | .idea/**/dataSources.local.xml 144 | .idea/**/sqlDataSources.xml 145 | .idea/**/dynamic.xml 146 | .idea/**/uiDesigner.xml 147 | 148 | # Gradle: 149 | .idea/**/gradle.xml 150 | .idea/**/libraries 151 | 152 | # CMake 153 | cmake-build-debug/ 154 | 155 | ## File-based project format: 156 | *.iws 157 | 158 | ## Plugin-specific files: 159 | 160 | # IntelliJ 161 | /out/ 162 | 163 | # mpeltonen/sbt-idea plugin 164 | .idea_modules/ 165 | 166 | # JIRA plugin 167 | atlassian-ide-plugin.xml 168 | 169 | # Cursive Clojure plugin 170 | .idea/replstate.xml 171 | 172 | # Ruby plugin and RubyMine 173 | /.rakeTasks 174 | 175 | # Crashlytics plugin (for Android Studio and IntelliJ) 176 | com_crashlytics_export_strings.xml 177 | crashlytics.properties 178 | crashlytics-build.properties 179 | fabric.properties 180 | 181 | ### PyCharm Patch ### 182 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 183 | 184 | # *.iml 185 | # modules.xml 186 | # .idea/misc.xml 187 | # *.ipr 188 | 189 | # Sonarlint plugin 190 | .idea/sonarlint 191 | 192 | ### Python ### 193 | # Byte-compiled / optimized / DLL files 194 | *.py[cod] 195 | *$py.class 196 | 197 | # C extensions 198 | *.so 199 | 200 | # Distribution / packaging 201 | .Python 202 | build/ 203 | develop-eggs/ 204 | dist/ 205 | downloads/ 206 | eggs/ 207 | .eggs/ 208 | #lib/ 209 | lib64/ 210 | parts/ 211 | sdist/ 212 | var/ 213 | wheels/ 214 | *.egg-info/ 215 | .installed.cfg 216 | *.egg 217 | 218 | # PyInstaller 219 | # Usually these files are written by a python script from a template 220 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 221 | *.manifest 222 | *.spec 223 | 224 | # Installer logs 225 | pip-log.txt 226 | pip-delete-this-directory.txt 227 | 228 | # Unit test / coverage reports 229 | htmlcov/ 230 | .tox/ 231 | .coverage 232 | .coverage.* 233 | .cache 234 | nosetests.xml 235 | coverage.xml 236 | *.cover 237 | .hypothesis/ 238 | 239 | # Translations 240 | *.mo 241 | 242 | # Django stuff: 243 | 244 | # Flask stuff: 245 | instance/ 246 | .webassets-cache 247 | 248 | # Scrapy stuff: 249 | .scrapy 250 | 251 | # Sphinx documentation 252 | docs/_build/ 253 | 254 | # PyBuilder 255 | target/ 256 | 257 | # Jupyter Notebook 258 | .ipynb_checkpoints 259 | 260 | # pyenv 261 | .python-version 262 | 263 | # celery beat schedule file 264 | celerybeat-schedule.* 265 | 266 | # SageMath parsed files 267 | *.sage.py 268 | 269 | # Environments 270 | .venv 271 | env/ 272 | venv/ 273 | ENV/ 274 | env.bak/ 275 | venv.bak/ 276 | 277 | # Spyder project settings 278 | .spyderproject 279 | .spyproject 280 | 281 | # Rope project settings 282 | .ropeproject 283 | 284 | # mkdocs documentation 285 | /site 286 | 287 | # mypy 288 | .mypy_cache/ 289 | 290 | ### Vagrant ### 291 | .vagrant/ 292 | *.box 293 | 294 | ### Windows ### 295 | # Windows thumbnail cache files 296 | Thumbs.db 297 | ehthumbs.db 298 | ehthumbs_vista.db 299 | 300 | # Folder config file 301 | Desktop.ini 302 | 303 | # Recycle Bin used on file shares 304 | $RECYCLE.BIN/ 305 | 306 | # Windows Installer files 307 | *.cab 308 | *.msi 309 | *.msm 310 | *.msp 311 | 312 | # Windows shortcuts 313 | *.lnk 314 | --------------------------------------------------------------------------------