synchronize python version with a property inside of package.json #4

Open
opened 2020-01-06 22:15:13 -05:00 by valyrie97 · 1 comment
valyrie97 commented 2020-01-06 22:15:13 -05:00 (Migrated from github.com)

when portapy is installed, create a key for what version it is, if it doesn't exist. if it does, use that version.

have a command, pvm, that allows you to change which version you are using locally, or be able to change it in package.json, and reinstall portapy, so it'll automagically be that version.

when portapy is installed, create a key for what version it is, if it doesn't exist. if it does, use that version. have a command, `pvm`, that allows you to change which version you are using locally, or be able to change it in `package.json`, and reinstall portapy, so it'll automagically be that version.
valyrie97 commented 2020-02-02 13:16:43 -05:00 (Migrated from github.com)

just want to add some behaviour examples to this

pvm ls

$ pvm ls
2.7.0
2.7.1
2.7.2 - latest 2
... etc
3.8.0
3.8.1 - latest 3

simply lists all available versions. call out latest for 3/2.

pvm use <version>

$ pvm use 3.8.1
Downloading Python 3.8.1...
[########-------] 57%
Installing...
[#####----------] 34%
Done! [18.3s]
Python => /Users/Valerie/test/folder/node_modules/.bin/python

This will first look for a package.json locally; it will ascend the file tree until it finds a package.json with portapy installed in it. For example, if the above was run in /Users/Valerie/test/folder/src/types, it would search for:

/Users/Valerie/test/folder/src/types/package.json
/Users/Valerie/test/folder/src/package.json
/Users/Valerie/test/folder/package.json
/Users/Valerie/test/package.json
/Users/Valerie/package.json
/Users/package.json
/package.json

when it found where it was installed, it would do the installation. this process is important, because if a person installs portapy globally, for the pvm command, but only wants to have a particular version in one project, they'll still need to install it for the project, like you normally would, then use pvm to select and install a different version.

alternatively, they could use npm scripts, to link pvm locally installed. this would mean:

package.json

{
  "name": "test-project",
  "version": "0.0.1",
  "scripts": {
    "pvm": "./node_modules/.bin/pvm"
  }
}
$ npm run pvm -- use 3.8.1

or with yarn

yarn pvm -- use 3.8.1

pvm use --global <version>

this will change the search array to just the global install location. this changes from system to system, but there should be a package.json for global installs, and the process should be mostly the same, but --global forces the global installation.

Manually moving to the global install folder and running pvm should have a similar effect, though the flag wont search parent directories, just the right one.

just want to add some behaviour examples to this ## `pvm ls` ``` $ pvm ls 2.7.0 2.7.1 2.7.2 - latest 2 ... etc 3.8.0 3.8.1 - latest 3 ``` simply lists all available versions. call out latest for 3/2. ## `pvm use <version>` ``` $ pvm use 3.8.1 Downloading Python 3.8.1... [########-------] 57% Installing... [#####----------] 34% Done! [18.3s] Python => /Users/Valerie/test/folder/node_modules/.bin/python ``` This will first look for a package.json locally; it will ascend the file tree until it finds a package.json with portapy installed in it. For example, if the above was run in `/Users/Valerie/test/folder/src/types`, it would search for: ``` /Users/Valerie/test/folder/src/types/package.json /Users/Valerie/test/folder/src/package.json /Users/Valerie/test/folder/package.json /Users/Valerie/test/package.json /Users/Valerie/package.json /Users/package.json /package.json ``` when it found where it was installed, it would do the installation. this process is important, because if a person installs portapy globally, for the pvm command, but only wants to have a particular version in one project, they'll still need to install it for the project, like you normally would, then use pvm to select and install a different version. alternatively, they could use npm scripts, to link pvm locally installed. this would mean: #### `package.json` ```json { "name": "test-project", "version": "0.0.1", "scripts": { "pvm": "./node_modules/.bin/pvm" } } ``` ``` $ npm run pvm -- use 3.8.1 ``` or with yarn ``` yarn pvm -- use 3.8.1 ``` ## `pvm use --global <version>` this will change the search array to just the global install location. this changes from system to system, but there should be a package.json for global installs, and the process should be mostly the same, but `--global` forces the global installation. Manually moving to the global install folder and running pvm should have a similar effect, though the flag wont search parent directories, just the right one.
This repo is archived. You cannot comment on issues.
No Milestone
No project
No Assignees
1 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: valerie/portapy#4
There is no content yet.