Jump to content

User talk:Dvorapa/Toolforge for beginners/Tool environment

From Wikitech

Confusing different package managers?

The "virtual environment" term is generally used to refer to Python virtual environments. The virtualenv command is specifically a tool to create a Python virtual environment. virtualenv -p nodejs my_venv does not work:

$ virtualenv -p nodejs my_venv
Running virtualenv with interpreter /usr/bin/nodejs
/usr/lib/python3/dist-packages/virtualenv.py:2
"""Create a "virtual" Python installation"""
  ^^^^^^^^^^^

SyntaxError: Unexpected string
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:616:28)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:188:16)
    at bootstrap_node.js:609:3

Since the use of each language specific package manager will be different, I think it would be best to organize this page by language runtime with most of the existing content moved under a "Python" section. I would also recommend renaming the page something like "Local packages" or "Package management". --BryanDavis (talk) 18:35, 9 March 2019 (UTC)Reply

@BryanDavis: I'm new to virtual environments at all, but this information was copied from cloud IRC I think, where I got it from other experienced guys. I don't want to go into the details here, we can always link to language-specific tutorials, this should be more like a universal guide. --Dvorapa (talk) 22:50, 9 March 2019 (UTC)Reply
@BryanDavis: This particular page was completely compiled from IRC chats with Czech Wikimedia Tech group IRC and Cloud IRC. Errors like this could be here, but I think there is a way to get some sort of venv for nodejs. But as I said earlier, this should be a general tutorial, for the language-specific things we should link away, not make the second gigantic long and unusable Help:Toolforge. --22:54, 9 March 2019 (UTC)
Guys explained me, that virtualenv my_env makes an environment and then I can install whatever I want, like python, pip, dart, typescript, nodejs, perl anything. But I can also use the preset environments, which are e.g. python3 or nodejs. If this is incorrect, please fix the mistake. --Dvorapa (talk) 22:59, 9 March 2019 (UTC)Reply
@Dvorapa: As I reported initially, the virtualenv command is specifically a tool to create a Python virtual environment. It does allow you to choose to make the environment using any installed Python interpreter, but it does not work with other arbitrary language runtimes like nodejs. Your "Local packages" section is largely correct, but the "Virtual environment" section is not. I like the idea of splitting language specific details into other sections. I think that means that the "Virtual environment" belongs in a Python specific page. I will update the current section to remove the incorrect information about use of virtualenv with nodejs. I will leave page splitting to you. --BryanDavis (talk) 02:14, 11 March 2019 (UTC)Reply
Okay, thank you, I'll split it later. Does that mean that for non-python languages there is no other option than .local? Do I understand it correctly? --Dvorapa (talk) 10:40, 11 March 2019 (UTC)Reply
It is language and package manager specific. PHP's composer and NodeJs's npm both can be used to manage dependencies in a way that is scoped to a particular directory. This is functionally very similar to Python's venv concept, but slightly different in that there is no equivalent of 'enabling' the collection of packages. Instead composer and npm are designed to work with the class loader mechanisms of their respective languages. (I don't think I'm doing a very good job of explaining the difference.) The pipenv project is attempting to mimic the way that composer, npm, etc work a package manger tied to a particular application deployment. The use of the $HOME/.local directory to store data is an implementation detail and related to use of $XDG_DATA_HOME by a particular package manager. --BryanDavis (talk) 18:21, 11 March 2019 (UTC)Reply
Yes, I knew that npm, pip, dartpub and also composer and some more can install things into the local directory (like .local). Python also has got venv, where multiple directories can have multiple settings. Dart supports similar process using projects directories. Perhaps some similar thing is working for composer or npm too, but I'm not much experienced with these two as I've never needed any package manager for PHP and also never needed npm at all as I find Dart better than Node.js (but unfortunately Dart seems not to be installed on Forge). --Dvorapa (talk) 20:33, 11 March 2019 (UTC)Reply