From 051e6bf754c10c31cce49ff5b3669f67e09cede6 Mon Sep 17 00:00:00 2001 From: otherjake Date: Thu, 28 Jul 2022 14:49:46 -0400 Subject: [PATCH 1/7] Check environment variable PIPENV_CUSTOM_VENV_NAME Resolves #1226 --- pipenv/project.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pipenv/project.py b/pipenv/project.py index 951ca018e2..20685fdd18 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -364,6 +364,9 @@ def get_name(name, location): @property def virtualenv_name(self) -> str: + custom_name = os.getenv("PIPENV_CUSTOM_VENV_NAME") + if custom_name: + return custom_name sanitized, encoded_hash = self._get_virtualenv_hash(self.name) suffix = "" if self.s.PIPENV_PYTHON: From 7ed8ab2f4f827a6eb1c361019f2798ec8cf6f849 Mon Sep 17 00:00:00 2001 From: otherjake Date: Tue, 2 Aug 2022 12:00:02 -0400 Subject: [PATCH 2/7] Support PIPENV_CUSTOM_VENV_NAME from environments in the same way as other environment variables. Update documentation to include the new variable. --- Pipfile.lock | 180 ++++++++++++++++++++--------------------- docs/advanced.rst | 4 + pipenv/environments.py | 3 + pipenv/project.py | 2 +- 4 files changed, 98 insertions(+), 91 deletions(-) diff --git a/Pipfile.lock b/Pipfile.lock index 264b9892ac..3cfcaeee35 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -39,18 +39,18 @@ }, "attrs": { "hashes": [ - "sha256:2d27e3784d7a565d36ab851fe94887c5eccd6a463168875832a1be79c82828b4", - "sha256:626ba8234211db98e869df76230a137c4c40a12d72445c45d5f5b716f076e2fd" + "sha256:29adc2665447e5191d0e7c568fde78b21f9672d344281d0c6e1ab085429b22b6", + "sha256:86efa402f67bf2df34f51a335487cf46b1ec130d02b8d39fd248abfd30da551c" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", - "version": "==21.4.0" + "markers": "python_version >= '3.5'", + "version": "==22.1.0" }, "babel": { "hashes": [ "sha256:7614553711ee97490f732126dc077f8d0ae084ebc6a96e23db1482afabdb2c51", "sha256:ff56f4892c1c4bf0d814575ea23471c230d544203c7748e8c68f0089478d48eb" ], - "markers": "python_full_version >= '3.6.0'", + "markers": "python_version >= '3.6'", "version": "==2.10.3" }, "beautifulsoup4": { @@ -58,7 +58,7 @@ "sha256:58d5c3d29f5a36ffeb94f02f0d786cd53014cf9b3b3951d42e0080d8a9498d30", "sha256:ad9aa55b65ef2808eb405f46cf74df7fcb7044d5cbc26487f96eb2ef2e436693" ], - "markers": "python_full_version >= '3.6.0'", + "markers": "python_version >= '3.6'", "version": "==4.11.1" }, "black": { @@ -101,7 +101,7 @@ "sha256:84c85a9078b11105f04f3036a9482ae10e4621616db313fe045dd24743a0820d", "sha256:fe86415d55e84719d75f8b69414f6438ac3547d2078ab91b67e779ef69378412" ], - "markers": "python_full_version >= '3.6.0'", + "markers": "python_version >= '3.6'", "version": "==2022.6.15" }, "cfgv": { @@ -117,7 +117,7 @@ "sha256:5189b6f22b01957427f35b6a08d9a0bc45b46d3788ef5a92e978433c7a35f8a5", "sha256:575e708016ff3a5e3681541cb9d79312c416835686d054a23accb873b254f413" ], - "markers": "python_full_version >= '3.6.0'", + "markers": "python_version >= '3.6'", "version": "==2.1.0" }, "click": { @@ -139,7 +139,7 @@ "sha256:854bf444933e37f5824ae7bfc1e98d5bce2ebe4160d46b5edf346a89358e99da", "sha256:e6c6b4334fc50988a639d9b98aa429a0b57da6e17b9a44f0451f930b6967b7a4" ], - "markers": "sys_platform == 'win32'", + "markers": "platform_system == 'Windows'", "version": "==0.4.5" }, "coverage": { @@ -147,57 +147,57 @@ "toml" ], "hashes": [ - "sha256:01c5615d13f3dd3aa8543afc069e5319cfa0c7d712f6e04b920431e5c564a749", - "sha256:106c16dfe494de3193ec55cac9640dd039b66e196e4641fa8ac396181578b982", - "sha256:129cd05ba6f0d08a766d942a9ed4b29283aff7b2cccf5b7ce279d50796860bb3", - "sha256:145f296d00441ca703a659e8f3eb48ae39fb083baba2d7ce4482fb2723e050d9", - "sha256:1480ff858b4113db2718848d7b2d1b75bc79895a9c22e76a221b9d8d62496428", - "sha256:269eaa2c20a13a5bf17558d4dc91a8d078c4fa1872f25303dddcbba3a813085e", - "sha256:26dff09fb0d82693ba9e6231248641d60ba606150d02ed45110f9ec26404ed1c", - "sha256:2bd9a6fc18aab8d2e18f89b7ff91c0f34ff4d5e0ba0b33e989b3cd4194c81fd9", - "sha256:309ce4a522ed5fca432af4ebe0f32b21d6d7ccbb0f5fcc99290e71feba67c264", - "sha256:3384f2a3652cef289e38100f2d037956194a837221edd520a7ee5b42d00cc605", - "sha256:342d4aefd1c3e7f620a13f4fe563154d808b69cccef415415aece4c786665397", - "sha256:39ee53946bf009788108b4dd2894bf1349b4e0ca18c2016ffa7d26ce46b8f10d", - "sha256:4321f075095a096e70aff1d002030ee612b65a205a0a0f5b815280d5dc58100c", - "sha256:4803e7ccf93230accb928f3a68f00ffa80a88213af98ed338a57ad021ef06815", - "sha256:4ce1b258493cbf8aec43e9b50d89982346b98e9ffdfaae8ae5793bc112fb0068", - "sha256:664a47ce62fe4bef9e2d2c430306e1428ecea207ffd68649e3b942fa8ea83b0b", - "sha256:75ab269400706fab15981fd4bd5080c56bd5cc07c3bccb86aab5e1d5a88dc8f4", - "sha256:83c4e737f60c6936460c5be330d296dd5b48b3963f48634c53b3f7deb0f34ec4", - "sha256:84631e81dd053e8a0d4967cedab6db94345f1c36107c71698f746cb2636c63e3", - "sha256:84e65ef149028516c6d64461b95a8dbcfce95cfd5b9eb634320596173332ea84", - "sha256:865d69ae811a392f4d06bde506d531f6a28a00af36f5c8649684a9e5e4a85c83", - "sha256:87f4f3df85aa39da00fd3ec4b5abeb7407e82b68c7c5ad181308b0e2526da5d4", - "sha256:8c08da0bd238f2970230c2a0d28ff0e99961598cb2e810245d7fc5afcf1254e8", - "sha256:961e2fb0680b4f5ad63234e0bf55dfb90d302740ae9c7ed0120677a94a1590cb", - "sha256:9b3e07152b4563722be523e8cd0b209e0d1a373022cfbde395ebb6575bf6790d", - "sha256:a7f3049243783df2e6cc6deafc49ea123522b59f464831476d3d1448e30d72df", - "sha256:bf5601c33213d3cb19d17a796f8a14a9eaa5e87629a53979a5981e3e3ae166f6", - "sha256:cec3a0f75c8f1031825e19cd86ee787e87cf03e4fd2865c79c057092e69e3a3b", - "sha256:d42c549a8f41dc103a8004b9f0c433e2086add8a719da00e246e17cbe4056f72", - "sha256:d67d44996140af8b84284e5e7d398e589574b376fb4de8ccd28d82ad8e3bea13", - "sha256:d9c80df769f5ec05ad21ea34be7458d1dc51ff1fb4b2219e77fe24edf462d6df", - "sha256:e57816f8ffe46b1df8f12e1b348f06d164fd5219beba7d9433ba79608ef011cc", - "sha256:ee2ddcac99b2d2aec413e36d7a429ae9ebcadf912946b13ffa88e7d4c9b712d6", - "sha256:f02cbbf8119db68455b9d763f2f8737bb7db7e43720afa07d8eb1604e5c5ae28", - "sha256:f1d5aa2703e1dab4ae6cf416eb0095304f49d004c39e9db1d86f57924f43006b", - "sha256:f5b66caa62922531059bc5ac04f836860412f7f88d38a476eda0a6f11d4724f4", - "sha256:f69718750eaae75efe506406c490d6fc5a6161d047206cc63ce25527e8a3adad", - "sha256:fb73e0011b8793c053bfa85e53129ba5f0250fdc0392c1591fd35d915ec75c46", - "sha256:fd180ed867e289964404051a958f7cccabdeed423f91a899829264bb7974d3d3", - "sha256:fdb6f7bd51c2d1714cea40718f6149ad9be6a2ee7d93b19e9f00934c0f2a74d9", - "sha256:ffa9297c3a453fba4717d06df579af42ab9a28022444cae7fa605af4df612d54" + "sha256:0895ea6e6f7f9939166cc835df8fa4599e2d9b759b02d1521b574e13b859ac32", + "sha256:0f211df2cba951ffcae210ee00e54921ab42e2b64e0bf2c0befc977377fb09b7", + "sha256:147605e1702d996279bb3cc3b164f408698850011210d133a2cb96a73a2f7996", + "sha256:24b04d305ea172ccb21bee5bacd559383cba2c6fcdef85b7701cf2de4188aa55", + "sha256:25b7ec944f114f70803d6529394b64f8749e93cbfac0fe6c5ea1b7e6c14e8a46", + "sha256:2b20286c2b726f94e766e86a3fddb7b7e37af5d0c635bdfa7e4399bc523563de", + "sha256:2dff52b3e7f76ada36f82124703f4953186d9029d00d6287f17c68a75e2e6039", + "sha256:2f8553878a24b00d5ab04b7a92a2af50409247ca5c4b7a2bf4eabe94ed20d3ee", + "sha256:3def6791adf580d66f025223078dc84c64696a26f174131059ce8e91452584e1", + "sha256:422fa44070b42fef9fb8dabd5af03861708cdd6deb69463adc2130b7bf81332f", + "sha256:4f89d8e03c8a3757aae65570d14033e8edf192ee9298303db15955cadcff0c63", + "sha256:5336e0352c0b12c7e72727d50ff02557005f79a0b8dcad9219c7c4940a930083", + "sha256:54d8d0e073a7f238f0666d3c7c0d37469b2aa43311e4024c925ee14f5d5a1cbe", + "sha256:5ef42e1db047ca42827a85e34abe973971c635f83aed49611b7f3ab49d0130f0", + "sha256:5f65e5d3ff2d895dab76b1faca4586b970a99b5d4b24e9aafffc0ce94a6022d6", + "sha256:6c3ccfe89c36f3e5b9837b9ee507472310164f352c9fe332120b764c9d60adbe", + "sha256:6d0b48aff8e9720bdec315d67723f0babd936a7211dc5df453ddf76f89c59933", + "sha256:6fe75dcfcb889b6800f072f2af5a331342d63d0c1b3d2bf0f7b4f6c353e8c9c0", + "sha256:79419370d6a637cb18553ecb25228893966bd7935a9120fa454e7076f13b627c", + "sha256:7bb00521ab4f99fdce2d5c05a91bddc0280f0afaee0e0a00425e28e209d4af07", + "sha256:80db4a47a199c4563d4a25919ff29c97c87569130375beca3483b41ad5f698e8", + "sha256:866ebf42b4c5dbafd64455b0a1cd5aa7b4837a894809413b930026c91e18090b", + "sha256:8af6c26ba8df6338e57bedbf916d76bdae6308e57fc8f14397f03b5da8622b4e", + "sha256:a13772c19619118903d65a91f1d5fea84be494d12fd406d06c849b00d31bf120", + "sha256:a697977157adc052284a7160569b36a8bbec09db3c3220642e6323b47cec090f", + "sha256:a9032f9b7d38bdf882ac9f66ebde3afb8145f0d4c24b2e600bc4c6304aafb87e", + "sha256:b5e28db9199dd3833cc8a07fa6cf429a01227b5d429facb56eccd765050c26cd", + "sha256:c77943ef768276b61c96a3eb854eba55633c7a3fddf0a79f82805f232326d33f", + "sha256:d230d333b0be8042ac34808ad722eabba30036232e7a6fb3e317c49f61c93386", + "sha256:d4548be38a1c810d79e097a38107b6bf2ff42151900e47d49635be69943763d8", + "sha256:d4e7ced84a11c10160c0697a6cc0b214a5d7ab21dfec1cd46e89fbf77cc66fae", + "sha256:d56f105592188ce7a797b2bd94b4a8cb2e36d5d9b0d8a1d2060ff2a71e6b9bbc", + "sha256:d714af0bdba67739598849c9f18efdcc5a0412f4993914a0ec5ce0f1e864d783", + "sha256:d774d9e97007b018a651eadc1b3970ed20237395527e22cbeb743d8e73e0563d", + "sha256:e0524adb49c716ca763dbc1d27bedce36b14f33e6b8af6dba56886476b42957c", + "sha256:e2618cb2cf5a7cc8d698306e42ebcacd02fb7ef8cfc18485c59394152c70be97", + "sha256:e36750fbbc422c1c46c9d13b937ab437138b998fe74a635ec88989afb57a3978", + "sha256:edfdabe7aa4f97ed2b9dd5dde52d2bb29cb466993bb9d612ddd10d0085a683cf", + "sha256:f22325010d8824594820d6ce84fa830838f581a7fd86a9235f0d2ed6deb61e29", + "sha256:f23876b018dfa5d3e98e96f5644b109090f16a4acb22064e0f06933663005d39", + "sha256:f7bd0ffbcd03dc39490a1f40b2669cc414fae0c4e16b77bb26806a4d0b7d1452" ], "markers": "python_version >= '3.7'", - "version": "==6.4.1" + "version": "==6.4.2" }, "distlib": { "hashes": [ - "sha256:6564fe0a8f51e734df6333d08b8b94d4ea8ee6b99b5ed50613f731fd4089f34b", - "sha256:e4b58818180336dc9c529bfb9a0b58728ffc09ad92027a3f30b7cd91e3458579" + "sha256:a7f75737c70be3b25e2bee06288cec4e4c221de18455b2dd037fe2a795cab2fe", + "sha256:b710088c59f06338ca514800ad795a132da19fda270e3ce4affc74abf955a26c" ], - "version": "==0.3.4" + "version": "==0.3.5" }, "docutils": { "hashes": [ @@ -241,19 +241,19 @@ }, "flask": { "hashes": [ - "sha256:315ded2ddf8a6281567edb27393010fe3406188bafbfe65a3339d5787d89e477", - "sha256:fad5b446feb0d6db6aec0c3184d16a8c1f6c3e464b511649c8918a9be100b4fe" + "sha256:10dc2bae7a9b6ab59111d6dbece2e08fb0015d2e88d296c40323cc0c7aac2c2e", + "sha256:98b33b13ad76ee9c7a80d2f56a6c578780e55bf8281790c62d50d4b7fadec2b8" ], "markers": "python_version >= '3.7'", - "version": "==2.1.2" + "version": "==2.2.0" }, "identify": { "hashes": [ - "sha256:0dca2ea3e4381c435ef9c33ba100a78a9b40c0bab11189c7cf121f75815efeaa", - "sha256:3d11b16f3fe19f52039fb7e39c9c884b21cb1b586988114fbe42671f03de3e82" + "sha256:a3d4c096b384d50d5e6dc5bc8b9bc44f1f61cefebd750a7b3e9f939b53fb214d", + "sha256:feaa9db2dc0ce333b453ce171c0cf1247bbfde2c55fc6bb785022d411a1b78b5" ], "markers": "python_version >= '3.7'", - "version": "==2.5.1" + "version": "==2.5.2" }, "idna": { "hashes": [ @@ -374,7 +374,7 @@ "sha256:122fcb64ee37cfad5b3f48d7a7d51875d7031aaf3d8be7c42e2bee25044eee62", "sha256:7d3fbbde18228f4ff2f1f119a45cdffa458b4c0dee32eb4d2bb2f82554bac7bc" ], - "markers": "python_full_version >= '3.6.0'", + "markers": "python_version >= '3.6'", "version": "==4.0.3" }, "mypy-extensions": { @@ -397,7 +397,7 @@ "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb", "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522" ], - "markers": "python_full_version >= '3.6.0'", + "markers": "python_version >= '3.6'", "version": "==21.3" }, "parver": { @@ -417,11 +417,11 @@ }, "pip": { "hashes": [ - "sha256:6d55b27e10f506312894a87ccc59f280136bad9061719fac9101bdad5a6bce69", - "sha256:a3edacb89022ef5258bf61852728bf866632a394da837ca49eb4303635835f17" + "sha256:0bbbc87dfbe6eed217beff0021f8b7dea04c8f4a0baa9d31dc4cff281ffc5b2b", + "sha256:50516e47a2b79e77446f0d05649f0d53772c192571486236b1905492bfc24bac" ], "markers": "python_version >= '3.7'", - "version": "==22.1.2" + "version": "==22.2.1" }, "pipenv": { "editable": true, @@ -444,16 +444,16 @@ "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159", "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3" ], - "markers": "python_full_version >= '3.6.0'", + "markers": "python_version >= '3.6'", "version": "==1.0.0" }, "pre-commit": { "hashes": [ - "sha256:10c62741aa5704faea2ad69cb550ca78082efe5697d6f04e5710c3c229afdd10", - "sha256:4233a1e38621c87d9dda9808c6606d7e7ba0e087cd56d3fe03202a01d2919615" + "sha256:51a5ba7c480ae8072ecdb6933df22d2f812dc897d5fe848778116129a681aac7", + "sha256:a978dac7bc9ec0bcee55c18a277d553b0f419d259dadb4b9418ff2d00eb43959" ], "index": "pypi", - "version": "==2.19.0" + "version": "==2.20.0" }, "py": { "hashes": [ @@ -494,7 +494,7 @@ "sha256:5eb116118f9612ff1ee89ac96437bb6b49e8f04d8a13b514ba26f620208e26eb", "sha256:dc9c10fb40944260f6ed4c688ece0cd2048414940f1cea51b8b226318411c519" ], - "markers": "python_full_version >= '3.6.0'", + "markers": "python_version >= '3.6'", "version": "==2.12.0" }, "pyparsing": { @@ -526,7 +526,7 @@ "sha256:8b67587c8f98cbbadfdd804539ed5455b6ed03802203485dd2f53c1422d7440e", "sha256:bbbb6717efc886b9d64537b41fb1497cfaf3c9601276be8da2cccfea5a3c8ad8" ], - "markers": "python_full_version >= '3.6.0'", + "markers": "python_version >= '3.6'", "version": "==1.4.0" }, "pytest-pypi": { @@ -538,7 +538,7 @@ "sha256:c07ca07404c612f8abbe22294b23c368e2e5104b521c1790195561f37e1ac3d9", "sha256:f6f50101443ce70ad325ceb4473c4255e9d74e3c7cd0ef827309dfa4c0d975c6" ], - "markers": "python_full_version >= '3.6.0'", + "markers": "python_version >= '3.6'", "version": "==2.1.0" }, "pytest-xdist": { @@ -546,7 +546,7 @@ "sha256:4580deca3ff04ddb2ac53eba39d76cb5dd5edeac050cb6fbc768b0dd712b4edf", "sha256:6fe5c74fec98906deb8f2d2b616b5c782022744978e7bd4695d39c8f42d0ce65" ], - "markers": "python_full_version >= '3.6.0'", + "markers": "python_version >= '3.6'", "version": "==2.5.0" }, "pytz": { @@ -592,7 +592,7 @@ "sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174", "sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5" ], - "markers": "python_full_version >= '3.6.0'", + "markers": "python_version >= '3.6'", "version": "==6.0" }, "requests": { @@ -605,11 +605,11 @@ }, "setuptools": { "hashes": [ - "sha256:16923d366ced322712c71ccb97164d07472abeecd13f3a6c283f6d5d26722793", - "sha256:db3b8e2f922b2a910a29804776c643ea609badb6a32c4bcc226fd4fd902cce65" + "sha256:273b6847ae61f7829c1affcdd9a32f67aa65233be508f4fbaab866c5faa4e408", + "sha256:d5340d16943a0f67057329db59b564e938bb3736c6e50ae16ea84d5e5d9ba6d0" ], "markers": "python_version >= '3.7'", - "version": "==63.1.0" + "version": "==63.3.0" }, "six": { "hashes": [ @@ -631,7 +631,7 @@ "sha256:3b2503d3c7084a42b1ebd08116e5f81aadfaea95863628c80a3b774a11b7c759", "sha256:fc53893b3da2c33de295667a0e19f078c14bf86544af307354de5fcf12a3f30d" ], - "markers": "python_full_version >= '3.6.0'", + "markers": "python_version >= '3.6'", "version": "==2.3.2.post1" }, "sphinx": { @@ -671,7 +671,7 @@ "sha256:d412243dfb797ae3ec2b59eca0e52dac12e75a241bf0e4eb861e450d06c6ed07", "sha256:f5f8bb2d0d629f398bf47d0d69c07bc13b65f75a81ad9e2f71a63d4b7a2f6db2" ], - "markers": "python_full_version >= '3.6.0'", + "markers": "python_version >= '3.6'", "version": "==2.0.0" }, "sphinxcontrib-jsmath": { @@ -726,7 +726,7 @@ "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc", "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f" ], - "markers": "python_full_version >= '3.6.0'", + "markers": "python_full_version < '3.11.0a7'", "version": "==2.0.1" }, "towncrier": { @@ -746,19 +746,19 @@ }, "urllib3": { "hashes": [ - "sha256:8298d6d56d39be0e3bc13c1c97d133f9b45d797169a0e11cdd0e0489d786f7ec", - "sha256:879ba4d1e89654d9769ce13121e0f94310ea32e8d2f8cf587b77c08bbcdb30d6" + "sha256:c33ccba33c819596124764c23a97d25f32b28433ba0dedeb77d873a38722c9bc", + "sha256:ea6e8fb210b19d950fab93b60c9009226c63a28808bc8386e05301e25883ac0a" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5' and python_version < '4'", - "version": "==1.26.10" + "version": "==1.26.11" }, "virtualenv": { "hashes": [ - "sha256:288171134a2ff3bfb1a2f54f119e77cd1b81c29fc1265a2356f3e8d14c7d58c4", - "sha256:b30aefac647e86af6d82bfc944c556f8f1a9c90427b2fb4e3bfbf338cb82becf" + "sha256:0ef5be6d07181946891f5abc8047fda8bc2f0b4b9bf222c64e6e8963baee76db", + "sha256:635b272a8e2f77cb051946f46c60a54ace3cb5e25568228bd6b57fc70eca9ff3" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", - "version": "==20.15.1" + "markers": "python_version >= '3.6'", + "version": "==20.16.2" }, "virtualenv-clone": { "hashes": [ @@ -770,11 +770,11 @@ }, "werkzeug": { "hashes": [ - "sha256:60ab4823078f08fdb36b5b83b35f1c422eab8c92929eba5487e1bd52d2316fd4", - "sha256:6a3fe061435495aed49c1ea54dbdf1529b6333bb7ddbe20089e4360250b040ec" + "sha256:4d7013ef96fd197d1cdeb03e066c6c5a491ccb44758a5b2b91137319383e5a5a", + "sha256:7e1db6a5ba6b9a8be061e47e900456355b8714c0f238b0313f53afce1a55a79a" ], "markers": "python_version >= '3.7'", - "version": "==2.2.0a1" + "version": "==2.2.1" }, "zipp": { "hashes": [ diff --git a/docs/advanced.rst b/docs/advanced.rst index 5e7e681823..eff9117c05 100644 --- a/docs/advanced.rst +++ b/docs/advanced.rst @@ -558,6 +558,10 @@ wherever you want, e.g.:: In addition, you can also have Pipenv stick the virtualenv in ``project/.venv`` by setting the ``PIPENV_VENV_IN_PROJECT`` environment variable. +☤ Custom Virtual Environment Name +------------------------------------- + +Pipenv supports a custom name for the virtual environment set at ``PIPENV_CUSTOM_VENV_NAME``. by default the venv will be named after the project directory. ☤ Testing Projects ------------------ diff --git a/pipenv/environments.py b/pipenv/environments.py index 41835bfeff..5b5e49f4e2 100644 --- a/pipenv/environments.py +++ b/pipenv/environments.py @@ -335,6 +335,9 @@ def initialize(self): approach, you may set this to '0', 'off', or 'false'. """ + self.PIPENV_CUSTOM_VENV_NAME = os.getenv("PIPENV_CUSTOM_VENV_NAME", None) + """Tells Pipenv whether to name the venv something other than the default dir name.""" + self.PIPENV_PYUP_API_KEY = os.environ.get("PIPENV_PYUP_API_KEY", None) # Internal, support running in a different Python from sys.executable. diff --git a/pipenv/project.py b/pipenv/project.py index 20685fdd18..17b26a0aa1 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -364,7 +364,7 @@ def get_name(name, location): @property def virtualenv_name(self) -> str: - custom_name = os.getenv("PIPENV_CUSTOM_VENV_NAME") + custom_name = self.s.PIPENV_CUSTOM_VENV_NAME if custom_name: return custom_name sanitized, encoded_hash = self._get_virtualenv_hash(self.name) From 5358b09ed6719a52bb6abe53fa1caa9bb90864a1 Mon Sep 17 00:00:00 2001 From: otherjake Date: Tue, 2 Aug 2022 12:04:33 -0400 Subject: [PATCH 3/7] Correct name of news fragment to house standards. --- news/4974-custom-venv-name.trivial.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/4974-custom-venv-name.trivial.rst diff --git a/news/4974-custom-venv-name.trivial.rst b/news/4974-custom-venv-name.trivial.rst new file mode 100644 index 0000000000..3f88944983 --- /dev/null +++ b/news/4974-custom-venv-name.trivial.rst @@ -0,0 +1 @@ +support PIPENV_CUSTOM_VENV_NAME to be the venv name if specified, update relevant docs. From 1a0557155e565fe55573cab4e5cb12351e14bba5 Mon Sep 17 00:00:00 2001 From: otherjake Date: Tue, 2 Aug 2022 12:15:22 -0400 Subject: [PATCH 4/7] Fix name of news fragment to be even more correct. --- news/4974-custom-venv-name.trivial.rst | 1 - 1 file changed, 1 deletion(-) delete mode 100644 news/4974-custom-venv-name.trivial.rst diff --git a/news/4974-custom-venv-name.trivial.rst b/news/4974-custom-venv-name.trivial.rst deleted file mode 100644 index 3f88944983..0000000000 --- a/news/4974-custom-venv-name.trivial.rst +++ /dev/null @@ -1 +0,0 @@ -support PIPENV_CUSTOM_VENV_NAME to be the venv name if specified, update relevant docs. From 7fcb2ff4e175e5f377e5d74973abfce8bcbda198 Mon Sep 17 00:00:00 2001 From: otherjake Date: Tue, 2 Aug 2022 12:17:06 -0400 Subject: [PATCH 5/7] Add new news fragment to git. --- news/4974.feature.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/4974.feature.rst diff --git a/news/4974.feature.rst b/news/4974.feature.rst new file mode 100644 index 0000000000..3f88944983 --- /dev/null +++ b/news/4974.feature.rst @@ -0,0 +1 @@ +support PIPENV_CUSTOM_VENV_NAME to be the venv name if specified, update relevant docs. From 80403b9e4cc497fc5ec83f8f0370049bb3f74fd8 Mon Sep 17 00:00:00 2001 From: otherjake Date: Wed, 3 Aug 2022 16:32:39 -0400 Subject: [PATCH 6/7] Add unit test, create a section about venv names in advanced docs. --- docs/advanced.rst | 13 +++++++++++-- docs/basics.rst | 6 ------ tests/integration/test_dot_venv.py | 15 +++++++++++++++ 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/docs/advanced.rst b/docs/advanced.rst index eff9117c05..4d76774270 100644 --- a/docs/advanced.rst +++ b/docs/advanced.rst @@ -558,10 +558,19 @@ wherever you want, e.g.:: In addition, you can also have Pipenv stick the virtualenv in ``project/.venv`` by setting the ``PIPENV_VENV_IN_PROJECT`` environment variable. -☤ Custom Virtual Environment Name +☤ Virtual Environment Name ------------------------------------- -Pipenv supports a custom name for the virtual environment set at ``PIPENV_CUSTOM_VENV_NAME``. by default the venv will be named after the project directory. +The virtualenv name created by Pipenv may be different from what you were expecting. +Dangerous characters (i.e. ``$`!*@"`` as well as space, line feed, carriage return, +and tab) are converted to underscores. Additionally, the full path to the current +folder is encoded into a "slug value" and appended to ensure the virtualenv name +is unique. + +Pipenv supports a arbitrary custom name for the virtual environment set at ``PIPENV_CUSTOM_VENV_NAME``. + +The logical place to specify this would be in a user's ``.env`` file in the root of the project, which gets loaded by pipenv when it is invoked. + ☤ Testing Projects ------------------ diff --git a/docs/basics.rst b/docs/basics.rst index a090a3cb78..62ef1c55cc 100644 --- a/docs/basics.rst +++ b/docs/basics.rst @@ -313,12 +313,6 @@ The user can provide these additional parameters: **destructive** and will delete your current virtualenv before replacing it with an appropriately versioned one. - .. note:: The virtualenv created by Pipenv may be different from what you were expecting. - Dangerous characters (i.e. ``$`!*@"`` as well as space, line feed, carriage return, - and tab) are converted to underscores. Additionally, the full path to the current - folder is encoded into a "slug value" and appended to ensure the virtualenv name - is unique. - - ``--dev`` — Install both ``develop`` and ``default`` packages from ``Pipfile``. - ``--system`` — Use the system ``pip`` command rather than the one from your virtualenv. - ``--deploy`` — Make sure the packages are properly locked in Pipfile.lock, and abort if the lock file is out-of-date. diff --git a/tests/integration/test_dot_venv.py b/tests/integration/test_dot_venv.py index af4293533f..c075aba768 100644 --- a/tests/integration/test_dot_venv.py +++ b/tests/integration/test_dot_venv.py @@ -161,3 +161,18 @@ def test_venv_in_project_default_when_venv_exists(PipenvInstance): assert venv_loc.joinpath('.project').exists() assert venv_loc == Path(venv_path) + + +@pytest.mark.dotenv +def test_venv_name_accepts_custom_name_environment_variable(PipenvInstance): + """Tests that virtualenv reads PIPENV_CUSTOM_VENV_NAME and accepts it as a name + """ + with PipenvInstance(chdir=True, venv_in_project=False) as p: + test_name = "sensible_custom_venv_name" + os.environ['PIPENV_CUSTOM_VENV_NAME'] = test_name + c = p.pipenv('install') + assert c.returncode == 0 + c = p.pipenv('--venv') + assert c.returncode == 0 + venv_path = c.stdout.strip() + assert test_name == Path(venv_path).parts[-1] From 08c76ad4b0ad17d16c5fc452b8fe333d76bbda56 Mon Sep 17 00:00:00 2001 From: Oz N Tiram Date: Thu, 4 Aug 2022 10:46:27 +0200 Subject: [PATCH 7/7] Use temp_environ in test for CUSTOM_VENV_NAME This is so that PIPENV_CUSTOM_VENV_NAME does not leak to other tests. --- tests/integration/test_dot_venv.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/integration/test_dot_venv.py b/tests/integration/test_dot_venv.py index c075aba768..319ebfcdd2 100644 --- a/tests/integration/test_dot_venv.py +++ b/tests/integration/test_dot_venv.py @@ -169,10 +169,11 @@ def test_venv_name_accepts_custom_name_environment_variable(PipenvInstance): """ with PipenvInstance(chdir=True, venv_in_project=False) as p: test_name = "sensible_custom_venv_name" - os.environ['PIPENV_CUSTOM_VENV_NAME'] = test_name - c = p.pipenv('install') - assert c.returncode == 0 - c = p.pipenv('--venv') - assert c.returncode == 0 - venv_path = c.stdout.strip() - assert test_name == Path(venv_path).parts[-1] + with temp_environ(): + os.environ['PIPENV_CUSTOM_VENV_NAME'] = test_name + c = p.pipenv('install') + assert c.returncode == 0 + c = p.pipenv('--venv') + assert c.returncode == 0 + venv_path = c.stdout.strip() + assert test_name == Path(venv_path).parts[-1]