This contributing guide is meant for internal LinkedIn maintainers. We are not currently accepting contributions from outside of LinkedIn at this time. If you are not a LinkedIn engineer, we appreciate your interest in our library and encourage you to provide bug reports or suggestions by opening an issue in the GitHub repo.
Here are instructions for setting up the project on your local machine for testing and development.
- Clone the project into a new directory:
git clone https://github.com/linkedin-developers/linkedin-api-python-client.git
- Install
poetry
on your machine:pip install --user poetry
- From the project root directory, install all the packages:
poetry install
- Install git hook scripts:
poetry run pre-commit install
Here are some other useful commands:
- Activate your virtual environment from the project root directory:
poetry shell
- Run tests or examples. For example, inside the activated virtual environment:
python3 examples/get-profile.py
- Deactivate your virtual environment at any time using
exit
- Run pre-commit checks on all files:
poetry run pre-commit run --all-files
- To install packages exactly as specified in poetry.lock:
poetry install
- To upgrade packages to latest versions and update the poetry.lock:
poetry update
Pre-commit checks perform linting, some of which requires python. To avoid issues, make sure you run poetry shell
before creating a commit.
Please follow conventional commits for standardized commit messages.
Make sure the documentation is consistent with any code changes in the same PR.
If there are code changes that might affect the example code (/examples), ensure each example runs correctly, or update accordingly.
From the project root directory, run poetry run pytest
.
- Create an account on Test PyPI
- Create an account on PyPI
- Get added as a maintainer to the project on pypi.org
- Configure Test PyPI
- Add test repo:
poetry config repositories.test-pypi https://test.pypi.org/legacy/
- Get token to upload packages here: https://test.pypi.org/manage/account/token/
- Copy the token and store it in the poetry config:
poetry config pypi-token.test-pypi pypi-XXXX
(Replace the last value with actual token value)
- Add test repo:
- Configure PyPI
- Get token to upload packages here: https://pypi.org/manage/account/token/
- Copy the token and store it in the poetry config:
poetry config pypi-token.pypi pypi-XXXX
(Replace the last value with actual token value)
- Bump the version in pyproject.toml:
poetry version prerelease
(for testing) orpoetry version <BUMP_RULE>
based on changes - Create source archive and a wheel for the package:
poetry build
- If you've made changes to pyproject.toml, run a check to make sure package metadata will be rendered properly on PyPI:
twine check dist/*
- If you want to test the package upload first:
- Upload to TestPyPI (will used the previously saved token):
poetry publish -r test-pypi
- Search for your package on TestPyPI ("linkedin-api-client") and confirm it looks good.
- Install and test out the published test package in a local project: For example:
python -m pip install -i https://test.pypi.org/simple linkedin-api-client==0.1.1a0
- Note: You cannot overwrite existing versions in TestPyPI or PyPI, so for testing, you would need to increment the version if it already exists.
- Upload to TestPyPI (will used the previously saved token):
- Once everything looks good, publish to PyPI:
poetry publish
- Tag and release
- Tag the last commit:
git tag -a v<version> -m "Release <version>" <commit-hash>
. For example:git tag -a v0.1.0 -m "Release 0.1.0" 043cc4ea
- Push the local tag:
git push origin --tags
- Create a new release in the Github repo based on the tagged commit.
- Tag the last commit: