Zachary Palmer

Zachary Palmer

1558079334

Guide from a Python project to an open source package

Excited about your python project? Do you want to share Python open source projects for beginners? Packaging, publishing your python projects source code is a great way to get other people interesting python projects. Here is a simple step by step guide to build and publish your first python package

We’ll describe all the steps we’ve been through to create Scitime, a package that gives an estimate of algorithm training times (you can learn more about Scitime here).

Note: We will assume that you already have a python projects source code in GitHub that you would like to package and publish.

Step 0: Have your project licensed

Before doing anything else, your project should have a license since it’s going to be open source. Depending on how you’d like your package to be used, many licenses are available. Some usual licenses for open source projects are MIT or BSD.

To add a license to your project, simply add a [LICENSE](https://github.com/nathan-toubiana/scitime/blob/master/LICENSE) file to the repository root by following the steps described here.

Step 1: make your code publish-ready

There are a few preliminary things you need to do to have your Python project package-able:

  • Your project structure needs to be in place. Usually, the root of the repository contains a folder with the name of the repository — this is where the core project code should be. What’s outside of this folder is the extra code that’s necessary to run and build the package (tests, documentation, etc.)
  • The core folder should include one (or more) module(s) and an [**__init__.py**](https://github.com/nathan-toubiana/scitime/blob/master/scitime/__init__.py) file which imports the classes/functions you’ll want the end user to have access to.
  • Ideally, a proper logging system (instead of prints) should be set by using the logging package.
  • Ideally, your core code should be organized in one or more classes.
from .estimate import Estimator

import logging

class LogMixin(object):
    @property
    def logger(self):
        name = '.'.join([self.__module__, self.__class__.__name__])
        FORMAT = '%(name)s:%(levelname)s:%(message)s'
        logging.basicConfig(format=FORMAT, level=logging.DEBUG)
        logger = logging.getLogger(name)
        return logger

Step 2: Create a setup.py with setuptools

Once your project has a set structure, you should then add a setup.py file at the root of the repository. This mostly helps to automate all the publishing and version maintaining processes. Here’s an example of what a setup.py should look like (source here).

from setuptools import setup
from os import path

DIR = path.dirname(path.abspath(__file__))
INSTALL_PACKAGES = open(path.join(DIR, 'requirements.txt')).read().splitlines()

with open(path.join(DIR, 'README.md')) as f:
    README = f.read()

setup(
    name='scitime',
    packages=['scitime'],
    description="Training time estimator for scikit-learn algorithms",
    long_description=README,
    long_description_content_type='text/markdown',
    install_requires=INSTALL_PACKAGES,
    version='0.0.2',
    url='http://github.com/nathan-toubiana/scitime',
    author='Gabriel Lerner & Nathan Toubiana',
    author_email='toubiana.nathan@gmail.com',
    keywords=['machine-learning', 'scikit-learn', 'training-time'],
    tests_require=[
        'pytest',
        'pytest-cov',
        'pytest-sugar'
    ],
    package_data={
        # include json and pkl files
        '': ['*.json', 'models/*.pkl', 'models/*.json'],
    },
    include_package_data=True,
    python_requires='>=3'
)

A few notes:

  • If your package has dependencies, a clean way to handle these is to add them in the setup file, through the install_requires argument (if the list is long you can always point to a requirement.txt file as done above)
  • If you want metadata (from the repository) to be downloaded when anyone installs the package, you should add these through the package_data argument
  • More information about the setup() function can be found here

Note: steps 3 to 6 are optional (but highly recommended), however you can jump straight to step 7 if you want to publish your package right now.

Step 3: Set local tests and test coverage checks

If it is not already the case, at this point, your project should definitely have unit tests. Although there are many frameworks that can help you do that, one simple way of doing it is using pytest. All tests should be in a dedicated folder (named tests/ or testing/ for example). In that folder, put all the test files you need in order to cover as much of your core code as possible. Here’s an example of how to write a unit test. Here’s also one of our Scitime’s test files.

Once in place, you can run your tests locally by running python -m pytest from the repository root.

Once your tests are created, you should also be able to estimate the coverage. This is important as you want to maximize the amount of code that’s tested in your project (to reduce the amount of unexpected bugs).

A lot of frameworks are available for this as well, for Scitime we used codecov. You can decide on a threshold of minimum coverage allowed by creating a .codecov.yml file and also decide on what files to include in the coverage analysis by creating a .coveragerc file.

comment: false

coverage:
  status:
    project:
      default:
        target: auto
        threshold: 10%
    patch:
      default:
        target: auto
        threshold: 10%

Example of a .codecov.yml file

[run]
branch = True
source = scitime
include = */scitime/*
omit =
    */_data.py
    */setup.py

Example of a .coveragerc file

Step 4: Standardize syntax and code style

You’ll also need to make sure that your code follows the PEP8 guidelines (i.e has a standard style and that the syntax is correct). Again, a lot of tools can help here. We used flake8.

Step 5: Create a proper documentation

Now that your project has tests and a good to structure, it should be a good time to add a proper documentation. First thing is to have a nice readme file that will show up on your Github repo root. Once this is done, here are a few additional “nice to have”:

  • Pull Request & issue templates: when a new PR or issue is created, these files permit you to template the descriptions as you wish. Follow these steps for PRs and these steps for issues to create them. Here are Scitime’s PR template and issue template.
  • A contribution guide. This should be a short guide on how you want external users to contribute to your package. Here’s Scitime’s contribution guide.
  • A code of conduct (here’s Scitime’s).
  • Tags and a description (see screenshot below).
  • Badges in the readme file (here’s a nice article on how to set these up).

As the readme file should be quite synthesized, it’s also pretty standard to have a more in-depth documentation. You can use sphinx to do so, and then host the documentation on readthedocs (here’s Scitime’s example). The documentation related files are usually in a docs/ folder (as done for Scitime). Here’s a nice sphinx & readthedocs tutorial.

python project for beginners

Example of a repo that has tags and a description

Step 6: Set up continuous integration

At this point, your project is not far away from being ready to be published. However, it seems a little overwhelming to have to deal with updating the docs, running the tests and checking the style and coverage after each commit. Fortunately, Continuous Integration (CI) helps you with that. You can use webhooks to GitHub to automate all these things after each commit. Here’s the set of CI tools we used for Scitime:

  • For running tests, we used travis-ci and appveyor (for tests on windows platforms). For travis-ci, besides setting up the webhooks on the repository, you also have to create a .travis.yml file in which you can not only run tests but also upload updated coverage outputs and check style and format. Same goes for appveyor by creating a appveyor.yml file
  • Codecov and readthdocs also have dedicated webhooks
language: python
python:
  - "3.6"
# command to install dependencies
install:
  - pip install -r requirements.txt
  - pip install flake8
  - pip install pytest-cov
  - pip install codecov
# command to run tests
script:
  - python -m pytest --cov=scitime
  - ./build_tools/flake_diff.sh
after_success:
  - codecov 

Example of a .travis.yml file: note that here, for each commit, the tests are run along with the test coverage checks. But there’s also a flake8 check (the logic being defined in the flake_diff.sh file)

environment:

  matrix:

    - PYTHON: "C:\\Python36-x64"

install:
  # We need wheel installed to build wheels
  - "%PYTHON%\\python.exe -m pip install -r requirements.txt"
  - "%PYTHON%\\python.exe -m pip install pytest==3.2.1"

build: off

test_script:

  - "%PYTHON%\\python.exe -m pytest"

Example of a appveyor.yml file: here, we only run the tests

This should make the whole process of updating the repository a lot easier.

python projects source code

Example of commit history with integrated webhooks

Step 7: Create your first release and publication

At this point, your soon-to-be package should look similar to this:

your_package/
   __init__.py
   your_module.py
docs/
tests/
setup.py
travis.yml
appveyor.yml
.coveragerc
.codecov.yml
README.md
LICENSE
.github/
   CODE_OF_CONDUCT.md
   CONTRIBUTING.md
   PULL_REQUEST_TEMPLATE.md
   ISSUE_TEMPLATE/

It’s now ready to be published! The first thing to do is to create your first release on GitHub — this is to keep track of the state of your project at a given point in time, a release should be created each time the version changes. You can follow this to create the release.

Once done, the only thing left to do is to publish your package. The most common platforms to publish a python package are PyPI and Conda. We will describe how to publish in both:

  • For PyPI, you first need to create an account, and then follow these steps using twine. This should be fairly straightforward, and PyPI also provides a test environment that can be used right before the actual deploy. The latter basically consists of creating a source distribution (python setup.py sdist) and uploading it with twine (twine upload dist/*). Once done, there should be a PyPI page corresponding to your package (here’s Scitime’s) and anyone should be able to install your package running the pip command.
  • For conda, we recommend publishing your package through conda-forge which is a community that helps you publish and maintain your package through their conda channel. You can follow these steps to add your package to the community, you will then be added to the conda-forge GitHub organization and be able to maintain your package quite easily (here’s Scitime’s conda-forge page) — anyone should then be able to install your package running the conda command.

All done!

You should now have your package finally published and available to anyone! Although most of the work is done, you’ll still have to maintain your project as you need to make some updates: this basically means changing the versions each time you make significant changes, creating new releases and going through step 7 again.

Originally published on https://medium.freecodecamp.org

#python

What is GEEK

Buddha Community

Guide from a Python project to an open source package

22 Interesting Python Open Source Project Ideas & Topics for Beginners [2021]

Python is among the most popular programming languages on the planet, and there are many reasons behind this fame. One of those reasons is a large number of open-source projects and libraries available for this language. From machine learning to animation, there’s a Python project for nearly everything. If you want to become a proficient Python developer, you should be familiar with some of these projects (if not all).

That’s why in this article, we’ll discuss different Python projects with source code Github. Because Python has applications in various industries, you might find many projects to help you complete your tasks. You should choose projects according to your interests and your experience. You can bookmark this article for future reference. Let’s get started.

Here are a few of the Python Open Source Project Ideas –

#data science #open source project ideas #open source projects #project ideas #python #python open source

Ray  Patel

Ray Patel

1623348300

Top 8 Java Open Source Projects You Should Get Your Hands-on [2021]

Learning about Java is no easy feat. It’s a prevalent and in-demand programming language with applications in numerous sectors. We all know that if you want to learn a new skill, the best way to do so is through using it. That’s why we recommend working on projects.

So if you’re a Java student, then you’ve come to the right place as this article will help you learn about the most popular Java open source projects. This way, you’d have a firm grasp of industry trends and the programming language’s applications.

However, before we discuss its various projects, it’s crucial to examine the place where you can get those projects – GitHub. Let’s begin.

#full stack development #java open source projects #java projects #open source projects #top 8 java open source projects #java open source projects

Ray  Patel

Ray Patel

1619518440

top 30 Python Tips and Tricks for Beginners

Welcome to my Blog , In this article, you are going to learn the top 10 python tips and tricks.

1) swap two numbers.

2) Reversing a string in Python.

3) Create a single string from all the elements in list.

4) Chaining Of Comparison Operators.

5) Print The File Path Of Imported Modules.

6) Return Multiple Values From Functions.

7) Find The Most Frequent Value In A List.

8) Check The Memory Usage Of An Object.

#python #python hacks tricks #python learning tips #python programming tricks #python tips #python tips and tricks #python tips and tricks advanced #python tips and tricks for beginners #python tips tricks and techniques #python tutorial #tips and tricks in python #tips to learn python #top 30 python tips and tricks for beginners

Ray  Patel

Ray Patel

1619636760

42 Exciting Python Project Ideas & Topics for Beginners [2021]

Python Project Ideas

Python is one of the most popular programming languages currently. It looks like this trend is about to continue in 2021 and beyond. So, if you are a Python beginner, the best thing you can do is work on some real-time Python project ideas.

We, here at upGrad, believe in a practical approach as theoretical knowledge alone won’t be of help in a real-time work environment. In this article, we will be exploring some interesting Python project ideas which beginners can work on to put their Python knowledge to test. In this article, you will find 42 top python project ideas for beginners to get hands-on experience on Python

Moreover, project-based learning helps improve student knowledge. That’s why all of the upGrad courses cover case studies and assignments based on real-life problems. This technique is ideally for, but not limited to, beginners in programming skills.

But first, let’s address the more pertinent question that must be lurking in your mind:

#data science #python project #python project ideas #python project ideas for beginners #python project topics #python projects #python projects for beginners

Autumn  Blick

Autumn Blick

1593867420

Top Android Projects with Source Code

Android Projects with Source Code – Your entry pass into the world of Android

Hello Everyone, welcome to this article, which is going to be really important to all those who’re in dilemma for their projects and the project submissions. This article is also going to help you if you’re an enthusiast looking forward to explore and enhance your Android skills. The reason is that we’re here to provide you the best ideas of Android Project with source code that you can choose as per your choice.

These project ideas are simple suggestions to help you deal with the difficulty of choosing the correct projects. In this article, we’ll see the project ideas from beginners level and later we’ll move on to intermediate to advance.

top android projects with source code

Android Projects with Source Code

Before working on real-time projects, it is recommended to create a sample hello world project in android studio and get a flavor of project creation as well as execution: Create your first android project

Android Projects for beginners

1. Calculator

build a simple calculator app in android studio source code

Android Project: A calculator will be an easy application if you have just learned Android and coding for Java. This Application will simply take the input values and the operation to be performed from the users. After taking the input it’ll return the results to them on the screen. This is a really easy application and doesn’t need use of any particular package.

To make a calculator you’d need Android IDE, Kotlin/Java for coding, and for layout of your application, you’d need XML or JSON. For this, coding would be the same as that in any language, but in the form of an application. Not to forget creating a calculator initially will increase your logical thinking.

Once the user installs the calculator, they’re ready to use it even without the internet. They’ll enter the values, and the application will show them the value after performing the given operations on the entered operands.

Source Code: Simple Calculator Project

2. A Reminder App

Android Project: This is a good project for beginners. A Reminder App can help you set reminders for different events that you have throughout the day. It’ll help you stay updated with all your tasks for the day. It can be useful for all those who are not so good at organizing their plans and forget easily. This would be a simple application just whose task would be just to remind you of something at a particular time.

To make a Reminder App you need to code in Kotlin/Java and design the layout using XML or JSON. For the functionality of the app, you’d need to make use of AlarmManager Class and Notifications in Android.

In this, the user would be able to set reminders and time in the application. Users can schedule reminders that would remind them to drink water again and again throughout the day. Or to remind them of their medications.

3. Quiz Application

Android Project: Another beginner’s level project Idea can be a Quiz Application in android. Here you can provide the users with Quiz on various general knowledge topics. These practices will ensure that you’re able to set the layouts properly and slowly increase your pace of learning the Android application development. In this you’ll learn to use various Layout components at the same time understanding them better.

To make a quiz application you’ll need to code in Java and set layouts using xml or java whichever you prefer. You can also use JSON for the layouts whichever preferable.

In the app, questions would be asked and answers would be shown as multiple choices. The user selects the answer and gets shown on the screen if the answers are correct. In the end the final marks would be shown to the users.

4. Simple Tic-Tac-Toe

android project tic tac toe game app

Android Project: Tic-Tac-Toe is a nice game, I guess most of you all are well aware of it. This will be a game for two players. In this android game, users would be putting X and O in the given 9 parts of a box one by one. The first player to arrange X or O in an adjacent line of three wins.

To build this game, you’d need Java and XML for Android Studio. And simply apply the logic on that. This game will have a set of three matches. So, it’ll also have a scoreboard. This scoreboard will show the final result at the end of one complete set.

Upon entering the game they’ll enter their names. And that’s when the game begins. They’ll touch one of the empty boxes present there and get their turn one by one. At the end of the game, there would be a winner declared.

Source Code: Tic Tac Toe Game Project

5. Stopwatch

Android Project: A stopwatch is another simple android project idea that will work the same as a normal handheld timepiece that measures the time elapsed between its activation and deactivation. This application will have three buttons that are: start, stop, and hold.

This application would need to use Java and XML. For this application, we need to set the timer properly as it is initially set to milliseconds, and that should be converted to minutes and then hours properly. The users can use this application and all they’d need to do is, start the stopwatch and then stop it when they are done. They can also pause the timer and continue it again when they like.

6. To Do App

Android Project: This is another very simple project idea for you as a beginner. This application as the name suggests will be a To-Do list holding app. It’ll store the users schedules and their upcoming meetings or events. In this application, users will be enabled to write their important notes as well. To make it safe, provide a login page before the user can access it.

So, this app will have a login page, sign-up page, logout system, and the area to write their tasks, events, or important notes. You can build it in android studio using Java and XML at ease. Using XML you can build the user interface as user-friendly as you can. And to store the users’ data, you can use SQLite enabling the users to even delete the data permanently.

Now for users, they will sign up and get access to the write section. Here the users can note down the things and store them permanently. Users can also alter the data or delete them. Finally, they can logout and also, login again and again whenever they like.

7. Roman to decimal converter

Android Project: This app is aimed at the conversion of Roman numbers to their significant decimal number. It’ll help to check the meaning of the roman numbers. Moreover, it will be easy to develop and will help you get your hands on coding and Android.

You need to use Android Studio, Java for coding and XML for interface. The application will take input from the users and convert them to decimal. Once it converts the Roman no. into decimal, it will show the results on the screen.

The users are supposed to just enter the Roman Number and they’ll get the decimal values on the screen. This can be a good android project for final year students.

8. Virtual Dice Roller

Android Project: Well, coming to this part that is Virtual Dice or a random no. generator. It is another simple but interesting app for computer science students. The only task that it would need to do would be to generate a number randomly. This can help people who’re often confused between two or more things.

Using a simple random number generator you can actually create something as good as this. All you’d need to do is get you hands-on OnClick listeners. And a good layout would be cherry on the cake.

The user’s task would be to set the range of the numbers and then click on the roll button. And the app will show them a randomly generated number. Isn’t it interesting ? Try soon!

9. A Scientific Calculator App

Android Project: This application is very important for you as a beginner as it will let you use your logical thinking and improve your programming skills. This is a scientific calculator that will help the users to do various calculations at ease.

To make this application you’d need to use Android Studio. Here you’d need to use arithmetic logics for the calculations. The user would need to give input to the application that will be in terms of numbers. After that, the user will give the operator as an input. Then the Application will calculate and generate the result on the user screen.

10. SMS App

Android Project: An SMS app is another easy but effective idea. It will let you send the SMS to various no. just in the same way as you use the default messaging application in your phone. This project will help you with better understanding of SMSManager in Android.

For this application, you would need to implement Java class SMSManager in Android. For the Layout you can use XML or JSON. Implementing SMSManager into the app is an easy task, so you would love this.

The user would be provided with the facility to text to whichever number they wish also, they’d be able to choose the numbers from the contact list. Another thing would be the Textbox, where they’ll enter their message. Once the message is entered they can happily click on the send button.

#android tutorials #android application final year project #android mini projects #android project for beginners #android project ideas #android project ideas for beginners #android projects #android projects for students #android projects with source code #android topics list #intermediate android projects #real-time android projects