Skip to content

Commit

Permalink
add dynamic version to pyproject
Browse files Browse the repository at this point in the history
  • Loading branch information
EeroEternal committed Dec 1, 2022
1 parent f52cf58 commit ebf593f
Show file tree
Hide file tree
Showing 12 changed files with 842 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/magicbag/_version.py export-subst
3 changes: 2 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ jobs:
with:
fetch-depth: 0
python-version: "3.10"
- run: python3 -m pip install --upgrade build && python3 -m build
- name: Build package
run: python3 -m pip install --upgrade build && python3 -m build
- name: Publish package
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
python-version: "3.10"
- name: Create new patch release
run: .github/scripts/release.py
env:
Expand Down
37 changes: 37 additions & 0 deletions doc/dev.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Development records

## versioneer install
[python versioneer](https://github.com/python-versioneer/python-versioneer)

### pyproject config
```toml
[tool.versioneer]
VCS = "git"
style = "pep440"
versionfile_source = "src/magicbag/_version.py"
versionfile_build = "magicbag/_version.py"
tag_prefix = "v"
parentdir_prefix = "magicbag-"
```
check source and build directory carefully


### setup.py config
```python
setup(
name="magicbag",
url="https://github.com/lipicoder/magicbag",
author="lipi",
author_email="[email protected]",
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
packages=find_packages(),
include_package_data=True,
install_requires=requires,
)
```

### create _version.py
```bash
versioneer install --vendor
```
18 changes: 15 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools >= 65", "wheel"]
requires = ["setuptools >= 65", "wheel", "versioneer[toml]"]

[project]
authors = [
Expand All @@ -11,9 +11,10 @@ authors = [
classifiers = [
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
"Topic :: Scientific/Engineering"
]
dependencies = []
description = 'python tool package'
dependencies = ["pytz>=2022.6"]
description = "A library of tools to aid in development"
name = 'magicbag'
readme = "README.md"
dynamic = ["version"]
Expand All @@ -28,6 +29,17 @@ where = ["src"]
[tool.pytest.ini_options]
pythonpath = ["src"]

# See the docstring in versioneer.py for instructions. Note that you must
# re-run 'versioneer.py setup' after changing this section, and commit the
# resulting files.
[tool.versioneer]
VCS = "git"
style = "pep440"
versionfile_source = "src/magicbag/_version.py"
versionfile_build = "magicbag/_version.py"
tag_prefix = "v"
parentdir_prefix = "magicbag-"

[tool.isort]
profile = 'black'

Expand Down
12 changes: 7 additions & 5 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
pytest==7.2.0
pylint==2.15.7
pydocstyle==6.1.1
pycodestyle==2.10.0
setuptools==65.6.3
versioneer[toml]>=0.28
pytest>=7.2.0
pylint>=2.15.7
pydocstyle>=6.1.1
pycodestyle>=2.10.0
setuptools>=65.6.3
pytz~=2022.6
3 changes: 0 additions & 3 deletions requirements.txt

This file was deleted.

104 changes: 104 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
[flake8]
max-line-length = 88
ignore =
# space before : (needed for how black formats slicing)
E203,
# line break before binary operator
W503,
# line break after binary operator
W504,
# module level import not at top of file
E402,
# do not assign a lambda expression, use a def
E731,
# found modulo formatter (incorrect picks up mod operations)
S001,
# controversial
B006,
# controversial
B007,
# controversial
B008,
# setattr is used to side-step mypy
B009,
# getattr is used to side-step mypy
B010,
# tests use assert False
B011,
# tests use comparisons but not their returned value
B015,
# false positives
B019,
# Use of functools.lru_cache or functools.cache on methods can lead to memory leaks.
B020
# Loop control variable overrides iterable it iterates
B023
# Functions defined inside a loop must not use variables redefined in the loop
B301,
# single-letter variables
PDF023,
# "use 'pandas._testing' instead" in non-test code
PDF025,
# If test must be a simple comparison against sys.platform or sys.version_info
Y002,
# Use "_typeshed.Self" instead of class-bound TypeVar
Y019,
# Docstrings should not be included in stubs
Y021,
# Use typing_extensions.TypeAlias for type aliases
Y026,
# Use "collections.abc.*" instead of "typing.*" (PEP 585 syntax)
Y027,
# while int | float can be shortened to float, the former is more explicit
Y041
exclude =
doc/build/*.py,
doc/temp/*.py,
.eggs/*.py,
versioneer.py,
# exclude asv benchmark environments from linting
env
per-file-ignores =
# private import across modules
pandas/tests/*:PDF020
# pytest.raises without match=
pandas/tests/extension/*:PDF009
# os.remove
doc/make.py:PDF008
# import from pandas._testing
pandas/testing.py:PDF014
# can't use fixtures in asv
asv_bench/*:PDF016


[flake8-rst]
max-line-length = 84
bootstrap =
import numpy as np
import pandas as pd
# avoiding error when importing again numpy or pandas
np
# (in some cases we want to do it to show users)
pd
ignore =
# space before : (needed for how black formats slicing)
E203,
# module level import not at top of file
E402,
# line break before binary operator
W503,
# Classes/functions in different blocks can generate those errors
# expected 2 blank lines, found 0
E302,
# expected 2 blank lines after class or function definition, found 0
E305,
# We use semicolon at the end to avoid displaying plot objects
# statement ends with a semicolon
E703,
# comparison to none should be 'if cond is none:'
E711,
exclude =
doc/source/development/contributing_docstring.rst,
# work around issue of undefined variable warnings
# https://github.com/pandas-dev/pandas/pull/38837#issuecomment-752884156
doc/source/getting_started/comparison/includes/*.rst
30 changes: 13 additions & 17 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,20 @@

# -*- coding: utf-8 -*-
from setuptools import find_packages, setup
import versioneer

LONG_DESC = "magicbag is a python tool library."

requires = []

setup(
name="magicbag",
url="https://github.com/lipicoder/magicbag",
author="lipi",
author_email="[email protected]",
description="python tools library",
long_description=LONG_DESC,
zip_safe=True,
classifiers=[
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
],
packages=find_packages(),
include_package_data=True,
install_requires=requires,
)
if __name__ == "__main__":
setup(
name="magicbag",
url="https://github.com/lipicoder/magicbag",
author="lipi",
author_email="[email protected]",
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
packages=find_packages(),
include_package_data=True,
install_requires=requires,
)
3 changes: 3 additions & 0 deletions src/magicbag/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
"random_datetime",
"random_timestamp",
"random_decimal"]

from . import _version
__version__ = _version.get_versions()['version']
Loading

0 comments on commit ebf593f

Please sign in to comment.