Giter Site home page Giter Site logo

Parse 'Requires-Dist' markers about pex HOT 2 CLOSED

zmanji avatar zmanji commented on August 25, 2024
Parse 'Requires-Dist' markers

from pex.

Comments (2)

wickman avatar wickman commented on August 25, 2024

After reading PEP345/426 more carefully, it probably makes sense for the PythonInterpreter ID_PY script to export all the defined environment markers for that interpreter:

  • python_version: '{0.major}.{0.minor}'.format(sys.version_info)
  • python_full_version: see definition below
  • os_name: os.name
  • sys_platform: sys.platform
  • platform_release: platform.release()
  • platform_version: platform.version()
  • platform_machine: platform.machine()
  • platform_python_implementation: platform.python_implementation()
  • implementation_name: sys.implementation.name
  • implementation_version: see definition below
def format_full_version(info):
    version = '{0.major}.{0.minor}.{0.micro}'.format(info)
    kind = info.releaselevel
    if kind != 'final':
        version += kind[0] + str(info.serial)
    return version

python_full_version = format_full_version(sys.version_info)
implementation_version = format_full_version(sys.implementation.version)

we can then just implement the PEP345/426 marker evaluator and have it run in the context of the PythonInterpreter.

the only challenge here is to build PEX files for other platforms we either need to get a handle to the remote interpreter or just fake it (e.g. if we see --platform=linux-x86_64 on the pex command line, we can't really actually support anything requiring platform_release/platform_version markers.)

from pex.

jsirois avatar jsirois commented on August 25, 2024

This state of affairs is now finally fully buttoned up with enhancements to PythonInterpreter: https://github.com/pantsbuild/pex/blob/3e71bc7896935a8177e9bbe9399769c3522528dc/pex/interpreter.py#L278-L286, AbbreviatedPlatform (--platform): https://github.com/pantsbuild/pex/blob/2b3bdee8cd99ffab0538a63fdd36de8de356f857/pex/targets.py#L214-L238 and the introduction of CompletePlatform (--complete-platform): https://github.com/pantsbuild/pex/blob/2b3bdee8cd99ffab0538a63fdd36de8de356f857/pex/targets.py#L246-L280

The abbreviated --platform case does not have enough information to form a full set of environment markers; so the surrounding code just hard fails iff solving of a resolve requires evaluating the missing env markers; otherwise, it proceeds correctly. This usually works since most env markers in the wild are python_version markers, but it fails when it should with the remedy of supplying a --complete-platform.

from pex.

Related Issues (20)

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.