facebookincubator / xar

executable archive format
Other
1.57k stars 55 forks source link

add a `--force` flag to pass force=True to add_distribution? #13

Closed nathantsoi closed 6 years ago

nathantsoi commented 6 years ago

Perhaps there is a better fix for this, but packaging selenium, I get existing file errors unless I patch https://github.com/facebookincubator/xar/blob/master/xar/xar_builder.py#L392 to force=True

e.g.

-        wheel.install(sys_paths, xar_paths, force=False)
+        wheel.install(sys_paths, xar_paths, force=True)

Any suggestions or should I look into passing through a --force flag?

edit: to clarify, packaging an executable with selenium as a dependency.

terrelln commented 6 years ago

Hmm, it shouldn't require force=True, I'll look into it.

terrelln commented 6 years ago

Can you provide reproduction instructions? I'm not sure how to build selenium.

nathantsoi commented 6 years ago

here ya go: https://github.com/nathantsoi/xar_packaging_test

building this with: pipenv run python setup.py bdist_xar

i get:

removing 'build/bdist.macosx-10.13-x86_64/xar' (and everything under it)
Traceback (most recent call last):
  File "setup.py", line 14, in <module>
    entry_points={'console_scripts':['test=test:main']}
  File "/Users/ntsoi/.local/share/virtualenvs/testpackage-OKd-JeQ2/lib/python3.7/site-packages/setuptools/__init__.py", line 131, in setup
    return distutils.core.setup(**attrs)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/Users/ntsoi/.local/share/virtualenvs/testpackage-OKd-JeQ2/lib/python3.7/site-packages/xar/commands/bdist_xar.py", line 232, in run
    xar.add_distribution(dep)
  File "/Users/ntsoi/.local/share/virtualenvs/testpackage-OKd-JeQ2/lib/python3.7/site-packages/xar/xar_builder.py", line 392, in add_distribution
    wheel.install(sys_paths, xar_paths, force=False)
  File "/Users/ntsoi/.local/share/virtualenvs/testpackage-OKd-JeQ2/lib/python3.7/site-packages/xar/py_util.py", line 261, in install
    self.copy_installation(src_paths, dst_paths, force)
  File "/Users/ntsoi/.local/share/virtualenvs/testpackage-OKd-JeQ2/lib/python3.7/site-packages/xar/py_util.py", line 355, in copy_installation
    raise self.Error("'%s' already exists" % dst_record)
xar.py_util.Error: '/var/folders/36/1q_9rkrj1xv5vx9qmvb8790c0000gn/T/tmprpq8xf49/selenium/webdriver/firefox/amd64/x_ignore_nofocus.so' already exists
terrelln commented 6 years ago

Awesome, I reproduced the failure! I will look into it, and get a fix out.

terrelln commented 6 years ago

The file selenium/webdriver/firefox/amd64/x_ignore_nofocus.so is present in the data, and in the {pure,plat}lib install locations, which are the same for XAR. In this case passing the force flag would work, since they are the same file, but I'm not sure if is a good idea in general.

Ideally wheel would have a flag meaning "don't force, but its okay to have duplicated files have the same sha256".

terrelln commented 6 years ago

It should be fixed once PR #15 lands.