Appearance
Getting started with RepoForge.io
This page demonstrates how to publish your first Python package with RepoForge.io
What is RepoForge.io?
RepoForge.io is a secure, cloud hosted package repository that currently supports the following package types:
- Python
- Docker
- NPM
- Debian
RepoForge.io is a package management tool for any organization that uses the above package types, which allows you to store, manage and distribute your private packaged software securely and reliably.
Pushing your first Python package to RepoForge.io
Once you sign up for RepoForge.io, you'll be issued with a unique Python repository URL in the format https://api.repoforge.io/unique-hash
.
You can retrieve your repository URL from the RepoForge.io dashboard, by clicking on Python Packages > Show me how to publish packages. Make a note of your URL - you'll need it to complete this tutorial.
You can use this unique URL as your endpoint for all of your Python packages. It is fully compatible with public repositories such as https://pypi.org/simple/.
Creating the package
First of all, lets create a python package, if you don’t have one already. Use the following structure to create a simple hello world app.
hello/
helloworld/
__init__.py
setup.py
Next, build a simple hello world function inside __init__.py
:
python
def hello():
return "Hello, World!"
You can configure your build in setup.py
like this:
python
from setuptools import setup
setup(
name='hello-world',
version='0.1',
description='Test',
author='Me',
author_email='me@example.com',
license='MIT',
packages=['helloworld'],
zip_safe=False
)
Finally, you can build a compiled package by running this command from the hello
folder:
bash
python setup.py sdist
Which will produce a built package called helloworld-0.1.tar.gz inside the dist
folder:
hello/
dist/
helloworld-0.1.tar.gz
helloworld/
__init__.py
setup.py
This package is now ready to be pushed to RepoForge.io
Pushing the package
For the sake of this tutorial, we'll be able using twine
to push our hello-world package to RepoForge.io. Twine
is a utility for publishing Python packages on PyPI, but it can also be used to publish packages to alternate repositories, too.
Twine can be installed with pip:
bash
pip install twine
Once installed, you can push your helloworld
package to RepoForge.io with the following commands:
bash
twine upload --repository-url https://api.repoforge.io/unique-hash/ dist/helloworld-0.1.tar.gz
Enter your username: chris@repoforge.io
Enter your password: ********
Uploading helloworld-0.1.tar.gz
100%|█████████████████████████| 3.34k/3.34k [00:00<00:00, 8.23kB/s]
Installing the package elsewhere
Now that you've installed the package, it can be installed on other clients using pip
as follows, using the --index-url
flag to tell pip where to look for the package. Once again, you'll need to enter your username and password so that pip
is able to pull your package from the server.
bash
pip install helloworld --index-url https://api.repoforge.io/unique-hash/
Looking in indexes: https://api.repoforge.io/unique-hash/
User for api.repoforge.io: chris@repoforge.io
Password: ********
Successfully installed helloworld-0.1
You can check that it works correctly with the following command:
bash
python -c "from helloworld import hello; print(hello())"
# Hello, World!
Next steps
Congratulations, you have now learnt how to push Python packages to, and install them from, your RepoForge.io repository. You might want to have a look at the following topics next.