Skip to content
This repository has been archived by the owner on Jul 30, 2023. It is now read-only.

python implementation #2

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/python/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
src/is_railway.egg-info/
19 changes: 19 additions & 0 deletions packages/python/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2022 Suhas

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
68 changes: 68 additions & 0 deletions packages/python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<div align="center">

# is-railway

**Check if the current process is running inside Railway.**

[![GitHub](https://img.shields.io/github/license/1chiSensei/is-railway)](https://github.com/1chiSensei/is-railway/blob/main/LICENSE)
[![crates.io](https://img.shields.io/crates/v/is-railway?color=orange&logo=rust&style=flat-square)](https://crates.io/crates/is-railway)

</div>

**Table of Contents**

- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [Basic Usage](#basic-usage)
- [CLI](#cli)
- [Contributors ✨](#contributors-%E2%9C%A8)

## Features

- Written in Rust
- Fast and lightweight
- Uses no dependencies

## Installation

You can use the following command to install this package.
```sh
pip install is-railway
```

Or as a dependency.
```
# requirements.txt

is-railway
```

## Usage

```py

from is_railway import check # notice the underscore in the import rather than a dash
print(check())

```

## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tr>
<td align="center"><a href="https://github.com/1chiSensei"><img src="https://avatars.githubusercontent.com/u/75403863?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tomio</b></sub></a><br /><a href="https://github.com/1chiSensei/is-railway/commits?author=1chiSensei" title="Code">💻</a> <a href="https://github.com/1chiSensei/is-railway/commits?author=1chiSensei" title="Documentation">📖</a></td>
</tr>
</table>

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
6 changes: 6 additions & 0 deletions packages/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[build-system]
requires = [
"setuptools>=42",
"wheel"
]
build-backend = "setuptools.build_meta"
24 changes: 24 additions & 0 deletions packages/python/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[metadata]
name = is-railway
version = 0.0.2
author = Suhas
author_email = [email protected]
description = A package to check if the current code is running on https://railway.app
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/1chiSensei/is-railway
project_urls =
Bug Tracker = https://github.com/1chiSensei/is-railway/issues
classifiers =
Programming Language :: Python :: 3
License :: OSI Approved :: MIT License
Operating System :: OS Independent

[options]
package_dir =
= src
packages = find:
python_requires = >=3.6

[options.packages.find]
where = src
16 changes: 16 additions & 0 deletions packages/python/src/is_railway/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from os import getenv

VARS = [
"RAILWAY_STATIC_URL",
"RAILWAY_ENVIRONMENT",
"RAILWAY_HEALTHCHECK_TIMEOUT_SEC",
"RAILWAY_GIT_COMMIT_SHA",
"RAILWAY_GIT_AUTHOR",
"RAILWAY_GIT_BRANCH",
"RAILWAY_GIT_REPO_NAME",
"RAILWAY_GIT_REPO_OWNER",
"RAILWAY_GIT_COMMIT_MESSAGE",
]

def check() -> bool:
return len([val for val in VARS if getenv(val) != None]) > 0