chipsalliance / fasm

FPGA Assembly (FASM) Parser and Generator
https://fasm.readthedocs.io
Apache License 2.0
90 stars 30 forks source link

Remove generated files on "pip uninstall" #37

Closed HackerFoo closed 3 years ago

HackerFoo commented 3 years ago

Context: https://github.com/SymbiFlow/fasm/pull/28#issuecomment-742850726

litghost commented 1 hour ago •

Try this, with ANTLR4 runtime installed:

python3 -mvenv test_env source test_env/bin/activate pip install -v git+https://github.com/HackerFoo/fasm.git@antltr_cpp pip uninstall fasm

I get the following message when running pip uninstall fasm:

pip uninstall fasm Found existing installation: fasm 0.0.2 Uninstalling fasm-0.0.2: Would remove: test_pip/bin/fasm test_pip/lib/python3.7/site-packages/fasm-0.0.2-py3.7.egg-info test_pip/lib/python3.7/site-packages/fasm/* Would not remove (might be manually added): test_pip/lib/python3.7/site-packages/fasm/parser/libparse_fasm.so test_pip/lib/python3.7/site-packages/fasm/parser/tags.py Proceed (y/n)?

Note the lines under Would not remove (might be manually added):. Even if I say y, it doesn't remove the .so and tags.py.

litghost commented 3 years ago

Solution was found in the setuptools documentation: https://setuptools.readthedocs.io/en/latest/setuptools.html#new-and-changed-setup-keywords

Building and Distributing Packages with Setuptools — setuptools 51.0.0 documentation
litghost commented 3 years ago

Fixed in #28

HackerFoo commented 3 years ago

Specifically, the solution was to add a pyproject.toml in the root with the following content:

[build-system]
requires = ["setuptools", "wheel"]

The link above only mentions this can be used for a setup.py-less package, but I'm not sure why it fixes this problem, as the fasm package does have a setup.py.

I found this, so it seems like the right thing to do. I just don't understand why it fixes the problem.

litghost commented 3 years ago

Without pyproject.toml, the wheel dependency is not installed. When I installed the package in a fresh py3.7, it warned that it was not building a wheel package because wheel was not installed. That lead to the link in https://github.com/SymbiFlow/fasm/issues/37#issuecomment-743353406, which specifies how to install packages prior to invoking setup.py, which is basically what pyproject.toml is for.