├── .gitignore ├── LICENSE ├── README.md ├── pdm.lock ├── pdm_shell.py └── pyproject.toml /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | 131 | # pdm 132 | .pdm.toml 133 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2022 abersheeran 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pdm-shell 2 | 3 | Use `pdm shell` set PATH and PYTHONPATH in the current shell 4 | 5 | ## Usage 6 | 7 | Run `pdm shell --memo` to get the command for the current shell. 8 | 9 | Also, you can copy `pdm shell` output to the current shell and then run it. 10 | -------------------------------------------------------------------------------- /pdm.lock: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "appdirs" 3 | version = "1.4.4" 4 | summary = "A small Python module for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." 5 | 6 | [[package]] 7 | name = "atoml" 8 | version = "1.0.3" 9 | requires_python = ">=3.6" 10 | summary = "Yet another style preserving TOML library" 11 | 12 | [[package]] 13 | name = "attrs" 14 | version = "21.2.0" 15 | requires_python = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*" 16 | summary = "Classes Without Boilerplate" 17 | 18 | [[package]] 19 | name = "cached-property" 20 | version = "1.5.2" 21 | summary = "A decorator for caching properties in classes." 22 | 23 | [[package]] 24 | name = "click" 25 | version = "8.0.1" 26 | requires_python = ">=3.6" 27 | summary = "Composable command line interface toolkit" 28 | dependencies = [ 29 | "colorama; platform_system == \"Windows\"", 30 | "importlib-metadata; python_version < \"3.8\"", 31 | ] 32 | 33 | [[package]] 34 | name = "colorama" 35 | version = "0.4.4" 36 | requires_python = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*" 37 | summary = "Cross-platform colored terminal text." 38 | 39 | [[package]] 40 | name = "importlib-metadata" 41 | version = "4.8.1" 42 | requires_python = ">=3.6" 43 | summary = "Read metadata from Python packages" 44 | dependencies = [ 45 | "typing-extensions>=3.6.4; python_version < \"3.8\"", 46 | "zipp>=0.5", 47 | ] 48 | 49 | [[package]] 50 | name = "installer" 51 | version = "0.2.3" 52 | requires_python = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*" 53 | summary = "A library for installing Python wheels." 54 | 55 | [[package]] 56 | name = "packaging" 57 | version = "21.0" 58 | requires_python = ">=3.6" 59 | summary = "Core utilities for Python packages" 60 | dependencies = [ 61 | "pyparsing>=2.0.2", 62 | ] 63 | 64 | [[package]] 65 | name = "pdm" 66 | version = "1.8.5" 67 | requires_python = ">=3.7" 68 | summary = "Python Development Master" 69 | dependencies = [ 70 | "appdirs", 71 | "atoml>=1.0.3", 72 | "click>=7", 73 | "importlib-metadata; python_version < \"3.8\"", 74 | "installer~=0.2.3", 75 | "pdm-pep517<0.9,>=0.8.3", 76 | "pep517>=0.11.0", 77 | "pip>=20.1", 78 | "python-dotenv~=0.15", 79 | "pythonfinder", 80 | "resolvelib<0.8.0,>=0.7.0", 81 | "shellingham<2.0.0,>=1.3.2", 82 | "tomli<2.0.0,>=1.1.0", 83 | "wheel<1.0.0,>=0.36.2", 84 | ] 85 | 86 | [[package]] 87 | name = "pdm-pep517" 88 | version = "0.8.4" 89 | requires_python = ">=3.6" 90 | summary = "A PEP 517 backend for PDM that supports PEP 621 metadata" 91 | 92 | [[package]] 93 | name = "pep517" 94 | version = "0.11.0" 95 | summary = "Wrappers to build Python packages using PEP 517 hooks" 96 | dependencies = [ 97 | "importlib-metadata; python_version < \"3.8\"", 98 | "tomli; python_version >= \"3.6\"", 99 | "zipp; python_version < \"3.8\"", 100 | ] 101 | 102 | [[package]] 103 | name = "pip" 104 | version = "21.2.4" 105 | requires_python = ">=3.6" 106 | summary = "The PyPA recommended tool for installing Python packages." 107 | 108 | [[package]] 109 | name = "pyparsing" 110 | version = "2.4.7" 111 | requires_python = ">=2.6,!=3.0.*,!=3.1.*,!=3.2.*" 112 | summary = "Python parsing module" 113 | 114 | [[package]] 115 | name = "python-dotenv" 116 | version = "0.19.0" 117 | requires_python = ">=3.5" 118 | summary = "Read key-value pairs from a .env file and set them as environment variables" 119 | 120 | [[package]] 121 | name = "pythonfinder" 122 | version = "1.2.8" 123 | requires_python = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*" 124 | summary = "A cross-platform python discovery tool to help locate python on any system." 125 | dependencies = [ 126 | "attrs", 127 | "cached-property", 128 | "click", 129 | "packaging", 130 | "six", 131 | ] 132 | 133 | [[package]] 134 | name = "resolvelib" 135 | version = "0.7.1" 136 | summary = "Resolve abstract dependencies into concrete ones" 137 | 138 | [[package]] 139 | name = "shellingham" 140 | version = "1.4.0" 141 | requires_python = ">=2.6,!=3.0.0,!=3.1.0,!=3.2.0,!=3.3.0" 142 | summary = "Tool to Detect Surrounding Shell" 143 | 144 | [[package]] 145 | name = "six" 146 | version = "1.16.0" 147 | requires_python = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*" 148 | summary = "Python 2 and 3 compatibility utilities" 149 | 150 | [[package]] 151 | name = "tomli" 152 | version = "1.2.1" 153 | requires_python = ">=3.6" 154 | summary = "A lil' TOML parser" 155 | 156 | [[package]] 157 | name = "typing-extensions" 158 | version = "3.10.0.2" 159 | summary = "Backported and Experimental Type Hints for Python 3.5+" 160 | 161 | [[package]] 162 | name = "wheel" 163 | version = "0.37.0" 164 | requires_python = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*" 165 | summary = "A built-package format for Python" 166 | 167 | [[package]] 168 | name = "zipp" 169 | version = "3.5.0" 170 | requires_python = ">=3.6" 171 | summary = "Backport of pathlib-compatible object wrapper for zip files" 172 | 173 | [metadata] 174 | lock_version = "3.1" 175 | content_hash = "sha256:ae41acfb0845724a6a5efce1fd643ed2c25211a06dabb52664ba2e1ea7b74110" 176 | 177 | [metadata.files] 178 | "appdirs 1.4.4" = [ 179 | {file = "appdirs-1.4.4-py2.py3-none-any.whl", hash = "sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128"}, 180 | {file = "appdirs-1.4.4.tar.gz", hash = "sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41"}, 181 | ] 182 | "atoml 1.0.3" = [ 183 | {file = "atoml-1.0.3-py3-none-any.whl", hash = "sha256:944c0e9043ca4e0729d4125132841ef1110677b8d015a624892d63cdc4988655"}, 184 | {file = "atoml-1.0.3.tar.gz", hash = "sha256:5dd70efcafde94a6aa5db2e8c6af5d832bf95b38f47d3283ee3779e920218e94"}, 185 | ] 186 | "attrs 21.2.0" = [ 187 | {file = "attrs-21.2.0-py2.py3-none-any.whl", hash = "sha256:149e90d6d8ac20db7a955ad60cf0e6881a3f20d37096140088356da6c716b0b1"}, 188 | {file = "attrs-21.2.0.tar.gz", hash = "sha256:ef6aaac3ca6cd92904cdd0d83f629a15f18053ec84e6432106f7a4d04ae4f5fb"}, 189 | ] 190 | "cached-property 1.5.2" = [ 191 | {file = "cached_property-1.5.2-py2.py3-none-any.whl", hash = "sha256:df4f613cf7ad9a588cc381aaf4a512d26265ecebd5eb9e1ba12f1319eb85a6a0"}, 192 | {file = "cached-property-1.5.2.tar.gz", hash = "sha256:9fa5755838eecbb2d234c3aa390bd80fbd3ac6b6869109bfc1b499f7bd89a130"}, 193 | ] 194 | "click 8.0.1" = [ 195 | {file = "click-8.0.1-py3-none-any.whl", hash = "sha256:fba402a4a47334742d782209a7c79bc448911afe1149d07bdabdf480b3e2f4b6"}, 196 | {file = "click-8.0.1.tar.gz", hash = "sha256:8c04c11192119b1ef78ea049e0a6f0463e4c48ef00a30160c704337586f3ad7a"}, 197 | ] 198 | "colorama 0.4.4" = [ 199 | {file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"}, 200 | {file = "colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"}, 201 | ] 202 | "importlib-metadata 4.8.1" = [ 203 | {file = "importlib_metadata-4.8.1-py3-none-any.whl", hash = "sha256:b618b6d2d5ffa2f16add5697cf57a46c76a56229b0ed1c438322e4e95645bd15"}, 204 | {file = "importlib_metadata-4.8.1.tar.gz", hash = "sha256:f284b3e11256ad1e5d03ab86bb2ccd6f5339688ff17a4d797a0fe7df326f23b1"}, 205 | ] 206 | "installer 0.2.3" = [ 207 | {file = "installer-0.2.3-py2.py3-none-any.whl", hash = "sha256:e649b9c7a454708a33a39db69f8daee515c9345020ab2fb2299d6639aad65711"}, 208 | {file = "installer-0.2.3.tar.gz", hash = "sha256:82c899f5e3c78303242df9c9ca7ac58001c9806d8c23fa2772be769d1f560fe5"}, 209 | ] 210 | "packaging 21.0" = [ 211 | {file = "packaging-21.0-py3-none-any.whl", hash = "sha256:c86254f9220d55e31cc94d69bade760f0847da8000def4dfe1c6b872fd14ff14"}, 212 | {file = "packaging-21.0.tar.gz", hash = "sha256:7dc96269f53a4ccec5c0670940a4281106dd0bb343f47b7471f779df49c2fbe7"}, 213 | ] 214 | "pdm 1.8.5" = [ 215 | {file = "pdm-1.8.5-py3-none-any.whl", hash = "sha256:54fcebc0255b59daaadf75ca77490ab55e91362176ff5629b475b0d9632db926"}, 216 | {file = "pdm-1.8.5.tar.gz", hash = "sha256:91c50a792b0af21c6e8b82c344281b4ce7e1f518010c362bee6a4b7434b5b97e"}, 217 | ] 218 | "pdm-pep517 0.8.4" = [ 219 | {file = "pdm_pep517-0.8.4-py3-none-any.whl", hash = "sha256:06a126d8c705d72e788899d46685ffa990b5809e6a5164519ee102bbdb961b27"}, 220 | {file = "pdm-pep517-0.8.4.tar.gz", hash = "sha256:2331c038bc53e1033c7114b15581cde90c5a6d79af6c5665fa9d2eb8f7702756"}, 221 | ] 222 | "pep517 0.11.0" = [ 223 | {file = "pep517-0.11.0-py2.py3-none-any.whl", hash = "sha256:3fa6b85b9def7ba4de99fb7f96fe3f02e2d630df8aa2720a5cf3b183f087a738"}, 224 | {file = "pep517-0.11.0.tar.gz", hash = "sha256:e1ba5dffa3a131387979a68ff3e391ac7d645be409216b961bc2efe6468ab0b2"}, 225 | ] 226 | "pip 21.2.4" = [ 227 | {file = "pip-21.2.4-py3-none-any.whl", hash = "sha256:fa9ebb85d3fd607617c0c44aca302b1b45d87f9c2a1649b46c26167ca4296323"}, 228 | {file = "pip-21.2.4.tar.gz", hash = "sha256:0eb8a1516c3d138ae8689c0c1a60fde7143310832f9dc77e11d8a4bc62de193b"}, 229 | ] 230 | "pyparsing 2.4.7" = [ 231 | {file = "pyparsing-2.4.7-py2.py3-none-any.whl", hash = "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b"}, 232 | {file = "pyparsing-2.4.7.tar.gz", hash = "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1"}, 233 | ] 234 | "python-dotenv 0.19.0" = [ 235 | {file = "python_dotenv-0.19.0-py2.py3-none-any.whl", hash = "sha256:aae25dc1ebe97c420f50b81fb0e5c949659af713f31fdb63c749ca68748f34b1"}, 236 | {file = "python-dotenv-0.19.0.tar.gz", hash = "sha256:f521bc2ac9a8e03c736f62911605c5d83970021e3fa95b37d769e2bbbe9b6172"}, 237 | ] 238 | "pythonfinder 1.2.8" = [ 239 | {file = "pythonfinder-1.2.8-py2.py3-none-any.whl", hash = "sha256:96815a069dfc4c265b0900fcb02d7b7b0bd8d788d2fb5090051af9ec33920252"}, 240 | {file = "pythonfinder-1.2.8.tar.gz", hash = "sha256:e3ea90d327f2ff61a692af9326deced042bb27f6fd562fc788637abee9bd62d9"}, 241 | ] 242 | "resolvelib 0.7.1" = [ 243 | {file = "resolvelib-0.7.1-py2.py3-none-any.whl", hash = "sha256:4bb1e7ec9b3054c3914cad1e715288b11091756bdb72af49fb8986931715a01a"}, 244 | {file = "resolvelib-0.7.1.tar.gz", hash = "sha256:c526cda7f080d908846262d86c738231d9bfb556eb02d77167b685d65d85ace9"}, 245 | ] 246 | "shellingham 1.4.0" = [ 247 | {file = "shellingham-1.4.0-py2.py3-none-any.whl", hash = "sha256:536b67a0697f2e4af32ab176c00a50ac2899c5a05e0d8e2dadac8e58888283f9"}, 248 | {file = "shellingham-1.4.0.tar.gz", hash = "sha256:4855c2458d6904829bd34c299f11fdeed7cfefbf8a2c522e4caea6cd76b3171e"}, 249 | ] 250 | "six 1.16.0" = [ 251 | {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, 252 | {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, 253 | ] 254 | "tomli 1.2.1" = [ 255 | {file = "tomli-1.2.1-py3-none-any.whl", hash = "sha256:8dd0e9524d6f386271a36b41dbf6c57d8e32fd96fd22b6584679dc569d20899f"}, 256 | {file = "tomli-1.2.1.tar.gz", hash = "sha256:a5b75cb6f3968abb47af1b40c1819dc519ea82bcc065776a866e8d74c5ca9442"}, 257 | ] 258 | "typing-extensions 3.10.0.2" = [ 259 | {file = "typing_extensions-3.10.0.2-py2-none-any.whl", hash = "sha256:d8226d10bc02a29bcc81df19a26e56a9647f8b0a6d4a83924139f4a8b01f17b7"}, 260 | {file = "typing_extensions-3.10.0.2-py3-none-any.whl", hash = "sha256:f1d25edafde516b146ecd0613dabcc61409817af4766fbbcfb8d1ad4ec441a34"}, 261 | {file = "typing_extensions-3.10.0.2.tar.gz", hash = "sha256:49f75d16ff11f1cd258e1b988ccff82a3ca5570217d7ad8c5f48205dd99a677e"}, 262 | ] 263 | "wheel 0.37.0" = [ 264 | {file = "wheel-0.37.0-py2.py3-none-any.whl", hash = "sha256:21014b2bd93c6d0034b6ba5d35e4eb284340e09d63c59aef6fc14b0f346146fd"}, 265 | {file = "wheel-0.37.0.tar.gz", hash = "sha256:e2ef7239991699e3355d54f8e968a21bb940a1dbf34a4d226741e64462516fad"}, 266 | ] 267 | "zipp 3.5.0" = [ 268 | {file = "zipp-3.5.0-py3-none-any.whl", hash = "sha256:957cfda87797e389580cb8b9e3870841ca991e2125350677b2ca83a0e99390a3"}, 269 | {file = "zipp-3.5.0.tar.gz", hash = "sha256:f5812b1e007e48cff63449a5e9f4e7ebea716b4111f9c4f9a645f91d579bf0c4"}, 270 | ] 271 | -------------------------------------------------------------------------------- /pdm_shell.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import os 3 | 4 | from pdm.cli.commands.base import BaseCommand, Project 5 | 6 | 7 | class ShellCommand(BaseCommand): 8 | """Set PATH and PYTHONPATH in the current shell""" 9 | 10 | def add_arguments(self, parser: argparse.ArgumentParser) -> None: 11 | parser.add_argument( 12 | "--memo", help="Print command to execute", action="store_true" 13 | ) 14 | 15 | def handle(self, project: Project, options: argparse.Namespace) -> None: 16 | """The command handler function. 17 | 18 | :param project: the pdm project instance 19 | :param options: the parsed Namespace object 20 | """ 21 | import shellingham 22 | 23 | shell, executeable = shellingham.detect_shell() 24 | shell = shell.lower() 25 | 26 | if options.memo: 27 | if shell in ("bash", "zsh", "fish", "csh", "tcsh"): 28 | self.output("eval $(pdm shell)") 29 | elif shell == "pwsh": 30 | self.output("pdm shell | Invoke-Expression") 31 | else: 32 | raise NotImplementedError(f"Shell {shell} is not supported") 33 | else: 34 | if shell in ("bash", "zsh"): 35 | self.output( 36 | "export PATH=$(pdm info --packages)/bin:$PATH" 37 | " && export PYTHONPATH=$(pdm info --packages)/lib:$PYTHONPATH" 38 | ) 39 | elif shell == "fish": 40 | self.output( 41 | "set -x PATH $(pdm info --packages)/bin $PATH" 42 | " && set -x PYTHONPATH $(pdm info --packages)/lib $PYTHONPATH" 43 | ) 44 | elif shell in ("csh", "tcsh"): 45 | self.output( 46 | "setenv PATH $(pdm info --packages)/bin:$PATH" 47 | " && setenv PYTHONPATH $(pdm info --packages)/lib:$PYTHONPATH" 48 | ) 49 | elif shell == "pwsh": 50 | split = ";" if os.name == "nt" else ":" 51 | bin_dir = "Scripts" if os.name == "nt" else "bin" 52 | self.output( 53 | f"Set-Item -Path Env:Path -Value ((Join-Path $(pdm info --packages) '{bin_dir}') + '{split}' + $env:PATH)" 54 | f" && Set-Item -Path Env:PYTHONPATH -Value ((Join-Path $(pdm info --packages) 'lib') + '{split}' + $env:PYTHONPATH)" 55 | ) 56 | else: 57 | raise NotImplementedError(f"Shell {shell} is not supported") 58 | 59 | def output(self, command: str) -> None: 60 | print(command, flush=True) 61 | 62 | 63 | def shell(core): 64 | core.register_command(ShellCommand, "shell") 65 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | authors = [ 3 | {name = "abersheeran", email = "me@abersheeran.com"}, 4 | ] 5 | dependencies = [ 6 | "pdm>=1.8", 7 | ] 8 | description = "Use `pdm shell` set PATH and PYTHONPATH in the current shell" 9 | license = {text = "Apache2.0"} 10 | name = "pdm-shell" 11 | requires-python = ">=3.7" 12 | version = "1.1.0" 13 | 14 | [project.urls] 15 | homepage = "https://github.com/abersheeran/pdm-shell" 16 | 17 | [project.entry-points.pdm] 18 | shell = "pdm_shell:shell" 19 | 20 | [build-system] 21 | build-backend = "pdm.pep517.api" 22 | requires = ["pdm-pep517"] 23 | --------------------------------------------------------------------------------