Skip to content

Commit

Permalink
PyPI v0.6.4: Fixed a bug in metadata updates during installation & RE…
Browse files Browse the repository at this point in the history
…ADME tweaks
  • Loading branch information
janik6n committed Apr 30, 2019
1 parent fc474c0 commit 0f4e9d2
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.6.4] - 2019-04-30

### Added

### Changed

### Removed

### Fixed

- Fixed a bug while installing a package (updating jetzt_metadata.json). The bug occured e.g. with jupyterlab which also installs jupyterlab-server as a dependency. Thus, the package name failed to resolve while validating installation.
- Tweaked README.

## [0.6.3] - 2019-04-16

### Added
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ After scaffolding, start a jupyter server by running `jupyter-notebook` in the p

## Manage Python dependencies

All dependency management takes place in a *virtualenv* (created with `jetzt --scaffold`), so **make sure you have activated the project's environment before running these commands with `source venv/bin/activate`**. There is naturally the standard way of using *pip* to install dependencies, and manually add them to `requirements.txt`, etc.
All dependency management takes place within a *virtualenv* (created with `jetzt --scaffold`), so **make sure you have activated the project's environment before running these commands with `source venv/bin/activate`**. There is naturally the standard way of using *pip* to install dependencies, and manually add them to `requirements.txt`, etc.

*Jetzt* includes an option to install and manage the dependencies for you. Please continue reading.

Expand All @@ -97,17 +97,17 @@ All dependency management takes place in a *virtualenv* (created with `jetzt --s
To install a package `requests`, run `jetzt --install` and follow the prompt. You have an option to install the package as *a production dependency* or as *a development dependency*. What does all this mean, you might ask? Jetzt will:

1. Install the package *requests* (latest available version).
2. Add the package `requests` to `requirements.txt` with a version requirement set to minimum of the currently installed version. The packages, which *requests* depends on, are *not* added. If you selected `DEV` as a dependency type, the file `requirements-dev.txt` will be used instead.
2. Add the package `requests` to `jetzt_metadata.json` with a version requirement set to minimum of the currently installed version. The packages, which *requests* depends on, are *not* added. You can install a dependency as a `DEV` dependency too.

**At the moment, you can only install one package at a time.**

Example of `requirements.txt`:
Example of a defined dependency with a version (as a installation requirement, or as seen in `jetzt_metadata.json`):

```
requests>=2.21.0
```

**Version pinning:** To install a specific version of a package, add the version, just as you would with pip. For example: `requests==2.20.1`. This will pin the version in `requirements.txt` like so:
**Version pinning:** To install a specific version of a package, add the version, just as you would with pip. For example: `requests==2.20.1`. This will pin the version like so:

```
requests==2.20.1
Expand Down
2 changes: 1 addition & 1 deletion jetzt/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.6.3'
__version__ = '0.6.4'
16 changes: 14 additions & 2 deletions jetzt/update_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,20 @@
print(f"Could not remove dependency {package} from jetzt_metadata.json ({dependencies}/{package}), please remove manually.")

elif action == 'INSTALL':
''' Installing a new dependency. '''
installed_package, installed_version = re.split("==|>=", package_with_version) # package==0.13.2
'''
Installing a new dependency.
As of now, the variable may contain more than one package. E.g. with jupyterlab:
- package_with_version: "jupyterlab==0.35.5\njupyterlab-server==0.2.0"
- need to split by linefeed and check, if the name matches.
'''
found_packages = package_with_version.split('\n')

for found_package in found_packages:
installed_package, installed_version = re.split("==|>=", found_package) # package==0.13.2
if package == installed_package:
break

# Pinned version
if '==' in package:
installed_version = f"=={installed_version}"
Expand Down

0 comments on commit 0f4e9d2

Please sign in to comment.