Skip to main content

flit_pytest_circleci_template is a sample project to show how to use flit, pytest, and circleci to automatically build, test and publish Python packages.

Project description

flit_pytest_circleci_template is a sample project to show how to use:

  • flit to build a python package, configured in pyproject.toml
  • pytest to test a python package, configured in pyproject.toml
  • circleci for to build the python package, test it, and publish to pypi automatically.

If you prefer to use github actions, here is a sample using flit in a github action to build a package and publish to testpypi. A later version of that file will no doubt publish to pypi instead of testpypi.

Getting Ready

To proceed with your own package and publishing to pypi:

  • copy the .circleci folder to your project and add to your git repo. Currently it has only one file config.yml that configures the build pipeline for a python project. Here is the .circleci/config.yml and pyproject.toml for this project.
  • Create the pyproject.toml as normally required to build your package with flit. Include in test dependencies pytest and any other python packages that need to be installed for testing:
[project.optional-dependencies]
test = [
    "pytest >=7.1.2",
]
  • Add testpaths to [tool.pytest.ini_options] identifying where your tests are located. Specifying minversion and addopts is also recommended:
[tool.pytest.ini_options]
minversion = "7.1.2"
addopts = "--capture=tee-sys "

testpaths= [
    "test",
]

When you are satisifed with your tests, review the config.yml and see if there are any obvious changes you require. You may not need any but you might elect to update to the latest python orb or specific python image you would like to use to build and test your python package.

The publish step will normally fail if there is already a package in pypi with the same version number. Which is desired behavior. When you are ready to publish, increase the version number (in pyproject.toml or init.py depending on how the project is set up.).

** You can elect to publish to testpypi by tweaking the twine command in config.yml **

Configure circleci

Create a circleci account if you don't have one and add your github repository as a project. Get the build at least running.

Using Project Settings, add Environment variables TWINE_USERNAME and TWINE_PASSWORD. These are the credentials you use to publish to pypi or testpypi. Until you set those variables, the publish stop obviously will fail, but the package build and test steps should work.

License

You can do whatever you want with the code in this repository and apply whatever license you want to copies or modifications in your own project. This project is mean to be a helpful starting point for people who want to get circleci to build and publish python packages.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flit_pytest_circleci_template-0.2.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file flit_pytest_circleci_template-0.2.tar.gz.

File metadata

File hashes

Hashes for flit_pytest_circleci_template-0.2.tar.gz
Algorithm Hash digest
SHA256 97618d6979053ba2b58bb3d37a661857527298910512981b6dd1ef191d03db61
MD5 26d39831fc5f08aea96ed7f4442f2414
BLAKE2b-256 79f071fc46fa69cd599609451b9815d9ded3f0c40f5114d4dd93e60028b9aaad

See more details on using hashes here.

File details

Details for the file flit_pytest_circleci_template-0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for flit_pytest_circleci_template-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7750e28cada84110f7d2e1c8571813879e680eb047b1d2b76feeb385c7f28a66
MD5 daf50643b3bd245cc1896c9ac4aadd8e
BLAKE2b-256 64fbff34d8ffbb636b6eb7012322e975e9e7d8cce7615ff541cef270edb5957e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page