Git Product home page Git Product logo

trampolim's Introduction

trampolim

test codecov check Documentation Status PyPI version

A modern Python build backend.

Features

  • Task system, allowing to run arbitrary Python code during the build process
  • Automatic version detection from git repos and git archives
  • Easy to use CLI -- build, publish, check for errors and recommended practices (Planned)

Usage

trampolim implements PEP 621. Your pyproject.toml should look something like this:

[build-system]
build-backend = 'trampolim'
requires = ['trampolim~=0.1.0']

[project]
name = 'sample_project'
version = '1.0.0'
description = 'A sample project'
readme = 'README.md'
requires-python = '>=3.7'
license = { file = 'LICENSE' }
authors = [
  { name = 'Filipe Laíns', email = '[email protected]' },
]
classifiers = [
  'Development Status :: 4 - Beta',
  'Programming Language :: Python',
]

dependencies = [
  'dependency',
  'some-backport ; python_version < "3.8"',
]

[project.optional-dependencies]
test = [
  'pytest',
  'pytest-cov',
]

[project.scripts]
sample_entrypoint = 'sample_project:entrypoint_function'

[project.urls]
homepage = 'https://my-sample-project-website.example.com'
documentation = 'https://github.com/some-user/sample-project'
repository = 'https://github.com/some-user/sample-project'
changelog = 'https://github.com/some-user/sample-project/blob/master/CHANGELOG.rst'

trampolim's People

Contributors

ffy00 avatar henryiii avatar pre-commit-ci[bot] avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

trampolim's Issues

Support for src structure

Src structure has some important benefits. Running something like pytest needs /src structure or otherwise it loads from the local folder instead. If you have compiled extensions, or if you use importlib stuff, it's critical to load the installed package, not the local folder. See, for example, scikit-build/cmake-python-distributions#145, which was motivated by scikit-build/cmake-python-distributions#139 (comment) for an example of problems in the wild.

However, not having editable support for now makes it a bit less attractive, since regular layout can run without installing in a pinch (if you avoid things like importlib), so maybe it would be best to wait till editable support is available (maybe best to use PEP 517 editable mode if it comes? PEP 660 or 662, whichever is accepted).

Version 0.0.4 doesn't support dynamic version

Upgrading to 0.0.4 breaks the dynamic version using TRAMPOLIM_VCS_VERSION:

Processing /Users/henryschreiner/git/scikit-hep/cookie/.nox/tests-trampolim/tmp/cookie-trampolim
  DEPRECATION: A future pip version will change local packages to be built in-place without first copying to a temporary directory. We recommend you use --use-feature=in-tree-build to test your packages with this new behavior before it becomes the default.
   pip 21.3 will remove support for this functionality. You can find discussion regarding this at https://github.com/pypa/pip/issues/7555.
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Installing backend dependencies: started
  Installing backend dependencies: finished with status 'done'
    Preparing wheel metadata: started
    Preparing wheel metadata: finished with status 'error'
    ERROR: Command errored out with exit status 1:
     command: /Users/henryschreiner/git/scikit-hep/cookie/.nox/tests-trampolim/bin/python /Users/henryschreiner/git/scikit-hep/cookie/.nox/tests-trampolim/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpbyha2ong
         cwd: /private/tmp/pip-req-build-cqa182lv
    Complete output (23 lines):
    Traceback (most recent call last):
      File "/Users/henryschreiner/git/scikit-hep/cookie/.nox/tests-trampolim/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 143, in prepare_metadata_for_build_wheel
        hook = backend.prepare_metadata_for_build_wheel
    AttributeError: module 'trampolim' has no attribute 'prepare_metadata_for_build_wheel'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/Users/henryschreiner/git/scikit-hep/cookie/.nox/tests-trampolim/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 349, in <module>
        main()
      File "/Users/henryschreiner/git/scikit-hep/cookie/.nox/tests-trampolim/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 331, in main
        json_out['return_val'] = hook(**hook_input['kwargs'])
      File "/Users/henryschreiner/git/scikit-hep/cookie/.nox/tests-trampolim/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 147, in prepare_metadata_for_build_wheel
        whl_basename = backend.build_wheel(metadata_directory, config_settings)
      File "/private/tmp/pip-build-env-osr5lkga/overlay/lib/python3.9/site-packages/trampolim/__init__.py", line 62, in build_wheel
        builder.build(wheel_directory)
      File "/private/tmp/pip-build-env-osr5lkga/overlay/lib/python3.9/site-packages/trampolim/_wheel.py", line 38, in build
        whl.writestr(f'{whl.dist_info_path}/METADATA', bytes(self._project._meta.as_rfc822()))
      File "/private/tmp/pip-build-env-osr5lkga/overlay/lib/python3.9/site-packages/pep621.py", line 243, in as_rfc822
        self.write_to_rfc822(message)
      File "/private/tmp/pip-build-env-osr5lkga/overlay/lib/python3.9/site-packages/pep621.py", line 250, in write_to_rfc822
        raise ConfigurationError('Missing version field')
    pep621.ConfigurationError: Missing version field

See https://github.com/scikit-hep/cookie/pull/41/checks?check_run_id=3804995613

Pinning to trampolim 0.0.3 fixes the issue.

Exactly sitting on a tag fails

This line breaks when this matches a tag exactly (which it usually should do if you are building wheels and SDists for publication?)

'git', 'describe', '--tags'

$ git describe --tags
v0.1.0

You want --long to force the commits since tag and current hash. Or you should check to see if -'s are present, then assume it's exactly a release then.

$ git describe --tags --long
v0.1.0-0-g165f120

Example failure from a nox run using scikit-hep/cookie:

nox -s 'dist(trampolim)'
nox > Running session dist(trampolim)
nox > Creating virtual environment (virtualenv) using python3.9 in .nox/dist-trampolim
nox > python -m pip install cookiecutter build twine
nox > cd .nox/dist-trampolim/tmp
nox > cookiecutter --no-input /Users/henryschreiner/git/scikit-hep/cookie --config-file=input.yml
nox > cd cookie-trampolim
nox > git init -q
nox > git add .
nox > git commit -qm feat: initial version
nox > git tag v0.1.0
nox > python -m build
nox > Command python -m build failed with exit code 1:
Found existing installation: setuptools 57.0.0
Uninstalling setuptools-57.0.0:
  Successfully uninstalled setuptools-57.0.0
Collecting trampolim~=0.0.3
  Using cached trampolim-0.0.3-py3-none-any.whl (13 kB)
Collecting packaging
  Using cached packaging-21.0-py3-none-any.whl (40 kB)
Collecting toml
  Using cached toml-0.10.2-py2.py3-none-any.whl (16 kB)
Collecting pyparsing>=2.0.2
  Using cached pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
Installing collected packages: pyparsing, toml, packaging, trampolim
Successfully installed packaging-21.0 pyparsing-2.4.7 toml-0.10.2 trampolim-0.0.3
Traceback (most recent call last):
  File "/Users/henryschreiner/git/scikit-hep/cookie/.nox/dist-trampolim/lib/python3.9/site-packages/pep517/in_process/_in_process.py", line 280, in <module>
    main()
  File "/Users/henryschreiner/git/scikit-hep/cookie/.nox/dist-trampolim/lib/python3.9/site-packages/pep517/in_process/_in_process.py", line 263, in main
    json_out['return_val'] = hook(**hook_input['kwargs'])
  File "/Users/henryschreiner/git/scikit-hep/cookie/.nox/dist-trampolim/lib/python3.9/site-packages/pep517/in_process/_in_process.py", line 236, in build_sdist
    return backend.build_sdist(sdist_directory, config_settings)
  File "/private/tmp/build-env-cgul0fht/lib/python3.9/site-packages/trampolim/__init__.py", line 44, in build_sdist
    project = trampolim._build.Project()
  File "/private/tmp/build-env-cgul0fht/lib/python3.9/site-packages/trampolim/_build.py", line 117, in __init__
    self.version  # calculate version
  File "/usr/local/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/functools.py", line 969, in __get__
    val = self.func(instance)
  File "/private/tmp/build-env-cgul0fht/lib/python3.9/site-packages/trampolim/_build.py", line 289, in version
    tag, r, commit = subprocess.check_output([
ValueError: not enough values to unpack (expected 3, got 1)

ERROR Backend subproccess exited when trying to invoke build_sdist

This works correctly in setuptools_scm.

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.