Git Product home page Git Product logo

Comments (12)

amangarg96 avatar amangarg96 commented on June 2, 2024

To reproduce the issue, create the following python package:

  • foo.py
import click

@click.group()
def bar():
    pass

@click.command()
def message():
    """Display the current version."""
    click.echo("Message!")

bar.add_command(message)
  • setup.py
from setuptools import setup, find_packages
import utils 

setup(name='testing-package',
      version='0.0.2',
      entry_points={
        "console_scripts": ['bar = utils.foo:bar']
        }, 
      packages=find_packages(exclude=['contrib', 'docs', '*.tests'])
      )

Directory structure:

C:\USERS\AMAN.GARG\TESTING-PACKAGE
│   setup.py
└───utils
        foo.py
        __init__.py

Error occurs when you run bar message

from conda-pack.

jcrist avatar jcrist commented on June 2, 2024

Hmmm, looks like the exe's provided by setuptools (e.g. things installed with pip) do need prefix rewriting, whereas those provided by conda packages don't (no absolute paths found in those). We currently don't do prefix rewriting for windows binaries, this would require some more work to handle. Is this a usecase that's important to you, and would you be willing/capable to submit a PR?

from conda-pack.

amangarg96 avatar amangarg96 commented on June 2, 2024

Yes, I would be willing to submit a PR. Could you guide me towards what needs to be done for handling the prefix for windows binaries?

from conda-pack.

jcrist avatar jcrist commented on June 2, 2024

I'm not really sure what needs to be done, I wasn't aware that any absolute paths existed in the launcher exes on windows (and am not sure why the difference between packages). I'd need to read more/experiment a bit to give better advice. If you feel like looking into things, the relevant code is here:

if on_win:
def binary_replace(data, placeholder, new_prefix):
if placeholder not in data:
return data
return replace_pyzzer_entry_point_shebang(data, placeholder, new_prefix)

from conda-pack.

amangarg96 avatar amangarg96 commented on June 2, 2024

Thanks, I'll start probing into the code.

Are the prefixes expected to be set during the conda-pack step? Or with the conda-unpack script?

from conda-pack.

jcrist avatar jcrist commented on June 2, 2024

If a destination prefix is given, they should be replaced on packing, otherwise they should be recorded and fixed later in the conda-unpack script.

from conda-pack.

Masseeh avatar Masseeh commented on June 2, 2024

I tracked the issue and the problem is with case-sensitivity, therefore replace_prefix method should be changed to

def replace_prefix(data, mode, placeholder, new_prefix):
    if mode == 'text':
        data2 = text_replace(data, placeholder, new_prefix)
    elif mode == 'binary':
        data2 = binary_replace(data,
                               placeholder.encode('utf-8').lower(),
                               new_prefix.encode('utf-8').lower()
    return data2

I changed both of placeholder and new_prefix to lower case and also remove the line:

if len(data2) != len(data):

from conda-pack.

frascuchon avatar frascuchon commented on June 2, 2024

I tracked the issue and the problem is with case-sensitivity, therefore replace_prefix method should be changed to

def replace_prefix(data, mode, placeholder, new_prefix):
    if mode == 'text':
        data2 = text_replace(data, placeholder, new_prefix)
    elif mode == 'binary':
        data2 = binary_replace(data,
                               placeholder.encode('utf-8').lower(),
                               new_prefix.encode('utf-8').lower()
    return data2

I changed both of placeholder and new_prefix to lower case and also remove the line:

if len(data2) != len(data):

I confirm that it works !!!

If there is no PR in process, I could create one with these changes

from conda-pack.

achimnol avatar achimnol commented on June 2, 2024

I have encountered this issue and manually applying #100 has worked as expected.

from conda-pack.

HiskiRobo avatar HiskiRobo commented on June 2, 2024

If you need to fix this in a CI pipeline, i used the following to make it automated:

  1. get patch.py here https://github.com/techtonik/python-patch/blob/master/patch.py

  2. create separate build environment, install conda pack there, and run build from there (i called the env "builder", change from below if needed)

  3. apply patch in your #100 as below before packing (in your batch file)

bitsadmin /transfer condapackpatch /download /priority normal https://github.com/conda/conda-pack/commit/b55c186e42134a33aa585fbd4723010805091997.patch %cd%\conda-pack.diff || goto :error
@CALL python .\patch.py conda-pack.diff --directory=.\envs\builder\lib\site-packages
  1. run conda pack for needed environment(s) after this. The unpack command will then be patched for the packed envs.

from conda-pack.

mcg1969 avatar mcg1969 commented on June 2, 2024

Fixed by #122.

from conda-pack.

github-actions avatar github-actions commented on June 2, 2024

Hi there, thank you for your contribution!

This issue has been automatically locked because it has not had recent activity after being closed.

Please open a new issue if needed.

Thanks!

from conda-pack.

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.