Skip to content

Commit

Permalink
Version 0.1 (#3)
Browse files Browse the repository at this point in the history
* add dev-requirements for reserver package

* import uploader object in `__init__`

* add function to check given name existance as a package name

* add function to generate template `setup.py` for the given name

* `Uploader` object initialization

* add `upload_to_pypi` function

* add pypi associated params to `reserver_param.py`

* add docstring for functions in `reserver_func.py`

* update docstring

* add `is_platform_linux` & `get_random_name` utility function

* apply `autopep8.sh`

* add `test.pypi` credentials to test.yml

* add package name to the params

* update test step's name

* reserved name package upload test case

* update .gitignore

* update the exception's description

* update test files

* add requests requirement to `dev-requirements.txt`

* add timeout to `get` request

* add `bandit` config file

* update `test.yml`

* update docstring issues reported by `pydocstyle`

* clean `imports` part

* add return value for `upload_to_pypi` function

* handle invalid PyPI API Key

* split test cases
add `package_exists` test case
add `valid_package_invalid_credentials` test case
add `valid_package_valid_credentials` test case

* enhance docstrings

* remove python 3.6 support for now

* remove assert & dummy pass detection rules in bandit

* add test case to `README.md`

* add placeholder for github stars

* add placeholder for PyPI counter

* update `CHANGELOG.md`

* `dev-requirements.txt` updated

* `requirements.txt` updated

* remove installation of requirements

* temporarily removed `importlib-metadata<5.0`

* remove unused import

* remove `is_platform_linux` function

* move `get_random_name` function from `utils.py` to `reserver_func.py`

* update template `setup.py`

* update docstrings

* remove `util.py` and add inner functionalities to `reserver_func.py`

* update test file import

* update author email

* add logo to readme

* partially update discord badge

* add Logo `.png` file

* fullfil discord badges

* fullfil `pypi` badge in `README.md`

* add References + fix typo

* remove `\n` from packages

* add functionality to create folder with the package name with a __init__.py inside

* make param name shorter

* handle "-" issue in `.eggfile`(replace with "_")

* handle too similiar name

* remove extra print in `reserver_obj.py`

* update test cases

* `README.md` updated

* `CHANGELOG.md` updated

* logo name updated

* fix `requests` requirment to trigger dependent bot

* add `requests` to package main requirments

* remove python 3.6

* correct typo in docstring

* ensure env variables are popped out

* change `>=` to `==` in basic requirments' version to trigger dependent bot

* Bump twine from 4.0.0 to 4.0.2 (#6)

Bumps [twine](https://github.com/pypa/twine) from 4.0.0 to 4.0.2.
- [Release notes](https://github.com/pypa/twine/releases)
- [Changelog](https://github.com/pypa/twine/blob/main/docs/changelog.rst)
- [Commits](pypa/twine@4.0.0...4.0.2)

---
updated-dependencies:
- dependency-name: twine
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump requests from 1.0.0 to 2.31.0 (#7)

Bumps [requests](https://github.com/psf/requests) from 1.0.0 to 2.31.0.
- [Release notes](https://github.com/psf/requests/releases)
- [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md)
- [Commits](psf/requests@v1.0.0...v2.31.0)

---
updated-dependencies:
- dependency-name: requests
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump wheel from 0.40.0 to 0.42.0 (#8)

Bumps [wheel](https://github.com/pypa/wheel) from 0.40.0 to 0.42.0.
- [Release notes](https://github.com/pypa/wheel/releases)
- [Changelog](https://github.com/pypa/wheel/blob/main/docs/news.rst)
- [Commits](pypa/wheel@0.40.0...0.42.0)

---
updated-dependencies:
- dependency-name: wheel
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump setuptools from 40.8.0 to 69.0.3 (#9)

Bumps [setuptools](https://github.com/pypa/setuptools) from 40.8.0 to 69.0.3.
- [Release notes](https://github.com/pypa/setuptools/releases)
- [Changelog](https://github.com/pypa/setuptools/blob/main/NEWS.rst)
- [Commits](pypa/setuptools@v40.8.0...v69.0.3)

---
updated-dependencies:
- dependency-name: setuptools
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* `Disclaimer` section added

* add disclaimer to table of index

* `README.md` updated

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
AHReccese and dependabot[bot] authored Feb 7, 2024
1 parent 0ae5bb9 commit cd0429e
Show file tree
Hide file tree
Showing 14 changed files with 294 additions and 31 deletions.
2 changes: 2 additions & 0 deletions .bandit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[bandit]
skips=B404,B602,B101,B105
9 changes: 6 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-latest, macOS-latest]
python-version: [3.6, 3.7, 3.8, 3.9, 3.10.0, 3.11.0, 3.12.0]
python-version: [3.7, 3.8, 3.9, 3.10.0, 3.11.0, 3.12.0]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -32,17 +32,20 @@ jobs:
python otherfiles/requirements-splitter.py
pip install --upgrade --upgrade-strategy=only-if-needed -r test-requirements.txt
- name: Test with pytest
env:
TWINE_TEST_USERNAME: ${{ secrets.TEST_PYPI_USERNAME }}
TWINE_TEST_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }}
run: |
python -m pytest . --cov=reserver --cov-report=term
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: false
if: matrix.python-version == env.TEST_PYTHON_VERSION && matrix.os == env.TEST_OS
- name: Other tests
- name: vulture, bandit and pydocstyle tests
run: |
python -m vulture reserver/ otherfiles/ setup.py --min-confidence 65 --exclude=__init__.py --sort-by-size
python -m bandit -r reserver -s B311
python -m bandit -r reserver .
python -m pydocstyle -v
if: matrix.python-version == env.TEST_PYTHON_VERSION
- name: Version check
Expand Down
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,4 @@ ENV/
out
gen

/tests/exported_linear_models
/tests/exported_neural_networks
/tests/exported_decision_trees
/tests/exported_clusterings
/.VSCodeCounter
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [0.1] - 2022-08-17
### Added
### Changed
## [0.1] - 2024-02-07
### Added
- `Uploader` class
- Check package name existence
- Upload template package to test.pypi
- Upload template package to pypi
- Generate template package for a given name
- Handle similiar name existance in pypi
- Handle issue with "-" character `.egginfo` file name

[Unreleased]: https://github.com/openscilab/reserver/compare/v0.1...dev
[0.1]: https://github.com/openscilab/reserver/compare/3598e8b...v0.1
[0.1]: https://github.com/openscilab/reserver/compare/0ae5bb9...v0.1
43 changes: 27 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
<div align="center">
<img src="https://github.com/openscilab/reserver/raw/main/otherfiles/logo.png" width="280" height="400">
<img src="https://github.com/openscilab/reserver/raw/main/otherfiles/reserver.png" width="300" height="300">
<br/>
<br/>
<a href="https://codecov.io/gh/openscilab/reserver">
<img src="https://codecov.io/gh/openscilab/reserver/branch/main/graph/badge.svg" alt="Codecov"/>
</a>
<a href="TODO">
<img src="TODO" alt="PyPI version" height="18">
<a href="https://badge.fury.io/py/reserver">
<img src="https://badge.fury.io/py/reserver.svg" alt="PyPI version" height="18">
</a>
<a href="https://www.python.org/">
<img src="https://img.shields.io/badge/built%20with-Python3-green.svg" alt="built with Python3">
</a>
<a href="TODO">
<img src="TODO" alt="Discord Channel">
<a href="https://discord.gg/RD2y6SGuY3">
<img src="https://img.shields.io/discord/1064533716615049236.svg" alt="Discord Channel">
</a>
</div>

----------

## Table of contents

* [Disclaimer](https://github.com/openscilab/reserver#disclaimer)
* [Overview](https://github.com/openscilab/reserver#overview)
* [Installation](https://github.com/openscilab/reserver#installation)
* [Usage](https://github.com/openscilab/reserver#usage)
Expand All @@ -32,25 +33,29 @@
* [Changelog](https://github.com/openscilab/reserver/blob/main/CHANGELOG.md)
* [Code of Conduct](https://github.com/openscilab/reserver/blob/main/.github/CODE_OF_CONDUCT.md)

## Disclaimer
<p align="justify">
⚠️The intention of this package is facilitating the reservation of package names on PyPI for legitimate and appropriate purposes. We explicitly disclaim any responsibility for the misuse or spamming of this tool, particularly in the excessive reservation of package names. Users are advised to be cautious and ensure the legitimate use of this package to avoid potential consequences such as the suspension of their PyPI account. By using this package, users acknowledge and agree to these terms.
</p>

## Overview
<p align="justify">
Reserver is an open source Python package that provides functionality to easily reserve a pypi package name. Have an idea? Reserve the package name instantly before it gets taken!
Reserver is an open source Python package that offers the ability to quickly reserve a PyPI package name. Got a notion? Before it's taken, immediately reserve the product name!
</p>
<table>
<tr>
<td align="center">PyPI Counter</td>
<td align="center">
<a href="TODO">
<img src="TODO">
<a href="http://pepy.tech/project/reserver">
<img src="http://pepy.tech/badge/reserver">
</a>
</td>
</tr>
<tr>
<td align="center">Github Stars</td>
<td align="center">
<a href="https://github.com/openscilab/reserver">
<img src="TODO">
<img src="https://img.shields.io/github/stars/openscilab/reserver.svg?style=social&label=Stars">
</a>
</td>
</tr>
Expand Down Expand Up @@ -84,9 +89,11 @@ Reserver is an open source Python package that provides functionality to easily
- Run `pip install .`

## Usage
### Reserve a specific pypi package name
```pycon
>>> TODO
### Secure your desired PyPI package name!
```python
from reserver import Uploader
uploader = Uploader(PYPI_API_TOKEN, test_pypi= False)
uploader.upload_to_pypi("CONSIDERED_NAME_FOR_YOUR_PACKAGE")
```

## Issues & bug reports
Expand All @@ -97,16 +104,20 @@ Just fill an issue and describe it. We'll check it ASAP! or send an email to [in

You can also join our discord server

<a href="TODO">
<img src="TODO" alt="Discord Channel">
<a href="https://discord.gg/RD2y6SGuY3">
<img src="https://img.shields.io/discord/1064533716615049236.svg?style=for-the-badge" alt="Discord Channel">
</a>

## References

## Show Your Support
### flaticon.com
+ box: <a href="https://www.flaticon.com/free-icons/box" title="box icons">Box icons created by Good Ware - Flaticon</a>
+ reserve plate: <a href="https://www.flaticon.com/free-icons/reserved" title="reserved icons">Reserved icons created by Freepik - Flaticon</a>


### Star this repo
## Show your support

### Star this repo
Give a ⭐️ if this project helped you!

### Donate to our project
Expand Down
9 changes: 9 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
requests==2.31.0
setuptools==69.0.3
wheel==0.42.0
twine==4.0.2
vulture>=1.0
bandit>=1.5.1
pydocstyle>=3.0.0
pytest>=4.3.1
pytest-cov>=2.6.1
Binary file added otherfiles/reserver.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
requests>=1.0.0
setuptools>=40.8.0
wheel>=0.40.0
twine>=4.0.0
1 change: 1 addition & 0 deletions reserver/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
"""Reserver modules."""
from .reserver_param import RESERVER_VERSION
from .reserver_obj import Uploader

__version__ = RESERVER_VERSION
103 changes: 102 additions & 1 deletion reserver/reserver_func.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,103 @@
# -*- coding: utf-8 -*-
"""Functions."""
"""Reserver functions."""
from requests import get
from .reserver_param import PYPI_TEST_URL, PYPI_MAIN_URL
from hashlib import sha256
from time import time
from os import mkdir, rmdir


def get_random_name():
"""
Generate a random str based on current timestamp.
:return: str
"""
return sha256(str(time()).encode("utf-8")).hexdigest()


def does_package_exist(suggested_name, test_pypi):
"""
Check whether a package with the given name exists or not.
:param suggested_name: given name to search in pypi(or test.pypi)
:type suggested_name: str
:param test_pypi: indicates to search in test.pypi or not
:type test_pypi: bool
:return: whether given name does exist in the pypi or not(as a boolean value)
"""
if not isinstance(suggested_name, str):
suggested_name = str(suggested_name)
if test_pypi:
url = PYPI_TEST_URL + "/" + suggested_name + "/"
else:
url = PYPI_MAIN_URL + "/" + suggested_name + "/"
response = get(url, timeout=5)
return not response.status_code == 404


def generate_template_setup_py(package_name):
"""
Generate a template `setup.py` file for given package name.
:param package_name: given name to generate template `setup.py` for it.
:type package_name: str
:return: None
"""
setup_py_content = """
import sys
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
# invalid email
# download url
# url
# project urls
setup(
name =""" + "\"" + package_name + "\"" + """,
packages=[""" + "\"" + package_name + "\"" + "," + """],
version='0.0.0',
description='This name has been reserved using Reserver',
long_description=\"\"\"
This name has been reserved using [Reserver](https://github.com/openscilab/reserver).
\"\"\",
long_description_content_type='text/markdown',
author='Development Team',
author_email='[email protected]',
url='https://url.com',
download_url='https://download_url.com',
keywords="python3 python reserve reserver reserved",
project_urls={
'Source': 'https://github.com/source',
},
install_requires="",
python_requires='>=3.6',
classifiers=[
\'Development Status :: 1 - Planning\',
\'Programming Language :: Python :: 3.6\',
\'Programming Language :: Python :: 3.7\',
\'Programming Language :: Python :: 3.8\',
\'Programming Language :: Python :: 3.9\',
\'Programming Language :: Python :: 3.10\',
\'Programming Language :: Python :: 3.11\',
\'Programming Language :: Python :: 3.12\',
],
license='MIT',
)
"""
with open(package_name + "_setup.py", "w+") as f:
f.writelines(setup_py_content)

try:
mkdir(package_name)
except FileExistsError:
rmdir(package_name)
mkdir(package_name)
with open(package_name + "/__init__.py", "w") as f:
f.write("# -*- coding: utf-8 -*-\n")
f.write("\"\"\"" + package_name + " modules." + "\"\"\"")
Loading

0 comments on commit cd0429e

Please sign in to comment.