Giter Site home page Giter Site logo

opg-data's Introduction

opg-data

This repository contains shared packages and infrastructure code used by various integration points into the case management system used by The Office of The Public Guardian, Sirius.

Creating shared packages

Preparing your code

The main thing to get right is the folder structure.

Create a new folder in the shared_code directory. This will hold all of the code and settings for your package. The name doesn't matter here, just call it something sensible.

To create a project locally, create the following file structure:

[[package_name_holding_folder]]
└── [[package_name]]
    └── __init__.py

Creating the package files

You will now create a handful of files to package up this project and prepare it for distribution. Create the new files listed below and place them in the project’s root directory - you will add content to them in the following steps.

[[package_name_holding_folder]]
├── LICENSE
├── README.md
├── [[package_name]]
│   └── __init__.py
├── setup.py
└── tests

Creating setup.py

setup.py is the build script for setuptools. It tells setuptools about your package (such as the name and version) as well as which code files to include.

Open setup.py and enter the following content.

import setuptools

with open("README.md", "r") as fh:
    long_description = fh.read()

setuptools.setup(
    name="[[package_name]]",
    version="0.0.1",
    author="OPG",
    author_email="[email protected]",
    description="Sirius Service",
    long_description=long_description,
    long_description_content_type="text/markdown",
    url="https://github.com/ministryofjustice/opg-data",
    packages=setuptools.find_namespace_packages(include=['[[package_name]]']),
    classifiers=[
        "Programming Language :: Python :: 3",
        "License :: OSI Approved :: MIT License",
        "Operating System :: OS Independent",
    ],
    python_requires=">=3.7",
)

This is a very simple version of setup.py, you can make this much more complicated if you need to. This example version uses find_namespace_packages to ensure we just build only the project files and don't include things like tests and other unneccessary files.

Packaging and uploading to PyPi

  1. Install the requirements:
cd shared_code
pip3 install -r requirements
  1. Package your code:
python3 setup.py sdist bdist_wheel
  1. Upload to the repo:
python3 -m twine upload dist/*

username: __token__
password: You'll need to obtain this from AWS SecretsManager in the Management Account.

Using your package in another project

  1. Install using pip in the usual way
pip3 install opg_sirius_service==0.0.1

opg-data's People

Contributors

charlesmmarshall avatar cooperaj avatar jackgoodby avatar jamesrwarren avatar jmackown avatar mattmachell avatar mishnajam avatar opg-ci avatar raffers avatar sixdaysandy avatar xaithe avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

uk-gov-mirror

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.